public ActionResult CreateNewMeeting(NewMeetingInfo model)
        {
            if (!ModelState.IsValid)
                return View("MeetingInfo", model);
            var organization = DbUtil.Db.LoadOrganizationById(Util2.CurrentOrganization.Id);
            if (organization == null)
                return Content("error: no org");
            var mt = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingDate == model.MeetingDate
                    && m.OrganizationId == organization.OrganizationId);

            if (mt != null)
                return Redirect("/Meeting/" + mt.MeetingId);

            mt = new Meeting
            {
                CreatedDate = Util.Now,
                CreatedBy = Util.UserId1,
                OrganizationId = organization.OrganizationId,
                GroupMeetingFlag = model.ByGroup,
                Location = organization.Location,
                MeetingDate = model.MeetingDate,
                AttendCreditId = model.AttendCredit.Value.ToInt()
            };
            DbUtil.Db.Meetings.InsertOnSubmit(mt);
            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity($"Creating new meeting for {organization.OrganizationName}");
            return Redirect("/Meeting/" + mt.MeetingId);
        }
Example #2
0
 public ActionResult ForNewRallyRollsheets(int schedule)
 {
     var m = new NewMeetingInfo()
     {
         MeetingDate =  OrgSearchModel.DefaultMeetingDate(schedule),
         Schedule = null,
         AttendCredit = null,
     };
     return View("MeetingInfo", m);
 }
 public ActionResult ForNewRallyRollsheet(int orgid)
 {
     var oi = new SettingsAttendanceModel { Id = orgid };
     var m = new NewMeetingInfo()
     {
         MeetingDate =  oi.NextMeetingDate,
         Schedule = new CodeInfo(0, oi.SchedulesNext()),
         AttendCredit = new CodeInfo(0, oi.AttendCreditList()),
     };
     ViewBag.Action = "/Reports/RallyRollsheetForOrg/" + orgid;
     ViewBag.Method = "POST";
     return View("MeetingInfo", m);
 }
Example #4
0
 public ActionResult ForNewMeeting(int orgid)
 {
     var oi = new SettingsAttendanceModel() { Id = orgid };
     var m = new NewMeetingInfo()
     {
         MeetingDate = oi.PrevMeetingDate,
         Schedule = new CodeInfo(0, oi.SchedulesPrev()),
         AttendCredit = new CodeInfo(0, oi.AttendCreditList()),
     };
     ViewBag.Action = "/CreateNewMeeting/";
     ViewBag.Method = "POST";
     return View("MeetingInfo", m);
 }
Example #5
0
 public ActionResult Rollsheets(NewMeetingInfo mi, OrgSearchModel m)
 {
     return new RollsheetResult
     {
         OrgSearchModel = m,
         NewMeetingInfo = mi
     };
 }
Example #6
0
 public ActionResult RollsheetForOrg(int? orgid, NewMeetingInfo mi)
 {
     return new RollsheetResult
     {
         orgid = orgid,
         NewMeetingInfo = mi,
     };
 }
Example #7
0
 public ActionResult Rollsheet(string dt, int? bygroup, string sgprefix,
     bool? altnames, string highlight, OrgSearchModel m)
 {
     DateTime? dt2 = dt.ToDate();
     if (!dt2.HasValue)
         return Message("no date");
     var mi = new NewMeetingInfo()
     {
         ByGroup = bygroup > 0,
         GroupFilterPrefix = sgprefix,
         UseAltNames = altnames == true,
         HighlightGroup = highlight,
         MeetingDate = dt2.Value
     };
     return new RollsheetResult
     {
         OrgSearchModel = m,
         NewMeetingInfo = mi
     };
 }
