Ejemplo n.º 1
0
        /// <summary>
        /// Gets Staff Members already existing in the Staff tab with the <c>lineRef</c> related. The <c>employeesView</c> can be of type AppointmentEmployees_View or ServiceOrderEmployees_View.
        /// </summary>
        /// <param name="staffView">Object of type AppointmentEmployees_View or ServiceOrderEmployees_View.</param>
        ///  <param name="lineRef">Line ref of related Service Line.</param>
        /// <returns>List of EmployeeID's existing in Employee Tab.</returns>
        private static List <int?> GetStaffByLineRefTab(object staffView, string lineRef)
        {
            List <int?> employeeIDList = new List <int?>();

            if (staffView is AppointmentCore.AppointmentEmployees_View)
            {
                AppointmentCore.AppointmentEmployees_View appEmployeeView = (AppointmentCore.AppointmentEmployees_View)staffView;

                foreach (FSAppointmentEmployee fsAppointmentEmployeeRow in appEmployeeView.Select().Where(y => ((FSAppointmentEmployee)y).ServiceLineRef == lineRef))
                {
                    employeeIDList.Add(fsAppointmentEmployeeRow.EmployeeID);
                }
            }

            if (staffView is ServiceOrderCore.ServiceOrderEmployees_View)
            {
                ServiceOrderCore.ServiceOrderEmployees_View soEmployeeView = (ServiceOrderCore.ServiceOrderEmployees_View)staffView;

                foreach (FSSOEmployee fsSOEmployeeRow in soEmployeeView.Select().Where(y => ((FSSOEmployee)y).ServiceLineRef == lineRef))
                {
                    employeeIDList.Add(fsSOEmployeeRow.EmployeeID);
                }
            }

            return(employeeIDList);
        }
