Ejemplo n.º 1
0
        public static void Show(Core core, TPage page, Primitive owner, long taskId)
        {
            core.Template.SetTemplate("Calendar", "viewcalendartask");

            try
            {
                Task calendarTask = new Task(core, owner, taskId);

                if (!calendarTask.Access.Can("VIEW"))
                {
                    core.Functions.Generate403();
                    return;
                }

                if (calendarTask.Calendar.Access.Can("CREATE_TASKS"))
                {
                    core.Template.Parse("U_NEW_TASK", core.Hyperlink.BuildAccountSubModuleUri(owner, "calendar", "new-task", true,
                        string.Format("year={0}", core.Tz.Now.Year),
                        string.Format("month={0}", core.Tz.Now.Month),
                        string.Format("day={0}", core.Tz.Now.Day)));
                }

                if (calendarTask.Access.Can("EDIT"))
                {
                    core.Template.Parse("U_EDIT_TASK", core.Hyperlink.BuildAccountSubModuleUri(owner, "calendar", "new-task", "edit", taskId, true));
                }

                /* pages */
                core.Display.ParsePageList(owner, true);

                core.Template.Parse("PAGE_TITLE", calendarTask.Topic);

                core.Template.Parse("TOPIC", calendarTask.Topic);
                core.Template.Parse("DESCRIPTION", calendarTask.Description);
                core.Template.Parse("DUE_DATE", calendarTask.GetDueTime(core.Tz).ToString());

                List<string[]> calendarPath = new List<string[]>();

                calendarPath.Add(new string[] { "calendar", core.Prose.GetString("CALENDAR") });
                calendarPath.Add(new string[] { "*tasks", core.Prose.GetString("TASKS") });
                calendarPath.Add(new string[] { "task/" + calendarTask.TaskId.ToString(), calendarTask.Topic });

                owner.ParseBreadCrumbs(calendarPath);
            }
            catch (InvalidTaskException)
            {
                core.Display.ShowMessage("Invalid submission", "You have made an invalid form submission.");
            }
        }
Ejemplo n.º 2
0
        void AccountCalendarTaskNew_Show(object sender, EventArgs e)
        {
            SetTemplate("account_calendar_task_new");

            bool edit = false;

            if (core.Http.Query["mode"] == "edit")
            {
                edit = true;
            }

            DateTimePicker dueDateTimePicker = new DateTimePicker(core, "due-date");
            dueDateTimePicker.ShowTime = true;
            dueDateTimePicker.ShowSeconds = false;

            int year = core.Functions.RequestInt("year", tz.Now.Year);
            int month = core.Functions.RequestInt("month", tz.Now.Month);
            int day = core.Functions.RequestInt("day", tz.Now.Day);

            byte percentComplete = 0;
            TaskPriority priority = TaskPriority.Normal;

            DateTime dueDate = new DateTime(year, month, day, 17, 0, 0);

            string topic = string.Empty;
            string description = string.Empty;

            Dictionary<string, string> percentages = new Dictionary<string, string>();
            for (int i = 0; i <= 100; i += 25)
            {
                percentages.Add(i.ToString(), i.ToString() + "%");
            }

            Dictionary<string, string> priorities = new Dictionary<string, string>();
            priorities.Add(((byte)TaskPriority.Low).ToString(), "Low");
            priorities.Add(((byte)TaskPriority.Normal).ToString(), "Normal");
            priorities.Add(((byte)TaskPriority.High).ToString(), "High");

            if (edit)
            {
                int id = core.Functions.RequestInt("id", -1);

                if (id < 1)
                {
                    DisplayGenericError();
                }

                try
                {
                    Task calendarTask = new Task(core, Owner, id);

                    template.Parse("EDIT", "TRUE");
                    template.Parse("ID", calendarTask.TaskId.ToString());

                    dueDate = calendarTask.GetDueTime(core.Tz);

                    topic = calendarTask.Topic;
                    description = calendarTask.Description;

                    percentComplete = calendarTask.PercentageComplete;
                    priority = calendarTask.Priority;
                }
                catch
                {
                    core.Display.ShowMessage("Invalid", "If you have stumbled onto this page by mistake, click back in your browser.");
                }
            }

            dueDateTimePicker.Value = dueDate;

            template.Parse("S_YEAR", year.ToString());
            template.Parse("S_MONTH", month.ToString());
            template.Parse("S_DAY", day.ToString());

            template.Parse("S_DUE_DATE", dueDateTimePicker);

            template.Parse("S_TOPIC", topic);
            template.Parse("S_DESCRIPTION", description);

            ParseSelectBox("S_PERCENT_COMPLETE", "percent-complete", percentages, percentComplete.ToString());
            ParseSelectBox("S_PRIORITY", "priority", priorities, ((byte)priority).ToString());

            Save(new EventHandler(AccountCalendarTaskNew_Save));
        }