Example #8
0
        public override void ExecuteResult(ControllerContext context)
        {
            var Response = context.HttpContext.Response;

            Meeting meeting = null;
            if (meetingid.HasValue)
            {
                meeting = DbUtil.Db.Meetings.Single(mt => mt.MeetingId == meetingid);
                Debug.Assert(meeting.MeetingDate != null, "meeting.MeetingDate != null");
                NewMeetingInfo = new NewMeetingInfo {MeetingDate = meeting.MeetingDate.Value};
                orgid = meeting.OrganizationId;
            }

            var list1 = NewMeetingInfo.ByGroup ? ReportList2().ToList() : ReportList().ToList();

            if (!list1.Any())
            {
                Response.Write("no data found");
                return;
            }
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "filename=foo.pdf");

            doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64);
            var w = PdfWriter.GetInstance(doc, Response.OutputStream);
            w.PageEvent = pageEvents;
            doc.Open();
            dc = w.DirectContent;

            box = new PdfPCell();
            box.Border = Rectangle.NO_BORDER;
            box.CellEvent = new CellEvent();
            PdfPTable table = null;

            OrgInfo lasto = null;
            foreach (var o in list1)
            {
                lasto = o;
                table = new PdfPTable(1);
                table.DefaultCell.Border = Rectangle.NO_BORDER;
                table.DefaultCell.Padding = 0;
                table.WidthPercentage = 100;
                var co = DbUtil.Db.CurrentOrg;

                if (meeting != null)
                {
                    var Groups = o.Groups;
                    if (!Groups.HasValue())
                    {
                        var q = from at in meeting.Attends
                                where at.AttendanceFlag || AttendCommitmentCode.committed.Contains(at.Commitment ?? 0)
                                orderby at.Person.LastName, at.Person.FamilyId, at.Person.Name2
                                select new
                                {
                                    at.MemberType.Code,
                                    Name2 = NewMeetingInfo.UseAltNames && at.Person.AltName.HasValue() ? at.Person.AltName : at.Person.Name2,
                                    at.PeopleId,
                                    at.Person.DOB
                                };
                        if (q.Any())
                            StartPageSet(o);
                        foreach (var a in q)
                            table.AddCell(AddRow(a.Code, a.Name2, a.PeopleId, a.DOB, "", font));
                    }
                    else
                    {
                        var q = from at in DbUtil.Db.Attends
                                where at.MeetingId == meeting.MeetingId
                                join om in DbUtil.Db.OrgMember(orgid, GroupSelectCode.Member, null, null, Groups, false) on at.PeopleId equals om.PeopleId into mm
                                from om in mm.DefaultIfEmpty()
                                where at.AttendanceFlag || AttendCommitmentCode.committed.Contains(at.Commitment ?? 0)
                                orderby at.Person.LastName, at.Person.FamilyId, at.Person.Name2
                                select new
                                {
                                    at.MemberType.Code,
                                    Name2 = NewMeetingInfo.UseAltNames && at.Person.AltName.HasValue() ? at.Person.AltName : at.Person.Name2,
                                    at.PeopleId,
                                    at.Person.DOB
                                };
                        if (q.Any())
                            StartPageSet(o);
                        foreach (var a in q)
                            table.AddCell(AddRow(a.Code, a.Name2, a.PeopleId, a.DOB, "", font));
                    }
                }
                else if (OrgSearchModel != null)
                {
                    var q = from om in DbUtil.Db.OrganizationMembers
                            where om.OrganizationId == o.OrgId
                            join m in DbUtil.Db.OrgPeople(o.OrgId, o.Groups) on om.PeopleId equals m.PeopleId
                            where om.EnrollmentDate <= Util.Now
                            orderby om.Person.LastName, om.Person.FamilyId, om.Person.Name2
                            let p = om.Person
                            let ch = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0
                            select new
                            {
                                p.PeopleId,
                                Name2 = ch ? p.AltName : p.Name2,
                                BirthDate = Util.FormatBirthday(
                                    p.BirthYear,
                                    p.BirthMonth,
                                    p.BirthDay),
                                MemberTypeCode = om.MemberType.Code,
                                ch,
                                highlight =
                                    om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup)
                                        ? NewMeetingInfo.HighlightGroup
                                        : ""
                            };
                    if (q.Any())
                        StartPageSet(o);
                    foreach (var m in q)
                        table.AddCell(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china ?? font : font));
                }
                else if (co.GroupSelect == GroupSelectCode.Member)
                {
                    var Groups = NewMeetingInfo.ByGroup ? o.Groups : co.SgFilter;
                    var q = from om in DbUtil.Db.OrganizationMembers
                            where om.OrganizationId == orgid
                            join m in DbUtil.Db.OrgPeople(orgid, co.GroupSelect,
                                co.First(), co.Last(), Groups, co.ShowHidden,
                                co.FilterIndividuals, co.FilterTag) on om.PeopleId equals m.PeopleId
                            where om.EnrollmentDate <= Util.Now
                            orderby om.Person.LastName, om.Person.FamilyId, om.Person.Name2
                            let p = om.Person
                            let ch = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0
                            select new
                            {
                                p.PeopleId,
                                Name2 = ch ? p.AltName : p.Name2,
                                BirthDate = Util.FormatBirthday(
                                    p.BirthYear,
                                    p.BirthMonth,
                                    p.BirthDay),
                                MemberTypeCode = om.MemberType.Code,
                                ch,
                                highlight =
                                    om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup)
                                        ? NewMeetingInfo.HighlightGroup
                                        : ""
                            };
                    if (q.Any())
                        StartPageSet(o);
                    foreach (var m in q)
                        table.AddCell(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china ?? font : font));
                }
                else
                {
                    var q = from m in DbUtil.Db.OrgPeople(orgid, co.GroupSelect,
                        co.First(), co.Last(), co.SgFilter, co.ShowHidden,
                        co.FilterIndividuals, co.FilterTag)
                            orderby m.Name2
                            let p = DbUtil.Db.People.Single(pp => pp.PeopleId == m.PeopleId)
                            let om = p.OrganizationMembers.SingleOrDefault(mm => mm.OrganizationId == orgid)
                            let ch = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0
                            select new
                            {
                                p.PeopleId,
                                Name2 = ch ? p.AltName : p.Name2,
                                BirthDate = Util.FormatBirthday(
                                    p.BirthYear,
                                    p.BirthMonth,
                                    p.BirthDay),
                                MemberTypeCode = om == null ? "Guest" : om.MemberType.Code,
                                ch,
                                highlight = om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == NewMeetingInfo.HighlightGroup) ? NewMeetingInfo.HighlightGroup : ""
                            };
                    if (q.Any())
                        StartPageSet(o);
                    foreach (var m in q)
                        table.AddCell(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china ?? font : font));
                }
                if ((OrgSearchModel != null && NewMeetingInfo.ByGroup == false)
                    || (co != null
                        && co.GroupSelect == GroupSelectCode.Member
                        && meeting == null
                        && !co.SgFilter.HasValue()
                        && !co.NameFilter.HasValue()
                        && !co.FilterIndividuals
                        && !co.FilterTag
                        && NewMeetingInfo.ByGroup == false))
                {
                    foreach (var m in RollsheetModel.FetchVisitors(o.OrgId, NewMeetingInfo.MeetingDate, true, NewMeetingInfo.UseAltNames))
                    {
                        if (table.Rows.Count == 0)
                            StartPageSet(o);
                        table.AddCell(AddRow(m.VisitorType, m.Name2, m.PeopleId, m.BirthDate, "", boldfont));
                    }
                }
                if (!pageSetStarted)
                    continue;

                var col = 0;
                var gutter = 20f;
                var colwidth = (doc.Right - doc.Left - gutter)/2;
                var ct = new ColumnText(w.DirectContent);
                ct.AddElement(table);

                var status = 0;

                while (ColumnText.HasMoreText(status))
                {
                    if (col == 0)
                        ct.SetSimpleColumn(doc.Left, doc.Bottom, doc.Left + colwidth, doc.Top);
                    else
                        ct.SetSimpleColumn(doc.Right - colwidth, doc.Bottom, doc.Right, doc.Top);
                    status = ct.Go();
                    ++col;
                    if (col > 1)
                    {
                        col = 0;
                        doc.NewPage();
                    }
                }
            }
            if (!hasRows)
            {
                if (!pageSetStarted)
                    StartPageSet(lasto);
                doc.Add(new Paragraph("no members as of this meeting date and time to show on rollsheet"));
            }
            doc.Close();
        }