public ActionResult Index() { #region User identification IIdentity context = HttpContext.User.Identity; string userId = ""; bool admin = false; bool customerCreator = false; bool purchaseOrderCreator = false; int companyId = 0; string userName = ""; AppConnData appConnData = new AppConnData(); if (context.IsAuthenticated) { System.Web.Security.FormsIdentity ci = (System.Web.Security.FormsIdentity)HttpContext.User.Identity; string[] userRole = ci.Ticket.UserData.Split('|'); userId = userRole[0]; admin = int.Parse(userRole[1]) == 1 ? true : false; customerCreator = int.Parse(userRole[2]) == 1 ? true : false; purchaseOrderCreator = int.Parse(userRole[3]) == 1 ? true : false; companyId = int.Parse(userRole[4]); userName = ci.Name; appConnData = GetAppConnData(companyId); } #endregion List<CompanyParameter> companyParameters = BizCompanyParameter.GetList(companyId).ToList(); string MaxOlderOrderDays = companyParameters.Where(x => x.idParameter.Equals(4)).Select(x => x.value).FirstOrDefault(); string batchMarketingTransactions = companyParameters.Where(x => x.idParameter.Equals(5)).Select(x => x.value).FirstOrDefault(); List<ORDR> orders = BizSalesOrderDraft.GetPendingList(userId, companyId, int.Parse(MaxOlderOrderDays)) //.Where(x => x.draftDM.Equals(false) && x.draftLC.Equals(false)) .ToList(); List<ORDRViewModel> listOrders = new List<ORDRViewModel>(); List<ProcessQueue> pendingByProcess = BizProcessQueue.GetList(companyId, int.Parse(MaxOlderOrderDays)).ToList(); vmOrderQueue model = new vmOrderQueue(); foreach (ORDR item in orders) { if (batchMarketingTransactions == "Si") { if (pendingByProcess.Where(x => x.actionType == "A" && x.idTarget.Equals(item.id)).Count() == 0) { ORDRViewModel order = new ORDRViewModel() { id = HexSerialization.StringToHex(item.id.ToString()), cardCode = item.cardCode, cardName = !string.IsNullOrEmpty(item.cardName) ? item.cardName : "", docDate = item.docDate, comment = item.docEntry == null ? "No finalizada" : "Enviada a SAP correctamente", editable = item.docEntry == null ? true : false, }; listOrders.Add(order); //model.openOrders.Add(order); } else { ProcessQueue orderProcess = pendingByProcess.Where(x => x.actionType == "A" && x.idTarget.Equals(item.id)).FirstOrDefault(); ORDRViewModel order = new ORDRViewModel() { id = HexSerialization.StringToHex(item.id.ToString()), cardCode = item.cardCode, cardName = !string.IsNullOrEmpty(item.cardName) ? item.cardName : "", docDate = item.docDate, editable = false }; if (orderProcess.processed == null) order.comment = "En cola"; else { if (orderProcess.logMessage.Substring(0, 5) == "Error") order.redo = true; else order.redo = false; order.comment = string.Format("{0}", orderProcess.logMessage); } listOrders.Add(order); } } else { ORDRViewModel order = new ORDRViewModel() { id = HexSerialization.StringToHex(item.id.ToString()), cardCode = item.cardCode, cardName = !string.IsNullOrEmpty(item.cardName) ? item.cardName : "", docDate = item.docDate, comment = item.docEntry == null ? "No finalizada" : "Enviada a SAP correctamente", editable = item.docEntry == null ? true : false }; listOrders.Add(order); } } return View(listOrders.OrderByDescending(x => x.docDate).ToList()); }
public ActionResult AuthorizationReport() { #region User identification IIdentity context = HttpContext.User.Identity; string userId = ""; bool admin = false; bool customerCreator = false; bool purchaseOrderCreator = false; bool orderApprover = false; int companyId = 0; string userName = ""; AppConnData appConnData = new AppConnData(); if (context.IsAuthenticated) { System.Web.Security.FormsIdentity ci = (System.Web.Security.FormsIdentity)HttpContext.User.Identity; string[] userRole = ci.Ticket.UserData.Split('|'); userId = userRole[0]; admin = int.Parse(userRole[1]) == 1 ? true : false; customerCreator = int.Parse(userRole[2]) == 1 ? true : false; purchaseOrderCreator = int.Parse(userRole[3]) == 1 ? true : false; companyId = int.Parse(userRole[4]); userName = ci.Name; appConnData = GetAppConnData(companyId); orderApprover = int.Parse(userRole[7]) == 1 ? true : false; } #endregion List<ORDR> orders = new List<ORDR>(); if (orderApprover) { orders = BizSalesOrderDraft.GetPendingList(companyId).ToList(); } else { orders = BizSalesOrderDraft.GetPendingList(userId, companyId).ToList(); } List<ORDRViewModel> listOrders = new List<ORDRViewModel>(); //List<string> customers = orders.Select(x => x.cardCode).Distinct().ToList(); //List<GenericBusinessPartner> customerList = backEnd.GetBusinessPartnersByIds(CardType.Customer, customers, appConnData); foreach (ORDR item in orders) { ORDRViewModel order = new ORDRViewModel() { id = HexSerialization.StringToHex(item.id.ToString()), cardCode = item.cardCode, cardName = !string.IsNullOrEmpty(item.cardName) ? item.cardName : "", docDate = item.docDate, //comment = item.draftDM.Equals(true) ? "Dias de mora": "Sobrecupo" }; if (item.draftDM == null) item.draftDM = false; if (item.draftLC == null) item.draftLC = false; if (item.draftPB == null) item.draftPB = false; if ((bool)item.draftDM) order.comment = "Dias de mora"; if ((bool)item.draftLC) if (string.IsNullOrEmpty(order.comment)) order.comment = "Sobrecupo"; else order.comment += "-Sobrecupo"; if ((bool)item.draftPB) if (string.IsNullOrEmpty(order.comment)) order.comment = "Saldo a favor"; else order.comment += "-Saldo a favor"; order.status = item.authStatus; listOrders.Add(order); } ViewBag.orderApprover = orderApprover; return View(listOrders); }