private DateTime?GetLasttUsingWeek() { DateTime dateFromActivity = new DateTime(1900, 1, 1); DateTime startDate = new DateTime(1900, 1, 1); EPTimeCard lastTimeCard = (EPTimeCard)PXSelectOrderBy <EPTimeCard, OrderBy <Desc <EPTimeCard.weekId> > > .SelectSingleBound(this, null); CRPMTimeActivity lastActivity = PXSelect <CRPMTimeActivity, Where <CRPMTimeActivity.weekID, IsNotNull, And <CRPMTimeActivity.trackTime, Equal <True>, And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.emailRouting>, And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.task>, And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.events> > > > > >, OrderBy < Desc <CRPMTimeActivity.weekID> > > .SelectSingleBound(this, null); if (lastTimeCard != null) { startDate = PXWeekSelectorAttribute.GetWeekStartDate(lastTimeCard.WeekID.Value); } if (lastActivity != null) { dateFromActivity = lastActivity.StartDate.Value; } startDate = startDate >= dateFromActivity ? startDate : dateFromActivity; if (startDate == new DateTime(1900, 1, 1)) { return(null); } else { return(startDate); } }
private DateTime?GetFirstActivityDate() { MasterFinYear minYear = PXSelect <MasterFinYear, Where <True, Equal <True> >, OrderBy <Desc <MasterFinYear.year> > > .Select(this); int minWeek; if (minYear != null && int.TryParse(minYear.Year + "01", out minWeek)) { CRPMTimeActivity firstActivity = PXSelect <CRPMTimeActivity, Where <CRPMTimeActivity.weekID, GreaterEqual <Required <CRPMTimeActivity.weekID> >, And <CRPMTimeActivity.trackTime, Equal <True>, And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.emailRouting>, And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.task>, And <CRPMTimeActivity.classID, NotEqual <CRActivityClass.events> > > > > >, OrderBy < Asc <CRPMTimeActivity.weekID> > > .Select(this, minWeek); if (firstActivity != null) { return(firstActivity.StartDate.Value); } } return(null); }
public static string GetCalendarID(PXGraph graph, CRPMTimeActivity act) { var projectCalendar = act.ProjectID. With(_ => (CT.Contract)PXSelect <CT.Contract, Where <CT.Contract.contractID, Equal <Required <CT.Contract.contractID> > > > . Select(graph, _.Value)). With(_ => _.CalendarID); if (projectCalendar != null) { return(projectCalendar); } var projectTaskCalendar = act.ProjectTaskID. With(_ => (PXResult <Location, PM.PMTask>)PXSelectJoin <Location, InnerJoin <PM.PMTask, On <PM.PMTask.customerID, Equal <Location.bAccountID>, And <PM.PMTask.locationID, Equal <Location.locationID> > > >, Where <PM.PMTask.taskID, Equal <Required <PM.PMTask.taskID> > > > . Select(graph, _.Value)). With(_ => ((Location)_).CCalendarID); if (projectTaskCalendar != null) { return(projectTaskCalendar); } var caseLocationCalendar = act.RefNoteID. With(_ => (PXResult <Location, CRCase>)PXSelectJoin <Location, InnerJoin <CRCase, On <CRCase.customerID, Equal <Location.bAccountID>, And <CRCase.locationID, Equal <Location.locationID> > > >, Where <CRCase.noteID, Equal <Required <CRCase.noteID> > > > . Select(graph, _.Value)). With(_ => ((Location)_).CCalendarID); if (caseLocationCalendar != null) { return(caseLocationCalendar); } var employeeCalendar = act.Owner. With(_ => (EPEmployee)PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > . Select(graph, _.Value)). With(_ => _.CalendarID); if (employeeCalendar != null) { return(employeeCalendar); } return(null); }
protected void grid_RowDataBound(object sender, PX.Web.UI.PXGridRowEventArgs e) { PXResult record = e.Row.DataItem as PXResult; if (record == null) { return; } EPView viewInfo = (EPView)record[typeof(EPView)]; bool isBold = viewInfo != null && (viewInfo.Status == null || viewInfo.Status == EPViewStatusAttribute.NOTVIEWED); CRPMTimeActivity item = (CRPMTimeActivity)record[typeof(CRPMTimeActivity)]; if (isBold) { e.Row.Style.CssClass = "BaseBold"; } if (item.CategoryID != null && coloredCategories.Contains(item.CategoryID ?? 0)) { if (item.IsOverdue == true) { e.Row.Style.CssClass = (isBold ? "CssBoldOver" : "CssOver") + item.CategoryID; } else { e.Row.Style.CssClass = (isBold ? "CssBold" : "Css") + item.CategoryID; } } else { if (item.IsOverdue == true) { e.Row.Style.CssClass = (isBold ? "CssOverdueBold" : "CssOverdue"); } } }
private static CRPMTimeActivity CreateActivity(ProcessTranscript graph, ContactMaint contMaint, TransScriptDetail transScriptDetail, CRPMTimeActivity activityData, string meetingText = null) { int minsConsumed = 0; if (string.IsNullOrEmpty(meetingText)) { activityData.Body = GetTranscriptInfo(transScriptDetail, graph, out minsConsumed); } else { activityData.Body = meetingText; } activityData.TrackTime = true; activityData.IsBillable = false; activityData.Summary = transScriptDetail.Title; activityData.Subject = transScriptDetail.Title; activityData.TimeSpent = minsConsumed == 0 ? 1 : minsConsumed; activityData = contMaint.Activities.Update(activityData); activityData.ProjectID = 0; activityData = contMaint.Activities.Update(activityData); contMaint.Persist(); return(activityData); }
public static DateTime?GetNextActivityStartDate <Activity>(PXGraph graph, PXResultset <Activity> res, CRPMTimeActivity row, int?fromWeekId, int?tillWeekId, PXCache tempDataCache, Type tempDataField) where Activity : CRPMTimeActivity, new() { DateTime?date; if (fromWeekId != null || tillWeekId != null) { date = PXWeekSelector2Attribute.GetWeekStartDate(graph, (int)(fromWeekId ?? tillWeekId)); } else { date = graph.Accessinfo.BusinessDate.GetValueOrDefault(DateTime.Now).Date; } EPEmployee employee = PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > .Select(graph, row.Owner); EPEmployeeClass employeeClass = PXSelect <EPEmployeeClass, Where <EPEmployeeClass.vendorClassID, Equal <Required <EPEmployee.vendorClassID> > > > .Select(graph, employee != null?employee.VendorClassID : null); var calendarId = CRActivityMaint.GetCalendarID(graph, row); if (employeeClass != null && EPEmployeeClass.defaultDateInActivity.LastDay == employeeClass.DefaultDateInActivity) { DateTime?val = tempDataCache.GetValue(tempDataCache.Current, tempDataField.Name) as DateTime?; if (val != null) { int week = PXWeekSelector2Attribute.GetWeekID(graph, (DateTime)val); if ((fromWeekId == null || week >= fromWeekId) && (tillWeekId == null || tillWeekId >= week)) { date = val; } } } else { DateTime weekDate = (DateTime)date; DateTime?newDate = null; date = res != null && res.Count > 0 ? res.Max(_ => ((Activity)_).StartDate) : null ?? date; for (int curentWeek = PXWeekSelector2Attribute.GetWeekID(graph, weekDate); tillWeekId == null || curentWeek <= tillWeekId; curentWeek = PXWeekSelector2Attribute.GetWeekID(graph, weekDate)) { PXWeekSelector2Attribute.WeekInfo week1 = PXWeekSelector2Attribute.GetWeekInfo(graph, PXWeekSelector2Attribute.GetWeekID(graph, weekDate)); foreach (KeyValuePair <DayOfWeek, PXWeekSelector2Attribute.DayInfo> pair in week1.Days.OrderBy(_ => _.Value.Date)) { if (pair.Value.Date >= date && (CalendarHelper.IsWorkDay(graph, calendarId, (DateTime)pair.Value.Date) || string.IsNullOrEmpty(calendarId) && pair.Key != DayOfWeek.Saturday && pair.Key != DayOfWeek.Sunday)) { newDate = (DateTime)pair.Value.Date; break; } weekDate = weekDate.AddDays(1D); } if (newDate != null) { date = ((DateTime)newDate).Date; break; } } } if (!string.IsNullOrEmpty(calendarId) && date != null) { DateTime startDate; DateTime endDate; CalendarHelper.CalculateStartEndTime(graph, calendarId, (DateTime)date, out startDate, out endDate); date = startDate; } return(date); }
public static TimeSpan CalculateOvertime(PXGraph graph, CRPMTimeActivity act, DateTime start, DateTime end) { var calendarId = GetCalendarID(graph, act); return(calendarId == null ? new TimeSpan() : CalendarHelper.CalculateOvertime(graph, start, end, calendarId)); }