/* INDEX **********************************************************************************************************************************************/ // GET: Suppliers public ActionResult Index(int?rss, string FILTER_Keyword, int?FILTER_Active) { if (!UserAccountsController.getUserAccess(Session).Suppliers_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } if (rss != null) { ViewBag.RemoveDatatablesStateSave = rss; return(View()); } else { setViewBag(FILTER_Keyword, FILTER_Active); return(View(get(FILTER_Keyword, FILTER_Active))); } }
/* PRINT **********************************************************************************************************************************************/ // GET: Payments/Print public ActionResult Print(Guid?id) { if (id == null || !UserAccountsController.getUserAccess(Session).Payments_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } PaymentsModel model = get((Guid)id); ViewBag.InvoiceHeaderText = new BranchesController().get(Helper.getActiveBranchId(Session)).InvoiceHeaderText; ViewData["SaleInvoiceItems"] = SaleInvoiceItemsController.get(null, null, null, model.Id, null, null, null, null, null, null) .OrderBy(x => x.SaleInvoices_No) .ThenBy(x => x.RowNo) .ToList(); ViewData["PaymentItems"] = PaymentItemsController.get(null, model.Id); ViewBag.TotalAmount = model.CashAmount + model.ConsignmentAmount + model.DebitAmount; return(View(model)); }
/* INDEX **********************************************************************************************************************************************/ // GET: PayrollPayments public ActionResult Index(int?rss, string FILTER_Keyword, int?FILTER_Cancelled, int?FILTER_Approved, bool?FILTER_chkDateFrom, DateTime?FILTER_DateFrom, bool?FILTER_chkDateTo, DateTime?FILTER_DateTo) { if (!UserAccountsController.getUserAccess(Session).PayrollPayments_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } setViewBag(FILTER_Keyword, FILTER_Cancelled, FILTER_Approved, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo); if (rss != null) { ViewBag.RemoveDatatablesStateSave = rss; return(View()); } else { return(View(get(FILTER_Keyword, FILTER_Cancelled, FILTER_Approved, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo))); } }
public void add(FilesModel model) { model.UserAccounts_Id = (Guid)UserAccountsController.getUserId(Session); model.No = WebDBConnection.GetNextHex(db.Database, "Files", "No"); WebDBConnection.Insert(db.Database, "Files", DBConnection.getSqlParameter(FilesModel.COL_Id.Name, model.Id), DBConnection.getSqlParameter(FilesModel.COL_OnlineFileId.Name, model.OnlineFileId), DBConnection.getSqlParameter(FilesModel.COL_ParentId.Name, model.ParentId), DBConnection.getSqlParameter(FilesModel.COL_Branches_Id.Name, model.Branches_Id), DBConnection.getSqlParameter(FilesModel.COL_No.Name, model.No), DBConnection.getSqlParameter(FilesModel.COL_Filename.Name, model.Filename), DBConnection.getSqlParameter(FilesModel.COL_DirectoryName.Name, model.DirectoryName), DBConnection.getSqlParameter(FilesModel.COL_Notes.Name, model.Notes), DBConnection.getSqlParameter(FilesModel.COL_UserAccounts_Id.Name, model.UserAccounts_Id), DBConnection.getSqlParameter(FilesModel.COL_Timestamp.Name, model.Timestamp), DBConnection.getSqlParameter(FilesModel.COL_IsDeleted.Name, model.IsDeleted), DBConnection.getSqlParameter(FilesModel.COL_Approved.Name, model.Approved) ); }
/* CREATE *********************************************************************************************************************************************/ public ActionResult Create(string FILTER_Keyword, string FILTER_Custom, DayOfWeekEnum?DayOfWeek, string StartTime, Guid?Id) { if (!UserAccountsController.getUserAccess(Session).ClubSchedules_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } setViewBag(FILTER_Keyword); ClubSchedulesModel model = new ClubSchedulesModel(); if (DayOfWeek != null) { model.DayOfWeek = (DayOfWeekEnum)DayOfWeek; } if (!string.IsNullOrEmpty(StartTime)) { model.StartTime = Util.standardizeTimeToIgnoreDate(StartTime); model.EndTime = model.StartTime.AddHours(1); } return(View(model)); }
/* EDIT ***********************************************************************************************************************************************/ // GET: StudentSchedules/Edit/{id} public ActionResult Edit(Guid?id, string FILTER_Keyword, string FILTER_UserAccounts_Name, string FILTER_Custom) { if (!UserAccountsController.getUserAccess(Session).StudentSchedules_View) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } if (id == null) { return(RedirectToAction(nameof(Index))); } setViewBag(FILTER_Keyword, FILTER_UserAccounts_Name, FILTER_Custom); StudentSchedulesModel model = get((Guid)id); if (model.SessionHours_Remaining == 0) { model.SaleInvoiceItems_Id = Guid.Empty; ModelState.AddModelError(StudentSchedulesModel.COL_SaleInvoiceItems_Id.Name, "Paket sebelumnya sudah tidak memiliki sisa jam"); } return(View(model)); }
public static List <StudentSchedulesModel> get(HttpSessionStateBase Session, Guid?Id, Guid?Tutor_UserAccounts_Id, Guid?Student_UserAccounts_Id, DayOfWeekEnum?DayOfWeek, DateTime?StartTime, DateTime?EndTime, Guid?SaleInvoiceItems_Id, Guid?Languages_Id, string FILTER_Keyword, string FILTER_UserAccounts_Name) { UserAccountsModel UserAccount = UserAccountsController.getUserAccount(Session); return(new DBContext().Database.SqlQuery <StudentSchedulesModel>(@" SELECT StudentSchedules.*, StudentSchedules.LessonLocation AS LessonLocationRadioButton, Tutor_UserAccounts.Fullname AS Tutor_UserAccounts_Name, Tutor_UserAccounts.No AS Tutor_UserAccounts_No, Student_UserAccounts.Fullname AS Student_UserAccounts_Name, Student_UserAccounts.No AS Student_UserAccounts_No, Student_UserAccounts.Branches AS Student_UserAccounts_Branches, SaleInvoices.No AS SaleInvoices_No, SaleInvoiceItems.Description AS SaleInvoiceItems_Description, Languages.Name AS Languages_Name, SaleInvoiceItems.SessionHours_Remaining AS SessionHours_Remaining FROM StudentSchedules LEFT JOIN UserAccounts Tutor_UserAccounts ON Tutor_UserAccounts.Id = StudentSchedules.Tutor_UserAccounts_Id LEFT JOIN UserAccounts Student_UserAccounts ON Student_UserAccounts.Id = StudentSchedules.Student_UserAccounts_Id LEFT JOIN SaleInvoiceItems ON SaleInvoiceItems.Id = StudentSchedules.SaleInvoiceItems_Id LEFT JOIN LessonPackages ON LessonPackages.Id = SaleInvoiceItems.LessonPackages_Id LEFT JOIN Languages ON Languages.Id = LessonPackages.Languages_Id LEFT JOIN SaleInvoices ON SaleInvoices.Id = SaleInvoiceItems.SaleInvoices_Id WHERE 1=1 AND (@Id IS NULL OR StudentSchedules.Id = @Id) AND (@Id IS NOT NULL OR ( (@Tutor_UserAccounts_Id IS NULL OR StudentSchedules.Tutor_UserAccounts_Id = @Tutor_UserAccounts_Id) AND (@Student_UserAccounts_Id IS NULL OR StudentSchedules.Student_UserAccounts_Id = @Student_UserAccounts_Id) AND (@ShowOnlyOwnUserData = 0 OR (StudentSchedules.Student_UserAccounts_Id = @UserAccounts_Id OR StudentSchedules.Tutor_UserAccounts_Id = @UserAccounts_Id)) AND (@DayOfWeek IS NULL OR StudentSchedules.[DayOfWeek] = @DayOfWeek) AND ((@StartTime IS NULL OR (@StartTime >= StudentSchedules.StartTime OR @StartTime <= StudentSchedules.EndTime)) OR (@EndTime IS NULL OR (@EndTime >= StudentSchedules.StartTime OR @EndTime <= StudentSchedules.EndTime)) ) AND (@Languages_Id IS NULL OR Languages.Id = @Languages_Id) AND (@SaleInvoiceItems_Id IS NULL OR StudentSchedules.SaleInvoiceItems_Id = @SaleInvoiceItems_Id) AND (@FILTER_Keyword IS NULL OR ( Student_UserAccounts.Fullname LIKE '%'+@FILTER_Keyword+'%' OR SaleInvoices.No LIKE '%'+@FILTER_Keyword+'%' OR StudentSchedules.DayOfWeek LIKE '%'+@FILTER_Keyword+'%' OR StudentSchedules.LessonLocation LIKE '%'+@FILTER_Keyword+'%' )) AND (@FILTER_UserAccounts_Name IS NULL OR ( Tutor_UserAccounts.Fullname LIKE '%'+@FILTER_UserAccounts_Name+'%' )) AND (@Branches_Id IS NULL OR Student_UserAccounts.Branches LIKE '%'+ convert(nvarchar(50), @Branches_Id) + '%') )) ORDER BY Student_UserAccounts.Fullname ASC, StudentSchedules.DayOfWeek ASC, StudentSchedules.StartTime ASC, StudentSchedules.EndTime ASC, Tutor_UserAccounts.Fullname ASC ", DBConnection.getSqlParameter(StudentSchedulesModel.COL_Id.Name, Id), DBConnection.getSqlParameter(StudentSchedulesModel.COL_Tutor_UserAccounts_Id.Name, Tutor_UserAccounts_Id), DBConnection.getSqlParameter(StudentSchedulesModel.COL_Student_UserAccounts_Id.Name, Student_UserAccounts_Id), DBConnection.getSqlParameter(StudentSchedulesModel.COL_DayOfWeek.Name, DayOfWeek), DBConnection.getSqlParameter(StudentSchedulesModel.COL_StartTime.Name, StartTime), DBConnection.getSqlParameter(StudentSchedulesModel.COL_EndTime.Name, EndTime), DBConnection.getSqlParameter(StudentSchedulesModel.COL_SaleInvoiceItems_Id.Name, SaleInvoiceItems_Id), DBConnection.getSqlParameter(StudentSchedulesModel.COL_Languages_Id.Name, Languages_Id), DBConnection.getSqlParameter("Branches_Id", Helper.getActiveBranchId(Session)), DBConnection.getSqlParameter("FILTER_Keyword", FILTER_Keyword), DBConnection.getSqlParameter("FILTER_UserAccounts_Name", FILTER_UserAccounts_Name), DBConnection.getSqlParameter("ShowOnlyOwnUserData", SettingsController.ShowOnlyOwnUserData(UserAccount.Roles_List)), DBConnection.getSqlParameter("UserAccounts_Id", UserAccount.Id) ).ToList()); }
public static bool hasActiveClubSubscription(HttpSessionStateBase Session) { return(hasActiveClubSubscriptions((Guid)UserAccountsController.getUserId(Session), 0).Count > 0); }
public static List <LessonSessionsModel> get(HttpSessionStateBase Session, Guid?Id, string FILTER_Keyword, string FILTER_InvoiceNo, bool?FILTER_chkDateFrom, DateTime?FILTER_DateFrom, bool?FILTER_chkDateTo, DateTime?FILTER_DateTo, int?Cancelled) { Guid Branches_Id = Helper.getActiveBranchId(Session); if (FILTER_chkDateFrom == null || !(bool)FILTER_chkDateFrom) { FILTER_DateFrom = null; } if (FILTER_chkDateTo == null || !(bool)FILTER_chkDateTo) { FILTER_DateTo = null; } string ShowOnlyOwnUserDataClause = ""; if (UserAccountsController.getShowOnlyUserData(Session)) { ShowOnlyOwnUserDataClause = string.Format(" AND (Student_UserAccounts.Id = '{0}' OR Tutor_UserAccounts.Id = '{0}')", UserAccountsController.getUserId(Session)); } string sql = string.Format(@" SELECT LessonSessions.*, SaleInvoices.No AS SaleInvoices_No, SaleInvoiceItems.Description AS SaleInvoiceItems_Description, Student_UserAccounts.Fullname AS Student_UserAccounts_Fullname, Student_UserAccounts.No AS Student_UserAccounts_No, Tutor_UserAccounts.Fullname AS Tutor_UserAccounts_Fullname, Tutor_UserAccounts.No AS Tutor_UserAccounts_No, ROW_NUMBER() OVER (ORDER BY LessonSessions.Timestamp DESC) AS InitialRowNumber FROM LessonSessions LEFT JOIN SaleInvoiceItems ON SaleInvoiceItems.Id = LessonSessions.SaleInvoiceItems_Id LEFT JOIN SaleInvoices ON SaleInvoices.Id = SaleInvoiceItems.SaleInvoices_Id LEFT JOIN UserAccounts Student_UserAccounts ON Student_UserAccounts.Id = SaleInvoices.Customer_UserAccounts_Id LEFT JOIN UserAccounts Tutor_UserAccounts ON Tutor_UserAccounts.Id = LessonSessions.Tutor_UserAccounts_Id WHERE 1=1 AND (@Id IS NULL OR LessonSessions.Id = @Id) AND (@Id IS NOT NULL OR ( LessonSessions.Branches_Id = @Branches_Id AND (@FILTER_Keyword IS NULL OR ( LessonSessions.No LIKE '%'+@FILTER_Keyword+'%' )) AND (@FILTER_DateFrom IS NULL OR LessonSessions.Timestamp >= @FILTER_DateFrom) AND (@FILTER_DateTo IS NULL OR LessonSessions.Timestamp <= @FILTER_DateTo) AND (@Cancelled IS NULL OR LessonSessions.Cancelled = @Cancelled) AND (@FILTER_InvoiceNo IS NULL OR (LessonSessions.SaleInvoiceItems_Id IN ( SELECT SaleInvoiceItems.Id FROM SaleInvoiceItems LEFT JOIN SaleInvoices ON Saleinvoices.Id = SaleInvoiceItems.SaleInvoices_Id WHERE SaleInvoices.No = @FILTER_InvoiceNo ))) {0} )) ORDER BY LessonSessions.Timestamp DESC ", ShowOnlyOwnUserDataClause); return(new DBContext().Database.SqlQuery <LessonSessionsModel>(sql, DBConnection.getSqlParameter(LessonSessionsModel.COL_Id.Name, Id), DBConnection.getSqlParameter(LessonSessionsModel.COL_Branches_Id.Name, Branches_Id), DBConnection.getSqlParameter(LessonSessionsModel.COL_Cancelled.Name, Cancelled), DBConnection.getSqlParameter("FILTER_Keyword", FILTER_Keyword), DBConnection.getSqlParameter("FILTER_InvoiceNo", FILTER_InvoiceNo), DBConnection.getSqlParameter("FILTER_DateFrom", FILTER_DateFrom), DBConnection.getSqlParameter("FILTER_DateTo", Util.getAsEndDate(FILTER_DateTo)) ).ToList()); }
/* EDIT ***********************************************************************************************************************************************/ // GET: LessonSessions/Edit/{id} public ActionResult Edit(Guid?id, string FILTER_Keyword, string FILTER_InvoiceNo, int?FILTER_Cancelled, bool?FILTER_chkDateFrom, DateTime?FILTER_DateFrom, bool?FILTER_chkDateTo, DateTime?FILTER_DateTo) { if (!UserAccountsController.getUserAccess(Session).LessonSessions_Edit&& !UserAccountsController.getUserAccess(Session).LessonSessions_EditReviewAndInternalNotes) { return(RedirectToAction(nameof(HomeController.Index), "Home")); } if (id == null) { return(RedirectToAction(nameof(Index))); } setViewBag(FILTER_Keyword, FILTER_InvoiceNo, FILTER_Cancelled, FILTER_chkDateFrom, FILTER_DateFrom, FILTER_chkDateTo, FILTER_DateTo); return(View(get(id.Value))); }
public ActionResult Create(string id, string JsonPayments) { List <SaleInvoicesModel> saleinvoices = SaleInvoicesController.get(Session, id).OrderBy(x => x.Timestamp).ToList(); if (ModelState.IsValid) { PaymentsModel payment = JsonConvert.DeserializeObject <PaymentsModel>(JsonPayments); payment.Id = Guid.NewGuid(); payment.No = Util.incrementHexNumber(getLastNo()); payment.Timestamp = Helper.getCurrentDateTime(); if (payment.DebitAmount == 0) { payment.DebitBank = null; payment.DebitNumber = null; payment.DebitOwnerName = null; payment.DebitRefNo = null; } if (payment.ConsignmentAmount == 0) { payment.Consignments_Id = null; } //create payment items and update sale invoice due amount int RemainingPaymentAmount = payment.DebitAmount + payment.CashAmount + payment.ConsignmentAmount; int paymentItemAmount = 0; int dueBefore = 0; int dueAfter = 0; foreach (SaleInvoicesModel saleinvoice in saleinvoices) { dueBefore = saleinvoice.Due; dueAfter = saleinvoice.Due; if (RemainingPaymentAmount == 0) { break; } else { if (RemainingPaymentAmount >= saleinvoice.Due) { paymentItemAmount = saleinvoice.Due; } else { paymentItemAmount = RemainingPaymentAmount; } RemainingPaymentAmount -= paymentItemAmount; dueAfter -= paymentItemAmount; SaleInvoicesController.update_Due(Session, db, saleinvoice.Id, saleinvoice.Due, saleinvoice.Due - paymentItemAmount); saleinvoice.Due -= paymentItemAmount; } PaymentItemsController.add(db, payment.Id, new PaymentItemsModel { Id = Guid.NewGuid(), Payments_Id = payment.Id, ReferenceId = saleinvoice.Id, Amount = paymentItemAmount, DueBefore = dueBefore, DueAfter = dueAfter }); } //create petty cash if (payment.CashAmount > 0) { PettyCashRecordsController.add(db, new PettyCashRecordsModel { Id = Guid.NewGuid(), Branches_Id = Helper.getActiveBranchId(Session), ReferenceId = payment.Id, No = "", Timestamp = payment.Timestamp, PettyCashRecordsCategories_Id = SettingsController.get().AutoEntryForCashPayments.Value, Notes = "Cash Payment [" + payment.No + "]", Amount = payment.CashAmount, Approved = false, UserAccounts_Id = (Guid)UserAccountsController.getUserId(Session), ExpenseCategories_Id = null }); } add(payment); return(RedirectToAction(nameof(Print), new { id = payment.Id })); } return(setCreateViewBagsAndReturn(id)); }
public ActionResult Edit(UserAccountRolesModel model) { if (ModelState.IsValid) { if (isExists(EnumActions.Edit, model.Id, model.Name)) { ModelState.AddModelError(UserAccountRolesModel.COL_Name.Name, $"{model.Name} sudah terdaftar"); } else { UserAccountRolesModel originalModel = get(model.Id); string log = string.Empty; log = Helper.append(log, originalModel.Name, model.Name, UserAccountRolesModel.COL_Name.LogDisplay); //Reminders log = Helper.append(log, originalModel.Reminders_Notes, model.Reminders_Notes, UserAccountRolesModel.COL_Reminders_Notes.LogDisplay); log = Helper.append(log, originalModel.Reminders_Add, model.Reminders_Add, UserAccountRolesModel.COL_Reminders_Add.LogDisplay); log = Helper.append(log, originalModel.Reminders_Edit, model.Reminders_Edit, UserAccountRolesModel.COL_Reminders_Edit.LogDisplay); log = Helper.append(log, originalModel.Reminders_View, model.Reminders_View, UserAccountRolesModel.COL_Reminders_View.LogDisplay); //Birthdays log = Helper.append(log, originalModel.Birthdays_Notes, model.Birthdays_Notes, UserAccountRolesModel.COL_Birthdays_Notes.LogDisplay); log = Helper.append(log, originalModel.Birthdays_View, model.Birthdays_View, UserAccountRolesModel.COL_Birthdays_View.LogDisplay); //UserAccounts log = Helper.append(log, originalModel.UserAccounts_Notes, model.UserAccounts_Notes, UserAccountRolesModel.COL_UserAccounts_Notes.LogDisplay); log = Helper.append(log, originalModel.UserAccounts_Add, model.UserAccounts_Add, UserAccountRolesModel.COL_UserAccounts_Add.LogDisplay); log = Helper.append(log, originalModel.UserAccounts_Edit, model.UserAccounts_Edit, UserAccountRolesModel.COL_UserAccounts_Edit.LogDisplay); log = Helper.append(log, originalModel.UserAccounts_View, model.UserAccounts_View, UserAccountRolesModel.COL_UserAccounts_View.LogDisplay); log = Helper.append(log, originalModel.UserAccounts_ResetPassword, model.UserAccounts_ResetPassword, UserAccountRolesModel.COL_UserAccounts_ResetPassword.LogDisplay); log = Helper.append(log, originalModel.UserAccounts_EditRoles, model.UserAccounts_EditRoles, UserAccountRolesModel.COL_UserAccounts_EditRoles.LogDisplay); log = Helper.append(log, originalModel.UserAccounts_ViewAllRoles, model.UserAccounts_ViewAllRoles, UserAccountRolesModel.COL_UserAccounts_ViewAllRoles.LogDisplay); //User Account Roles log = Helper.append(log, originalModel.UserAccountRoles_Notes, model.UserAccountRoles_Notes, UserAccountRolesModel.COL_UserAccountRoles_Notes.LogDisplay); log = Helper.append(log, originalModel.UserAccountRoles_Add, model.UserAccountRoles_Add, UserAccountRolesModel.COL_UserAccountRoles_Add.LogDisplay); log = Helper.append(log, originalModel.UserAccountRoles_Edit, model.UserAccountRoles_Edit, UserAccountRolesModel.COL_UserAccountRoles_Edit.LogDisplay); log = Helper.append(log, originalModel.UserAccountRoles_View, model.UserAccountRoles_View, UserAccountRolesModel.COL_UserAccountRoles_View.LogDisplay); //Settings log = Helper.append(log, originalModel.Settings_Notes, model.Settings_Notes, UserAccountRolesModel.COL_Settings_Notes.LogDisplay); log = Helper.append(log, originalModel.Settings_Edit, model.Settings_Edit, UserAccountRolesModel.COL_Settings_Edit.LogDisplay); log = Helper.append(log, originalModel.Settings_View, model.Settings_View, UserAccountRolesModel.COL_Settings_View.LogDisplay); //Branches log = Helper.append(log, originalModel.Branches_Notes, model.Branches_Notes, UserAccountRolesModel.COL_Branches_Notes.LogDisplay); log = Helper.append(log, originalModel.Branches_Add, model.Branches_Add, UserAccountRolesModel.COL_Branches_Add.LogDisplay); log = Helper.append(log, originalModel.Branches_Edit, model.Branches_Edit, UserAccountRolesModel.COL_Branches_Edit.LogDisplay); log = Helper.append(log, originalModel.Branches_View, model.Branches_View, UserAccountRolesModel.COL_Branches_View.LogDisplay); //PromotionEvents log = Helper.append(log, originalModel.PromotionEvents_Notes, model.PromotionEvents_Notes, UserAccountRolesModel.COL_PromotionEvents_Notes.LogDisplay); log = Helper.append(log, originalModel.PromotionEvents_Add, model.PromotionEvents_Add, UserAccountRolesModel.COL_PromotionEvents_Add.LogDisplay); log = Helper.append(log, originalModel.PromotionEvents_Edit, model.PromotionEvents_Edit, UserAccountRolesModel.COL_PromotionEvents_Edit.LogDisplay); log = Helper.append(log, originalModel.PromotionEvents_View, model.PromotionEvents_View, UserAccountRolesModel.COL_PromotionEvents_View.LogDisplay); //PettyCashRecordsCategories log = Helper.append(log, originalModel.PettyCashRecordsCategories_Notes, model.PettyCashRecordsCategories_Notes, UserAccountRolesModel.COL_PettyCashRecordsCategories_Notes.LogDisplay); log = Helper.append(log, originalModel.PettyCashRecordsCategories_Add, model.PettyCashRecordsCategories_Add, UserAccountRolesModel.COL_PettyCashRecordsCategories_Add.LogDisplay); log = Helper.append(log, originalModel.PettyCashRecordsCategories_Edit, model.PettyCashRecordsCategories_Edit, UserAccountRolesModel.COL_PettyCashRecordsCategories_Edit.LogDisplay); log = Helper.append(log, originalModel.PettyCashRecordsCategories_View, model.PettyCashRecordsCategories_View, UserAccountRolesModel.COL_PettyCashRecordsCategories_View.LogDisplay); //Languages log = Helper.append(log, originalModel.Languages_Notes, model.Languages_Notes, UserAccountRolesModel.COL_Languages_Notes.LogDisplay); log = Helper.append(log, originalModel.Languages_Add, model.Languages_Add, UserAccountRolesModel.COL_Languages_Add.LogDisplay); log = Helper.append(log, originalModel.Languages_Edit, model.Languages_Edit, UserAccountRolesModel.COL_Languages_Edit.LogDisplay); log = Helper.append(log, originalModel.Languages_View, model.Languages_View, UserAccountRolesModel.COL_Languages_View.LogDisplay); //LessonTypes log = Helper.append(log, originalModel.LessonTypes_Notes, model.LessonTypes_Notes, UserAccountRolesModel.COL_LessonTypes_Notes.LogDisplay); log = Helper.append(log, originalModel.LessonTypes_Add, model.LessonTypes_Add, UserAccountRolesModel.COL_LessonTypes_Add.LogDisplay); log = Helper.append(log, originalModel.LessonTypes_Edit, model.LessonTypes_Edit, UserAccountRolesModel.COL_LessonTypes_Edit.LogDisplay); log = Helper.append(log, originalModel.LessonTypes_View, model.LessonTypes_View, UserAccountRolesModel.COL_LessonTypes_View.LogDisplay); //LessonPackages log = Helper.append(log, originalModel.LessonPackages_Notes, model.LessonPackages_Notes, UserAccountRolesModel.COL_LessonPackages_Notes.LogDisplay); log = Helper.append(log, originalModel.LessonPackages_Add, model.LessonPackages_Add, UserAccountRolesModel.COL_LessonPackages_Add.LogDisplay); log = Helper.append(log, originalModel.LessonPackages_Edit, model.LessonPackages_Edit, UserAccountRolesModel.COL_LessonPackages_Edit.LogDisplay); log = Helper.append(log, originalModel.LessonPackages_View, model.LessonPackages_View, UserAccountRolesModel.COL_LessonPackages_View.LogDisplay); //Consignments log = Helper.append(log, originalModel.Consignments_Notes, model.Consignments_Notes, UserAccountRolesModel.COL_Consignments_Notes.LogDisplay); log = Helper.append(log, originalModel.Consignments_Add, model.Consignments_Add, UserAccountRolesModel.COL_Consignments_Add.LogDisplay); log = Helper.append(log, originalModel.Consignments_Edit, model.Consignments_Edit, UserAccountRolesModel.COL_Consignments_Edit.LogDisplay); log = Helper.append(log, originalModel.Consignments_View, model.Consignments_View, UserAccountRolesModel.COL_Consignments_View.LogDisplay); //Vouchers log = Helper.append(log, originalModel.Vouchers_Notes, model.Vouchers_Notes, UserAccountRolesModel.COL_Vouchers_Notes.LogDisplay); log = Helper.append(log, originalModel.Vouchers_Add, model.Vouchers_Add, UserAccountRolesModel.COL_Vouchers_Add.LogDisplay); log = Helper.append(log, originalModel.Vouchers_Edit, model.Vouchers_Edit, UserAccountRolesModel.COL_Vouchers_Edit.LogDisplay); log = Helper.append(log, originalModel.Vouchers_View, model.Vouchers_View, UserAccountRolesModel.COL_Vouchers_View.LogDisplay); //Suppliers log = Helper.append(log, originalModel.Suppliers_Notes, model.Suppliers_Notes, UserAccountRolesModel.COL_Suppliers_Notes.LogDisplay); log = Helper.append(log, originalModel.Suppliers_Add, model.Suppliers_Add, UserAccountRolesModel.COL_Suppliers_Add.LogDisplay); log = Helper.append(log, originalModel.Suppliers_Edit, model.Suppliers_Edit, UserAccountRolesModel.COL_Suppliers_Edit.LogDisplay); log = Helper.append(log, originalModel.Suppliers_View, model.Suppliers_View, UserAccountRolesModel.COL_Suppliers_View.LogDisplay); //Units log = Helper.append(log, originalModel.Units_Notes, model.Units_Notes, UserAccountRolesModel.COL_Units_Notes.LogDisplay); log = Helper.append(log, originalModel.Units_Add, model.Units_Add, UserAccountRolesModel.COL_Units_Add.LogDisplay); log = Helper.append(log, originalModel.Units_Edit, model.Units_Edit, UserAccountRolesModel.COL_Units_Edit.LogDisplay); log = Helper.append(log, originalModel.Units_View, model.Units_View, UserAccountRolesModel.COL_Units_View.LogDisplay); //ExpenseCategories log = Helper.append(log, originalModel.ExpenseCategories_Notes, model.ExpenseCategories_Notes, UserAccountRolesModel.COL_ExpenseCategories_Notes.LogDisplay); log = Helper.append(log, originalModel.ExpenseCategories_Add, model.ExpenseCategories_Add, UserAccountRolesModel.COL_ExpenseCategories_Add.LogDisplay); log = Helper.append(log, originalModel.ExpenseCategories_Edit, model.ExpenseCategories_Edit, UserAccountRolesModel.COL_ExpenseCategories_Edit.LogDisplay); log = Helper.append(log, originalModel.ExpenseCategories_View, model.ExpenseCategories_View, UserAccountRolesModel.COL_ExpenseCategories_View.LogDisplay); //Services log = Helper.append(log, originalModel.Services_Notes, model.Services_Notes, UserAccountRolesModel.COL_Services_Notes.LogDisplay); log = Helper.append(log, originalModel.Services_Add, model.Services_Add, UserAccountRolesModel.COL_Services_Add.LogDisplay); log = Helper.append(log, originalModel.Services_Edit, model.Services_Edit, UserAccountRolesModel.COL_Services_Edit.LogDisplay); log = Helper.append(log, originalModel.Services_View, model.Services_View, UserAccountRolesModel.COL_Services_View.LogDisplay); //Products log = Helper.append(log, originalModel.Products_Notes, model.Products_Notes, UserAccountRolesModel.COL_Products_Notes.LogDisplay); log = Helper.append(log, originalModel.Products_Add, model.Products_Add, UserAccountRolesModel.COL_Products_Add.LogDisplay); log = Helper.append(log, originalModel.Products_Edit, model.Products_Edit, UserAccountRolesModel.COL_Products_Edit.LogDisplay); log = Helper.append(log, originalModel.Products_View, model.Products_View, UserAccountRolesModel.COL_Products_View.LogDisplay); //SaleInvoices log = Helper.append(log, originalModel.SaleInvoices_Notes, model.SaleInvoices_Notes, UserAccountRolesModel.COL_SaleInvoices_Notes.LogDisplay); log = Helper.append(log, originalModel.SaleInvoices_Add, model.SaleInvoices_Add, UserAccountRolesModel.COL_SaleInvoices_Add.LogDisplay); log = Helper.append(log, originalModel.SaleInvoices_Edit, model.SaleInvoices_Edit, UserAccountRolesModel.COL_SaleInvoices_Edit.LogDisplay); log = Helper.append(log, originalModel.SaleInvoices_View, model.SaleInvoices_View, UserAccountRolesModel.COL_SaleInvoices_View.LogDisplay); log = Helper.append(log, originalModel.SaleInvoices_Approve, model.SaleInvoices_Approve, UserAccountRolesModel.COL_SaleInvoices_Approve.LogDisplay); log = Helper.append(log, originalModel.SaleInvoices_TutorTravelCost_View, model.SaleInvoices_TutorTravelCost_View, UserAccountRolesModel.COL_SaleInvoices_TutorTravelCost_View.LogDisplay); //Payments log = Helper.append(log, originalModel.Payments_Notes, model.Payments_Notes, UserAccountRolesModel.COL_Payments_Notes.LogDisplay); log = Helper.append(log, originalModel.Payments_Add, model.Payments_Add, UserAccountRolesModel.COL_Payments_Add.LogDisplay); log = Helper.append(log, originalModel.Payments_Edit, model.Payments_Edit, UserAccountRolesModel.COL_Payments_Edit.LogDisplay); log = Helper.append(log, originalModel.Payments_View, model.Payments_View, UserAccountRolesModel.COL_Payments_View.LogDisplay); log = Helper.append(log, originalModel.Payments_Approve, model.Payments_Approve, UserAccountRolesModel.COL_Payments_Approve.LogDisplay); //PettyCashRecords log = Helper.append(log, originalModel.PettyCashRecords_Notes, model.PettyCashRecords_Notes, UserAccountRolesModel.COL_PettyCashRecords_Notes.LogDisplay); log = Helper.append(log, originalModel.PettyCashRecords_Add, model.PettyCashRecords_Add, UserAccountRolesModel.COL_PettyCashRecords_Add.LogDisplay); log = Helper.append(log, originalModel.PettyCashRecords_Edit, model.PettyCashRecords_Edit, UserAccountRolesModel.COL_PettyCashRecords_Edit.LogDisplay); log = Helper.append(log, originalModel.PettyCashRecords_View, model.PettyCashRecords_View, UserAccountRolesModel.COL_PettyCashRecords_View.LogDisplay); log = Helper.append(log, originalModel.PettyCashRecords_Approve, model.PettyCashRecords_Approve, UserAccountRolesModel.COL_PettyCashRecords_Approve.LogDisplay); //Inventory log = Helper.append(log, originalModel.Inventory_Notes, model.Inventory_Notes, UserAccountRolesModel.COL_Inventory_Notes.LogDisplay); log = Helper.append(log, originalModel.Inventory_Add, model.Inventory_Add, UserAccountRolesModel.COL_Inventory_Add.LogDisplay); log = Helper.append(log, originalModel.Inventory_Edit, model.Inventory_Edit, UserAccountRolesModel.COL_Inventory_Edit.LogDisplay); log = Helper.append(log, originalModel.Inventory_View, model.Inventory_View, UserAccountRolesModel.COL_Inventory_View.LogDisplay); //LessonSessions log = Helper.append(log, originalModel.LessonSessions_Notes, model.LessonSessions_Notes, UserAccountRolesModel.COL_LessonSessions_Notes.LogDisplay); log = Helper.append(log, originalModel.LessonSessions_Add, model.LessonSessions_Add, UserAccountRolesModel.COL_LessonSessions_Add.LogDisplay); log = Helper.append(log, originalModel.LessonSessions_Edit, model.LessonSessions_Edit, UserAccountRolesModel.COL_LessonSessions_Edit.LogDisplay); log = Helper.append(log, originalModel.LessonSessions_EditReviewAndInternalNotes, model.LessonSessions_EditReviewAndInternalNotes, UserAccountRolesModel.COL_LessonSessions_EditReviewAndInternalNotes.LogDisplay); log = Helper.append(log, originalModel.LessonSessions_View, model.LessonSessions_View, UserAccountRolesModel.COL_LessonSessions_View.LogDisplay); log = Helper.append(log, originalModel.LessonSessions_InternalNotes_View, model.LessonSessions_InternalNotes_View, UserAccountRolesModel.COL_LessonSessions_InternalNotes_View.LogDisplay); //HourlyRates log = Helper.append(log, originalModel.HourlyRates_Notes, model.HourlyRates_Notes, UserAccountRolesModel.COL_HourlyRates_Notes.LogDisplay); log = Helper.append(log, originalModel.HourlyRates_Add, model.HourlyRates_Add, UserAccountRolesModel.COL_HourlyRates_Add.LogDisplay); log = Helper.append(log, originalModel.HourlyRates_Edit, model.HourlyRates_Edit, UserAccountRolesModel.COL_HourlyRates_Edit.LogDisplay); log = Helper.append(log, originalModel.HourlyRates_View, model.HourlyRates_View, UserAccountRolesModel.COL_HourlyRates_View.LogDisplay); //PayrollPayments log = Helper.append(log, originalModel.PayrollPayments_Notes, model.PayrollPayments_Notes, UserAccountRolesModel.COL_PayrollPayments_Notes.LogDisplay); log = Helper.append(log, originalModel.PayrollPayments_Add, model.PayrollPayments_Add, UserAccountRolesModel.COL_PayrollPayments_Add.LogDisplay); log = Helper.append(log, originalModel.PayrollPayments_Edit, model.PayrollPayments_Edit, UserAccountRolesModel.COL_PayrollPayments_Edit.LogDisplay); log = Helper.append(log, originalModel.PayrollPayments_View, model.PayrollPayments_View, UserAccountRolesModel.COL_PayrollPayments_View.LogDisplay); log = Helper.append(log, originalModel.PayrollPayments_Approve, model.PayrollPayments_Approve, UserAccountRolesModel.COL_PayrollPayments_Approve.LogDisplay); //TutorSchedules log = Helper.append(log, originalModel.TutorSchedules_Notes, model.TutorSchedules_Notes, UserAccountRolesModel.COL_TutorSchedules_Notes.LogDisplay); log = Helper.append(log, originalModel.TutorSchedules_Add, model.TutorSchedules_Add, UserAccountRolesModel.COL_TutorSchedules_Add.LogDisplay); log = Helper.append(log, originalModel.TutorSchedules_Edit, model.TutorSchedules_Edit, UserAccountRolesModel.COL_TutorSchedules_Edit.LogDisplay); log = Helper.append(log, originalModel.TutorSchedules_View, model.TutorSchedules_View, UserAccountRolesModel.COL_TutorSchedules_View.LogDisplay); //StudentSchedules log = Helper.append(log, originalModel.StudentSchedules_Notes, model.StudentSchedules_Notes, UserAccountRolesModel.COL_StudentSchedules_Notes.LogDisplay); log = Helper.append(log, originalModel.StudentSchedules_Add, model.StudentSchedules_Add, UserAccountRolesModel.COL_StudentSchedules_Add.LogDisplay); log = Helper.append(log, originalModel.StudentSchedules_Edit, model.StudentSchedules_Edit, UserAccountRolesModel.COL_StudentSchedules_Edit.LogDisplay); log = Helper.append(log, originalModel.StudentSchedules_View, model.StudentSchedules_View, UserAccountRolesModel.COL_StudentSchedules_View.LogDisplay); //ClubSchedules log = Helper.append(log, originalModel.ClubSchedules_Notes, model.ClubSchedules_Notes, UserAccountRolesModel.COL_ClubSchedules_Notes.LogDisplay); log = Helper.append(log, originalModel.ClubSchedules_Add, model.ClubSchedules_Add, UserAccountRolesModel.COL_ClubSchedules_Add.LogDisplay); log = Helper.append(log, originalModel.ClubSchedules_Edit, model.ClubSchedules_Edit, UserAccountRolesModel.COL_ClubSchedules_Edit.LogDisplay); log = Helper.append(log, originalModel.ClubSchedules_View, model.ClubSchedules_View, UserAccountRolesModel.COL_ClubSchedules_View.LogDisplay); //Files log = Helper.append(log, originalModel.Files_Notes, model.Files_Notes, UserAccountRolesModel.COL_Files_Notes.LogDisplay); log = Helper.append(log, originalModel.Files_Add, model.Files_Add, UserAccountRolesModel.COL_Files_Add.LogDisplay); log = Helper.append(log, originalModel.Files_Edit, model.Files_Edit, UserAccountRolesModel.COL_Files_Edit.LogDisplay); log = Helper.append(log, originalModel.Files_View, model.Files_View, UserAccountRolesModel.COL_Files_View.LogDisplay); log = Helper.append(log, originalModel.Files_EditGlobal, model.Files_EditGlobal, UserAccountRolesModel.COL_Files_EditGlobal.LogDisplay); //Income Statement log = Helper.append(log, originalModel.IncomeStatement_Notes, model.IncomeStatement_Notes, UserAccountRolesModel.COL_IncomeStatement_Notes.LogDisplay); log = Helper.append(log, originalModel.IncomeStatement_View, model.IncomeStatement_View, UserAccountRolesModel.COL_IncomeStatement_View.LogDisplay); log = Helper.append(log, originalModel.IncomeStatement_ViewProfit, model.IncomeStatement_ViewProfit, UserAccountRolesModel.COL_IncomeStatement_ViewProfit.LogDisplay); if (!string.IsNullOrEmpty(log)) { db.Entry(model).State = EntityState.Modified; ActivityLogsController.AddEditLog(db, Session, model.Id, log); db.SaveChanges(); } UserAccountsController.updateLoginSession(Session); return(RedirectToAction(nameof(Index))); } } return(View(model)); }
public static bool ShowOnlyOwnUserData(HttpSessionStateBase Session) { return(ShowOnlyOwnUserData(UserAccountsController.getUserAccount(Session).Roles_List)); }
public static List <SaleInvoicesModel> get(HttpSessionStateBase Session, Guid?Id, string SaleInvoiceItemIdList, string FILTER_Keyword, string FILTER_PaymentNo, bool?FILTER_chkDateFrom, DateTime?FILTER_DateFrom, bool?FILTER_chkDateTo, DateTime?FILTER_DateTo, int?Cancelled, int?Approved, int?FILTER_HasDueAmount) { Guid Branches_Id = Helper.getActiveBranchId(Session); if (FILTER_chkDateFrom == null || !(bool)FILTER_chkDateFrom) { FILTER_DateFrom = null; } if (FILTER_chkDateTo == null || !(bool)FILTER_chkDateTo) { FILTER_DateTo = null; } string SaleInvoiceItemIdListClause = ""; if (!string.IsNullOrEmpty(SaleInvoiceItemIdList)) { SaleInvoiceItemIdListClause = string.Format("AND SaleInvoices.Id IN ({0})", UtilWebMVC.convertToSqlIdList(SaleInvoiceItemIdList)); } string ShowOnlyOwnUserDataClause = ""; if (UserAccountsController.getShowOnlyUserData(Session)) { ShowOnlyOwnUserDataClause = string.Format(" AND Customer_UserAccounts.Id = '{0}' ", UserAccountsController.getUserId(Session)); } string sql = string.Format(@" SELECT SaleInvoices.*, Branches.Name AS Branches_Name, Customer_UserAccounts.Fullname AS Customer_UserAccounts_Name, Customer_UserAccounts.No AS Customer_UserAccounts_No, ROW_NUMBER() OVER (ORDER BY SaleInvoices.No DESC) AS InitialRowNumber FROM SaleInvoices LEFT JOIN Branches ON Branches.Id = SaleInvoices.Branches_Id LEFT JOIN UserAccounts Customer_UserAccounts ON Customer_UserAccounts.Id = SaleInvoices.Customer_UserAccounts_Id WHERE 1=1 AND (@Id IS NULL OR SaleInvoices.Id = @Id) AND (@Id IS NOT NULL OR ( (@FILTER_Keyword IS NULL OR ( SaleInvoices.No LIKE '%'+@FILTER_Keyword+'%' OR Customer_UserAccounts.Fullname LIKE '%'+@FILTER_Keyword+'%' )) AND (@FILTER_PaymentNo IS NULL OR (SaleInvoices.Id IN ( SELECT SaleInvoices.Id FROM PaymentItems LEFT JOIN Payments ON Payments.Id = PaymentItems.Payments_Id LEFT JOIN SaleInvoices ON Saleinvoices.Id = PaymentItems.ReferenceId WHERE Payments.No = @FILTER_PaymentNo ))) AND (@FILTER_DateFrom IS NULL OR SaleInvoices.Timestamp >= @FILTER_DateFrom) AND (@FILTER_DateTo IS NULL OR SaleInvoices.Timestamp <= @FILTER_DateTo) AND (@Cancelled IS NULL OR SaleInvoices.Cancelled = @Cancelled) AND (@Approved IS NULL OR SaleInvoices.Approved = @Approved) AND (@FILTER_HasDueAmount IS NULL OR ((@FILTER_HasDueAmount = 0 AND SaleInvoices.Due = 0) OR (@FILTER_HasDueAmount = 1 AND SaleInvoices.Due > 0))) AND (@Branches_Id IS NULL OR SaleInvoices.Branches_Id = @Branches_Id) {0}{1} )) ORDER BY SaleInvoices.No DESC ", SaleInvoiceItemIdListClause, ShowOnlyOwnUserDataClause); return(new DBContext().Database.SqlQuery <SaleInvoicesModel>(sql, DBConnection.getSqlParameter(SaleInvoicesModel.COL_Id.Name, Id), DBConnection.getSqlParameter("FILTER_Keyword", FILTER_Keyword), DBConnection.getSqlParameter("FILTER_PaymentNo", FILTER_PaymentNo), DBConnection.getSqlParameter("FILTER_DateFrom", FILTER_DateFrom), DBConnection.getSqlParameter("FILTER_DateTo", Util.getAsEndDate(FILTER_DateTo)), DBConnection.getSqlParameter("FILTER_HasDueAmount", FILTER_HasDueAmount), DBConnection.getSqlParameter(SaleInvoicesModel.COL_Branches_Id.Name, Branches_Id), DBConnection.getSqlParameter(SaleInvoicesModel.COL_Cancelled.Name, Cancelled), DBConnection.getSqlParameter(SaleInvoicesModel.COL_Approved.Name, Approved) ).ToList()); }
public JsonResult Ajax_GetDetails(Guid id) { UserAccountRolesModel access = UserAccountsController.getUserAccess(Session); List <SaleInvoiceItemsModel> models = SaleInvoiceItemsController.get_by_SaleInvoices_Id(id); string content = string.Format(@" <div class='table-responsive'> <table class='table table-striped table-bordered'> <!--<thead> <tr> <th>Line</th> <th>Description</th> <th></th> <th></th> <th></th> </tr> </thead>--> <tbody> "); foreach (SaleInvoiceItemsModel model in models) { int voucher = model.VouchersAmount; string subtractions = ""; if (voucher != 0) { subtractions = Util.append(subtractions, string.Format("Voucher: {0:N0}", -1 * voucher), "<br/>"); } if (model.DiscountAmount != 0) { subtractions = Util.append(subtractions, string.Format("Discount: {0:N0}", -1 * model.DiscountAmount), "<br/>"); } if (!string.IsNullOrEmpty(subtractions)) { subtractions += "<br/>"; } string log = model.RowNo.ToString(); if (access.SaleInvoices_TutorTravelCost_View) { log = string.Format("<a href='javascript: void(0)' onclick=\"Log('{0}')\">{1}</a>", model.Id.ToString(), model.RowNo); } string remaining = ""; if (!model.IsClubSubscription) { remaining = string.Format("<br/><strong>Available Hours:</strong> {0:N2}", model.SessionHours_Remaining); } else { DateTime expirationDate = model.StartingDate.AddMonths(model.ExpirationMonth).AddSeconds(-1); int remainingDays = 0; if (expirationDate > DateTime.Now.Date) { remainingDays = (expirationDate - DateTime.Now.Date).Days; } remaining = string.Format("<br/><strong>Expired:</strong> {0:dd/MM/yy} ({1:N0} days)", expirationDate, remainingDays); } content += string.Format(@" <tr> <td class='align-top' style='width:10px;'>{0}</td> <td class='align-top'>{1}{2}{3}{4}</td> <td class='align-top text-right'> Qty: {5:N0} x {6:N0} {7}{8} </td> <td class='align-top text-right'> {9} <strong>{10:N0}</strong> </td> </tr> ", log, model.Description, model.LessonPackages_Id == null ? "" : remaining, !string.IsNullOrWhiteSpace(model.VouchersName) ? string.Format("<br/>Vouchers: {0}", model.VouchersName) : "", !string.IsNullOrWhiteSpace(model.Notes) ? string.Format("<br/>Notes: {0}", model.Notes) : "", model.Qty, model.Price, model.TravelCost > 0 || model.TutorTravelCost > 0 ? string.Format("<br/>Travel: {0:N0}", model.TravelCost) : "", access.SaleInvoices_TutorTravelCost_View && (model.TravelCost > 0 || model.TutorTravelCost > 0) ? string.Format(" (Tutor: {0:N0})", model.TutorTravelCost) : "", subtractions, model.TotalAmount ); } SaleInvoicesModel SaleInvoice = get(id); content += string.Format(@" </tbody></table></div> <div class='mt-2'> <div class='h3 ml-2 float-right font-weight-bold'>TOTAL: {0:N0}</div> {1} </div> ", SaleInvoice.Amount, !string.IsNullOrWhiteSpace(SaleInvoice.Notes) ? string.Format("<div><strong>Notes: </strong>{0}</div>", SaleInvoice.Notes) : "" ); return(Json(new { content = content }, JsonRequestBehavior.AllowGet)); }