Ejemplo n.º 2
0
        private static bool IsNecessaryToUpdateTimeCards(
            PXCache appointmentCache,
            AppointmentCore.AppointmentEmployees_View appointmentEmployees,
            FSAppointment fsAppointmentRow)
        {
            DateTime?oldActualDateTimeBegin = (DateTime?)appointmentCache.GetValueOriginal <FSAppointment.actualDateTimeBegin>(fsAppointmentRow);
            DateTime?oldActualDateTimeEnd   = (DateTime?)appointmentCache.GetValueOriginal <FSAppointment.actualDateTimeEnd>(fsAppointmentRow);
            DateTime?oldExecutionDate       = (DateTime?)appointmentCache.GetValueOriginal <FSAppointment.executionDate>(fsAppointmentRow);
            string   oldDocDesc             = (string)appointmentCache.GetValueOriginal <FSAppointment.docDesc>(fsAppointmentRow);
            bool     appointmentModified    = false;

            if (fsAppointmentRow.ActualDateTimeBegin != oldActualDateTimeBegin ||
                fsAppointmentRow.ActualDateTimeEnd != oldActualDateTimeEnd ||
                fsAppointmentRow.ExecutionDate != oldExecutionDate ||
                fsAppointmentRow.DocDesc != oldDocDesc)
            {
                appointmentModified = true;
            }

            if (fsAppointmentRow.Status == ID.Status_Appointment.COMPLETED &&
                (
                    (string)appointmentCache.GetValueOriginal <FSAppointment.status>(fsAppointmentRow) != ID.Status_Appointment.COMPLETED ||
                    appointmentEmployees.Cache.IsInsertedUpdatedDeleted ||
                    appointmentModified))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize the EmployeeGrid filter with the existing employees in the Employee tab.
        /// </summary>
        /// <param name="employeesView">Employee view from Appointment or ServiceOrder screen.</param>
        private static IEnumerable <EmployeeGridFilter> PopulateEmployeeFilter(object employeesView)
        {
            HashSet <EmployeeGridFilter> employees = new HashSet <EmployeeGridFilter>();

            if (employeesView is AppointmentCore.AppointmentEmployees_View)
            {
                AppointmentCore.AppointmentEmployees_View appEmployeeView = (AppointmentCore.AppointmentEmployees_View)employeesView;

                foreach (FSAppointmentEmployee fsAppointmentEmployeeRow in appEmployeeView.Select())
                {
                    EmployeeGridFilter employee = new EmployeeGridFilter();
                    employee.EmployeeID = fsAppointmentEmployeeRow.EmployeeID;
                    employees.Add(employee);
                }
            }

            if (employeesView is ServiceOrderCore.ServiceOrderEmployees_View)
            {
                ServiceOrderCore.ServiceOrderEmployees_View soEmployeeView = (ServiceOrderCore.ServiceOrderEmployees_View)employeesView;

                foreach (FSSOEmployee fsSOEmployeeRow in soEmployeeView.Select())
                {
                    EmployeeGridFilter employee = new EmployeeGridFilter();
                    employee.EmployeeID = fsSOEmployeeRow.EmployeeID;
                    employees.Add(employee);
                }
            }

            return(employees);
        }
Ejemplo n.º 4
0
        public static void InsertUpdateDeleteTimeActivities(
            AppointmentEntry graphAppointmentEntry,
            PXCache appointmentCache,
            FSAppointment fsAppointmentRow,
            FSServiceOrder fsServiceOrderRow,
            AppointmentCore.AppointmentEmployees_View appointmentEmployees,
            List <FSAppointmentEmployee> deleteReleatedTimeActivity,
            List <FSAppointmentEmployee> createReleatedTimeActivity)
        {
            if (!TimeCardHelper.IsTheTimeCardIntegrationEnabled(graphAppointmentEntry) ||
                (fsAppointmentRow.Status != ID.Status_Appointment.COMPLETED &&
                 fsAppointmentRow.Status != ID.Status_Appointment.MANUAL_SCHEDULED))
            {
                return;
            }

            if (PXAccess.FeatureInstalled <FeaturesSet.timeReportingModule>() == false)
            {
                return;
            }

            EmployeeActivitiesEntry graphEmployeeActivitiesEntry = PXGraph.CreateInstance <EmployeeActivitiesEntry>();

            if (IsNecessaryToUpdateTimeCards(appointmentCache, appointmentEmployees, fsAppointmentRow))
            {
                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Select().Where(y => ((FSAppointmentEmployee)y).Type == BAccountType.EmployeeType))
                {
                    EPActivityApprove epActivityApproveRow    = null;
                    EPActivityApprove oldEPActivityApproveRow = null;
                    TMEPEmployee      epEmployeeRow           = null;
                    int?oldEmployeeIDValue;

                    FindTMEmployee(graphAppointmentEntry, fsAppointmentEmployee.EmployeeID, ref epEmployeeRow);
                    FindEPActivityApprove(graphAppointmentEntry, fsAppointmentEmployee, epEmployeeRow, ref epActivityApproveRow);

                    if (fsAppointmentEmployee.TrackTime == true)
                    {
                        oldEmployeeIDValue = (int?)graphAppointmentEntry.AppointmentEmployees.Cache.GetValueOriginal <FSAppointmentEmployee.employeeID>(fsAppointmentEmployee);
                        if (oldEmployeeIDValue != fsAppointmentEmployee.EmployeeID)
                        {
                            TMEPEmployee oldEPEmployeeRow = null;
                            FindTMEmployee(graphAppointmentEntry, oldEmployeeIDValue, ref oldEPEmployeeRow);
                            FindEPActivityApprove(graphAppointmentEntry, fsAppointmentEmployee, oldEPEmployeeRow, ref oldEPActivityApproveRow);
                            DeleteEPActivityApprove(graphEmployeeActivitiesEntry, oldEPActivityApproveRow);
                        }

                        InsertUpdateEPActivityApprove(graphAppointmentEntry, graphEmployeeActivitiesEntry, fsAppointmentEmployee, fsAppointmentRow, fsServiceOrderRow, epActivityApproveRow, epEmployeeRow);
                    }
                    else
                    {
                        if (epActivityApproveRow != null)
                        {
                            DeleteEPActivityApprove(graphEmployeeActivitiesEntry, epActivityApproveRow);
                        }
                    }
                }

                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Cache.Deleted)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }
            else if ((string)appointmentCache.GetValueOriginal <FSAppointment.status>(fsAppointmentRow) == ID.Status_Appointment.COMPLETED &&
                     fsAppointmentRow.Status == ID.Status_Appointment.MANUAL_SCHEDULED)
            {
                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Select().Where(y => ((FSAppointmentEmployee)y).Type == BAccountType.EmployeeType))
                {
                    SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                }

                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Cache.Deleted)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }

            if (deleteReleatedTimeActivity != null)
            {
                //Deleting time activities related with cancelled service lines
                foreach (FSAppointmentEmployee fsAppointmentEmployee in deleteReleatedTimeActivity)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }

            if (createReleatedTimeActivity != null)
            {
                //Creating time activities related with re-opened service lines
                foreach (FSAppointmentEmployee fsAppointmentEmployee in createReleatedTimeActivity)
                {
                    TMEPEmployee epEmployeeRow = null;
                    FindTMEmployee(graphAppointmentEntry, fsAppointmentEmployee.EmployeeID, ref epEmployeeRow);
                    InsertUpdateEPActivityApprove(graphAppointmentEntry, graphEmployeeActivitiesEntry, fsAppointmentEmployee, fsAppointmentRow, fsServiceOrderRow, null, epEmployeeRow);
                }
            }
        }