Ao select complete and mtc.mmbas

From ActivityOwnerWiki
Jump to: navigation, search
'ao_select_complete_and_mtc
'selects tasks marked complete on a dashboard and processes with mark_task_complete
'08Feb2010 -2
'
'#uses "ao_common.mmbas"
Option Explicit
Public Const advancecodetext ="Advance Codes"
Sub Main
		Dim t As Topic
		Dim configdoc As Document
		Const configmapname = "ao\CompletedConfig.mmap"
		Set configdoc 	=getmap(configmapname)
		If configdoc Is Nothing Then
			MsgBox "Configuration Map not created. Contact ActivityOwner. Exiting Program."
			End
		End If
		If f_IsADashboardMap(ActiveDocument) Then
			ActiveDocument.Selection.RemoveAll
			For Each t In ActiveDocument.Range(mmRangeAllTopics)
				If t.Task.Complete=100 And Not t.IsFloatingTopic  And Not t.Icons(True).HasStockIcon(mmStockIconCheck)  Then
					If isrepeatingtask(t,configdoc) Then
						t.Task.Complete=0
						ActiveDocument.Selection.Add(t)
					Else
						ActiveDocument.Selection.Add(t)
					End If
				End If
			Next
			Call MacroRun(GetPath(mmDirectoryMyMaps)&"\ao\mark_task_complete.mmbas")
		Else
			MsgBox "only works on dashboards"
		End If
		configdoc.Close
		Set configdoc=Nothing
End Sub
Function isrepeatingtask(ByRef t As Topic,ByRef configdoc As Document)
	Dim cats As String
	Dim a As Topic
	Dim codetopic As Topic
	cats=LCase(t.Task.Categories)
	isrepeatingtask=False
	If Len(cats)>0 Then 'don't bother with searching for repeat codes if categories are blank
		Debug.Print "checking for repeat"
		Set a = createmainbranch(advancecodetext,configdoc)
		For Each codetopic In a.AllSubTopics
		    If InStr(cats,codetopic.Text)>0 Then
				isrepeatingtask=True
				Debug.Print "isrepeatingtask"
				Exit For
			End If
		Next
	End If
	Set a=Nothing
End Function