using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using Kreta.BusinessLogic.Helpers; using Kreta.BusinessLogic.Helpers.SystemSettings; using Kreta.BusinessLogic.Security; using Kreta.Enums; using Kreta.Enums.ManualEnums; using Kreta.Framework; using Kreta.Web.Areas.Hianyzas.Models; using Kreta.Web.Areas.Hianyzas.Models.Mulasztasok; using Kreta.Web.Helpers; using Kreta.Web.Helpers.TabStrip; using Kreta.Web.Models.EditorTemplates; using Kreta.Web.Security; namespace Kreta.Web.Areas.Hianyzas.Controllers { public class BaseMulasztasokController : Controller { public List GetOsztalyCsoportList(bool setFirstItem = false) { IDictionary osztalyokEsCsoportok = OsztalyokEsCsoportokHelpers.GetOsztalyokVagyOsztalyokEsCsoportok(ClaimData.FelhasznaloId, osztalyfonokiFeladat: true); var result = osztalyokEsCsoportok.Select(x => new SelectListItem { Value = x.Key, Text = x.Value }).ToList(); if (setFirstItem && result.Any()) { if (ClaimData.FelhasznaloSzerepkorok.ContainsKey(SzerepkorTipusEnum.Naplo)) { var osztCsopId = new OsztalyCsoportHelper(ConnectionTypeExtensions.GetSessionConnectionType()).GetOsztalyfonokElsonekMegtalaltOsztalya(ClaimData.FelhasznaloId); if (osztCsopId.HasValue) { foreach (var r in result) { if (r.Value == osztCsopId.Value.ToString()) { r.Selected = true; break; } } } else { result[0].Selected = true; } } else { result[0].Selected = true; } } return result; } public List GetMulasztasokTabs(string mulasztasokControllerName) { List list = new List { new TabStripItemModel { ItemId = "0", ItemName = StringResourcesUtil.GetString(4332) /*Dátum nézet*/, Area = "Hianyzas", Controller = mulasztasokControllerName, Action = "GetMulasztasokDatumNezetTab" }, new TabStripItemModel { ItemId = "1", ItemName = StringResourcesUtil.GetString(4333) /*Tanuló nézet*/, Area = "Hianyzas", Controller = mulasztasokControllerName, Action = "GetMulasztasokTanuloNezetTab" }, new TabStripItemModel { ItemId = "2", ItemName = StringResourcesUtil.GetString(4334) /*Napló nézet*/, Area = "Hianyzas", Controller = mulasztasokControllerName, Action = "GetMulasztasokNaploNezetTab" } }; return list; } [NonAction] public ActionResult GetMulasztasokDatumNezetTab(string mulasztasokControllerName = null, string mulasztasokApiControllerName = null, int? szervezetTipusId = null) { var model = new MulasztasSearchModel { OsztalyCsoportList = GetOsztalyCsoportList(true) }; if(!string.IsNullOrWhiteSpace(mulasztasokControllerName)) { model.ControllerName = mulasztasokControllerName; } if (!string.IsNullOrWhiteSpace(mulasztasokApiControllerName)) { model.ApiControllerName = mulasztasokApiControllerName; } model.SzervezetTipusId = szervezetTipusId; return PartialView("Mulasztasok_DatumNezet_Tab", model); } [NonAction] public ActionResult GetMulasztasokDatumNezetDetailGrid(MulasztasokDatumNezetGridModel dateModel) { dateModel.SzerepkorViewType = SzerepkorViewTypeEnum.OsztalyfonokNezet; return PartialView("Mulasztasok_DatumNezet_DetailGrid", dateModel); } [NonAction] public ActionResult GetMulasztasokTanuloNezetTab(string mulasztasokControllerName = null, string mulasztasokApiControllerName = null, int? szervezetTipusId = null) { var model = new MulasztasSearchModel { OsztalyCsoportList = GetOsztalyCsoportList(true) }; if (!string.IsNullOrWhiteSpace(mulasztasokControllerName)) { model.ControllerName = mulasztasokControllerName; } if (!string.IsNullOrWhiteSpace(mulasztasokApiControllerName)) { model.ApiControllerName = mulasztasokApiControllerName; } model.SzervezetTipusId = szervezetTipusId; return PartialView("Mulasztasok_TanuloNezet_Tab", model); } [NonAction] public ActionResult GetMulasztasokTanuloNezetDetailGrid(MulasztasokTanuloNezetGridModel tanuloModel, bool GridHasDelete, int? SzervezetTipusId = null) { tanuloModel.GridHasDelete = GridHasDelete; tanuloModel.SzervezetTipusId = SzervezetTipusId; return PartialView("Mulasztasok_TanuloNezet_DetailGrid", tanuloModel); } [NonAction] public ActionResult GetMulasztasokNaploNezetTab(string mulasztasokControllerName = null, string mulasztasokApiControllerName = null, int? szervezetTipusId = null) { var model = new MulasztasSearchModel { OsztalyCsoportList = GetOsztalyCsoportList(true) }; if (!string.IsNullOrWhiteSpace(mulasztasokControllerName)) { model.ControllerName = mulasztasokControllerName; } if (!string.IsNullOrWhiteSpace(mulasztasokApiControllerName)) { model.ApiControllerName = mulasztasokApiControllerName; } model.SzervezetTipusId = szervezetTipusId; return PartialView("Mulasztasok_NaploNezet_Tab", model); } [NonAction] public ActionResult OpenTanuloMulasztasaiPopup(int tanuloId, int osztalyCsoportId, string apiControllerName = null, int? szervezetTipusId = null) { var model = new TanuloMulasztasaiPopupModel { TanuloId = tanuloId, SzerepkorViewType = SzerepkorViewTypeEnum.OsztalyfonokNezet, OsztalyCsoportId = osztalyCsoportId, ApiControllerName = apiControllerName, SzervezetTipusId = szervezetTipusId }; var popupModel = new PopUpModel(model, "TanuloMulasztasai_Popup"); popupModel.AddCancelBtn(popupModel, "MulasztasKezelesHelper.detailTanuloWindowCancel"); return PartialView(Constants.General.PopupView, popupModel); } [NonAction] public ActionResult TanuloKezeletlenMulasztasaiDetailGrid(TanuloMulasztasaiPopupModel gridModel, string apiControllerName = null, int? szervezetTipusId = null) { gridModel.SzerepkorViewType = SzerepkorViewTypeEnum.OsztalyfonokNezet; gridModel.Kezeletlen = true; gridModel.ApiControllerName = apiControllerName; gridModel.SzervezetTipusId = szervezetTipusId; return PartialView("TanuloMulasztasai_DetailGrid", gridModel); } [NonAction] public ActionResult TanuloKezeltMulasztasaiDetailGrid(TanuloMulasztasaiPopupModel gridModel, string apiControllerName = null, int? szervezetTipusId = null) { gridModel.SzerepkorViewType = SzerepkorViewTypeEnum.OsztalyfonokNezet; gridModel.Kezeletlen = false; gridModel.ApiControllerName = apiControllerName; gridModel.SzervezetTipusId = szervezetTipusId; return PartialView("TanuloMulasztasai_DetailGrid", gridModel); } } }