示例#1
0
 public void SaveSchedulerPreferences([FromBody] SchedulerPreferencesVm vm)
 {
     this.schedulerPreferencesManager.SaveSchedulerPreferences(vm.PracticeLocationId, vm.ToDictionary());
     //// Insert the Default View preference
     this.schedulerPreferencesManager.SaveSchedulerDefaultViewPreference(vm.PracticeLocationId, vm.DefaultView.ToString(CultureInfo.InvariantCulture));
     this.schedulerPreferencesIt2Manager.SaveAdditionalSchedulerPreferences(
         new Office
     {
         OfficeNumber = vm.PracticeLocationId,
         AppointmentAutoConfirmDays = vm.AutoConfirmAppointmentDays,
         SupportsPreAppointment     = vm.SupportsPreAppointments
     });
 }
示例#2
0
        public SchedulerPreferencesVm GetSchedulerPreferencesVm(string officeNumber)
        {
            var preferences =
                SchedulerPreferencesVm.FromDictionary(
                    this.schedulerPreferencesManager.GetSchedulerPreferences(officeNumber));
            var additionalPreferences =
                this.schedulerPreferencesIt2Manager.GetAdditionalSchedulerPreferences(officeNumber);

            preferences.AutoConfirmAppointmentDays = additionalPreferences.AppointmentAutoConfirmDays;
            preferences.SupportsPreAppointments    = additionalPreferences.SupportsPreAppointment.GetValueOrDefault();
            preferences.PracticeLocationId         = officeNumber;
            return(preferences);
        }
        // GET: /Appointments/

        /// <summary>
        /// The calendar.
        /// </summary>
        /// <param name="id">
        /// The patient id.
        /// </param>
        /// <param name="firstName">
        /// The first name.
        /// </param>
        /// <param name="lastName">
        /// The last name.
        /// </param>
        /// <param name="view">
        /// The view.
        /// </param>
        /// <param name="officeNum">
        /// The officeNum.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult Calendar(int?id, string firstName, string lastName, string view, string officeNum)
        {
            if (id != null)
            {
                try
                {
                    AccessControl.VerifyUserAccessToPatient(id.GetValueOrDefault());
                }
                catch (HttpResponseException)
                {
                    return(new HttpForbiddenResult());
                }
            }

            var authorizationTicketHelper = new AuthorizationTicketHelper();
            var user         = authorizationTicketHelper.GetUserInfo();
            var employeeId   = this.appointmentManager.GetEmployeeIdByUserId(user.Id).GetValueOrDefault();
            var startDate    = DateTime.Now.Date.AddDays(-Convert.ToDouble(DateTime.Now.DayOfWeek));
            var endDate      = DateTime.Now.Date.AddDays(6 - Convert.ToDouble(DateTime.Now.DayOfWeek));
            var userOfficeId = Convert.ToInt32(user.OfficeId);

            if (!string.IsNullOrEmpty(officeNum))
            {
                if (user.OfficeNum != officeNum)
                {
                    var companyId = OfficeHelper.GetCompanyId(officeNum);
                    if (companyId != user.CompanyId)
                    {
                        return(new HttpForbiddenResult());
                    }
                }

                userOfficeId = this.officeHelper.GetOfficeById(officeNum).OfficeId;
            }

            var scheduler = this.appointmentManager.GetSchedulerConfiguration(
                userOfficeId, (int)employeeId, startDate, endDate, view, user.CompanyId);
            var sched = new DHXScheduler
            {
                DataAction = this.Url.Action("Data"),
                SaveAction = this.Url.Action("Save"),
                Skin       = DHXScheduler.Skins.Terrace,
                Config     =
                {
                    multi_day             = true,
                    start_on_monday       = false,
                    use_select_menu_space = false,
                    fix_tab_position      = false,
                    show_loading          = false,
                    mark_now   = true,
                    touch      = true,
                    touch_drag =   700,
                    touch_tip  = false,
                    time_step  =     5,
                    hour_date  = "%h:%i %A"
                },
                InitialDate = DateTime.Now                 //// beginDate //// DateTime.Now
            };

            sched.Extensions.Add(SchedulerExtensions.Extension.PDF);

            // load data initially
            sched.LoadData = true;

            sched.UpdateFieldsAfterSave();

            // save client-side changes
            sched.EnableDataprocessor = true;
            sched.EnableDynamicLoading(SchedulerDataLoader.DynamicalLoadingMode.Week);

            // add resource units to the scheduler and replace the normal daily view.
            sched.Views.Items.RemoveAt(2); ////day (will replace this one.)
            sched.Views.Items.RemoveAt(0); ////month

            ////initializes the view
            var agenda = new AgendaView {
                Label = "List", StartDate = startDate, EndDate = endDate
            };

            sched.Views.Items.Insert(0, agenda);

            var units = new UnitsView("resource", "Id")
            {
                Label = "Day", Property = "resourceId", SkipIncorrect = true
            };

            units.AddOptions(
                scheduler.Resources.Select(
                    resource => new CalendarUnit {
                key = resource.Id.ToString(), label = resource.DisplayName
            })
                .ToList());
            units.Size = 50;
            sched.Views.Items.Insert(1, units);
            for (var i = 0; i < sched.Views.Count; i++)
            {
                sched.Views[i].TabPosition = 15 + (i * 60);
                sched.Views[i].TabClass    = "week_tab";
            }

            var preferences = SchedulerPreferencesVm.FromDictionary(new SchedulerPreferencesManager().GetSchedulerPreferences(user.OfficeNum));

            if (view == "resource" || preferences.DefaultView == (int)WorkspaceType.DailyView)
            {
                sched.InitialView = sched.Views[1].Name;
                sched.InitialDate = endDate;
            }

            ////sched.DataAction = "Data?userId=" + userId + "&officeId=" + officeId;
            sched.DataAction = "Data?userId=" + user.Id + "&officeId=" + userOfficeId;
            sched.Calendars.AttachMiniCalendar();

            ////var cal = sched.Calendars.AttachMiniCalendar();
            ////cal.Navigation = true;
            ////cal.Position = "dhx_cal_tab";
            scheduler.Scheduler    = sched;
            this.ViewBag.id        = id;
            this.ViewBag.firstName = firstName;
            this.ViewBag.lastName  = lastName;
            var security             = new Security();
            var isExceptionPermitted = security.IsSingleLocationUserInRole(user.Id, "Schedule Exceptions");

            this.ViewBag.isExceptionPermitted = isExceptionPermitted;
            return(this.View(scheduler));
        }