--[[ @Title: Event Calendar @Author: Jane Taubman @Version: 1.0b @LastUpdated: 08 Mar 2019 @Description: Create Html Pages for a 12 Month Calendar ]] function main() if fhGetContextInfo('CI_APP_MODE') ~= 'Project Mode' then fhMessageBox('Sorry this plugin needs to be run on a Project') return end local tblIndi = fhPromptUserForRecordSel('INDI') local tblIndiFactList = {'BIRT','DEAT','BURI','BAPM'} local tblFamFactList = {'MARR'} local tblMonths = {'January','February','March','April','May','June','July','August','September','October','November','December'} local tblFacts = {} if tblIndi[1] then for i,ptrIndi in pairs(tblIndi) do print(fhGetDisplayText(ptrIndi)) -- Indivdual Facts for px in facts(ptrIndi) do if inList(tblIndiFactList,fhGetTag(px)) then table.insert(tblFacts, px:Clone()) end end -- Family As Spouse Facts ptrFamLink = fhNewItemPtr() ptrFam = fhNewItemPtr() ptrFamLink:MoveTo(ptrIndi,'~.FAMS') while ptrFamLink:IsNotNull() do ptrFam = fhGetValueAsLink(ptrFamLink) for px in facts(ptrFam) do if inList(tblFamFactList,fhGetTag(px)) then table.insert(tblFacts, px:Clone()) end end ptrFamLink:MoveNext('SAME_TAG') end end end -- Convert Fact List to exclude those with out a day no and month number or that have complex dates local tblCalendarList = {} local tblDays = {31,29,31,30,31,30,31,31,30,31,30,31} local iId = 0 for i = 1,12 do tblCalendarList[i] = {} for j = 1,tblDays[i] do tblCalendarList[i][j] = {} end end for i,px in pairs(tblFacts) do local ptrDate = fhNewItemPtr() local ptrParent = fhNewItemPtr() local ptrSpou = fhNewItemPtr() ptrDate:MoveTo(px,'~.DATE') dDate = fhGetValueAsDate(ptrDate) if not(dDate:IsNull()) then if dDate:GetType() == 'Simple' then dpDatePt = dDate:GetDatePt1() dDay = dpDatePt:GetDay() dMonth = dpDatePt:GetMonth() dYear = dpDatePt:GetYear() if dDay > 0 and dMonth > 0 then print(dDate:GetDisplayText()) ptrParent:MoveToRecordItem(px) local sName = "" if fhGetTag(ptrParent) == 'FAM' then ptrSpou:MoveTo(ptrParent,'~.~SPOU[1]>') sName = fhGetDisplayText(ptrSpou)..' '..fhCallBuiltInFunction('LifeDates',ptrSpou) ptrSpou:MoveTo(ptrParent,'~.~SPOU[2]>') if ptrSpou:IsNotNull() then sName = sName..' and '..fhGetDisplayText(ptrSpou)..' '..fhCallBuiltInFunction('LifeDates',ptrSpou) end print(sName) else sName = fhGetDisplayText(ptrParent)..' '..fhCallBuiltInFunction('LifeDates',ptrParent) end local sLabel = fhCallBuiltInFunction('FactLabel',px) bFound = false for k,tblfact in pairs(tblCalendarList[dMonth][dDay]) do if px:IsSame(tblfact[4]) then bFound = true end end if not(bFound) then iId = iId + 1 tblCalendarList[dMonth][dDay][iId] = {sName,sLabel,dYear,px:Clone()} end end end end end local tblHtml = {} for i = 1,12 do table.insert(tblHtml,"\n
'..j.."
") tblDates = {} -- Sort Table By Date for k,tblfact in pairs(tblCalendarList[i][j]) do table.insert(tblDates,tblfact) end table.sort(tblDates, compare) for k,tblfact in ipairs(tblDates) do sData = facttemplate:gsub('{year}',tblfact[3]) sData = sData:gsub('{name}',tblfact[1]) sData = sData:gsub('{event}',tblfact[2]) table.insert(tblHtml,sData) end table.insert(tblHtml,'{year} {event}: {name}
]] ------------------------------------------------------ main main()