Today I am reviewing some changes and improvements from lesson three. The next little video shows the navigation changes.
As you can see the menu for the supercontrol now passes the report name by xbasic code. There is only one control on the form and the following code sends the name to the supercontrol then refreshes the page
‘Date Created: 30-Apr-2025 08:20:26 AM
‘Last Updated: 30-Apr-2025 10:53:53 AM
‘Created By : NLaws
‘Updated By : NLaws
TCCalendar:reportpreview1.settings.report = “Contact Activity Listing”
sys_send_keys(“{F5}”)
IF the report has filter in the report definition then just calling the name will display correctly. If the report does not have a built in filter you can pass the filter to the supercontrol here.

I also have added two navigational buttons above the left side menu. also of note the calendar buttons now show a red day number if appointments are scheduled for that day.

Here is the code for the buttons.
if xView >= 2 then
dim selBtn as C
selBtn = Right(this.object.name,2)
if val(right(this.object.name,2)) <= 7 .and. val(eval("Button"+selBtn+".text")) > 7 then
amonth = str(month(ActDate)-1)
aDay = Str(val(eval("Button"+selBtn+".text")))
ayear = Str(year(Date_LastDayOfPreviousMonth(ActDate)))
else if val(right(this.object.name,2)) >= 28 .and. val(eval("Button"+selBtn+".text")) <= 17 then
amonth = str(month(month_end(ActDate)+1))
aDay = Str(val(eval("Button"+selBtn+".text")))
ayear = Str(year(month_end(ActDate)+1))
ActDate = amonth+"/"+aDay+"/"+ayear
else
amonth = str(month(ActDate))
aDay = Str(val(eval("Button"+selBtn+".text")))
ayear = Str(year(ActDate))
ActDate = amonth+"/"+aDay+"/"+ayear
end if
ActDate = amonth+"/"+aDay+"/"+ayear
topparent:ActDate.refresh()
topparent:text17.text = Alltrim(Date_Format(ActDate,"MON"))+" "+Alltrim(aday)+" "+Alltrim(str(xyear))
script_play("ShowFocusDate")
else
ui_msg_box(“Sorry”, “You must Log In to use the TC Job Costing Features”)
end if
The code for ShowFocusDate:
‘Date Created: 27-Apr-2025 08:20:55 AM
‘Last Updated: 28-Apr-2025 11:07:38 AM
‘Created By : NLaws
‘Updated By : NLaws
dim count as N
dim fucount as N
dim count2 as N
dim fucount2 as N
count = tablecount(“activity”,”Cont_Date = Var->ActDate .and. Complete <> .t.”)
fucount = tablecount(“activity”,”FU_Date = Var->ActDate .and. Complete <> .t.”)
if count+fucount = 0 then
dt = “There are no uncompleted Reminders scheduled on this day.”
else
count2 = tablecount(“activity”,”Cont_Date = Var->ActDate .and. Complete <> .t.”)
fucount2 = tablecount(“activity”,”FU_Date = Var->ActDate .and. Complete <> .t.”)
dt = “You have ‘”+Alltrim(STR(var->count2))+”‘ Notes for this date.”
text2 = “You have ‘”+Alltrim(STR(var->fucount2))+”‘ Follou up Reminders for this date.”
end if
DIM SHARED xgoto as C
DIM SHARED varC_result as C
xgoto = “”
dim text as c
dim text2 as C
dim formatted_textHdr as C
formatted_textHdr = “{font=New Times Roman,11}”+”{C=Dark Blue}” +”Note Organizer for Focus Date: “+ActDate
dim formatted_text as c
formatted_text = “{font=New Times Roman,10}”+”{C=Dark Teal}” + text
dim formatted_text2 as C
formatted_text2 = “{font=New Times Roman,10}”+”{C=Dark Teal}” + text2
dim formatted_text3 as C
formatted_text3 = “{font=New Times Roman,10}”+”{C=Dark Teal}” + dt
ok_button_label = “&OK”
cancel_button_label = “&Cancel”
Delete XdialogStyle
dim XDialogStyle as p
XDialogStyle.AccentColor = “White”
XDialogStyle.Color = “Gray-50”
varC_result = ui_dlg_box(“Days Task”,<<%dlg%
{Windowstyle=Gradient Radial Bottom Right}
{image=$$generic.time}
{region}
{sp=6}{text=%O={@@}%70,2:formatted_textHdr};
{endregion};
{line=1,0};
{lf};
{ymargin=0,0}
{xmargin=1,1}
{ysize=0}
{blueframe=1,1: Messages! }
{region}
{sp=3}{text=%O={@@}%60,2:formatted_text3};
{sp=3}{text=%O={@@}%60,2:formatted_text2};
{endregion};
{line=1,0};
{ymargin=0,0}
{xmargin=1,1}
{ysize=0}
{blueframe=1,1: Note Organizer Actions! }
{region}{sp=3}(xchoice:Write a Quick Note for this Date);
{sp=5}{line=1,0};
{sp=3}(xchoice:View Notes for this date);
{sp=5}{line=1,0};
{sp=3}(xchoice:View Follow Up Reminders for this date);
{sp=5}{line=1,0};
{sp=3}(xchoice:View All for this date);
{sp=5}{line=1,0};
{sp=3}(xchoice:Mark All as Complete for this date);
{sp=5}{line=1,0};
{sp=3}(xchoice:Delete Notes for this date);
{sp=5}{line=1,0};
{sp=3}(xchoice:Print Notes for this date);
{endregion};
{lf};
{region}
{sp}<30=ok_button_label!OK> <30=cancel_button_label!CANCEL> {endregion}; %dlg%,<<%code% if a_dlg_button = “Cancel” then xchoice = “” end if %code%) if xchoice = “” then End else if xchoice = “Write a Quick Note for this Date” then if Var->ActDate < Date() then DIM msgprmpt as C DIM SHARED varC_result as C msgprmpt = “Since we cannot time travel into the past, it makes no sense to write a note or reminder in the past.” ok_button_label = “&OK” cancel_button_label = “&Cancel” Delete XdialogStyle dim XDialogStyle as p XDialogStyle.AccentColor = “White” XDialogStyle.Color = “#191+191+191” varC_result = ui_dlg_box(“Message Alert”,<<%dlg% {Windowstyle=Gradient Radial Top Left} {region} {lf}; {image=$sys_warning}{sp} |{text=40,4:msgprmpt}; {endregion}; {line=1,0}; {region} <20=ok_button_label!OK> <20=cancel_button_label!CANCEL>
{endregion};
%dlg%)
End
else
DIM Shared varP_QuickNoteOrganizer as P
DIM layout_name as c
layout_name = “QuickNoteOrganizer”
varP_QuickNoteOrganizer = :Form.load(layout_name,”popup”,””,”center”,”Top”)
varP_QuickNoteOrganizer.new_record()
varP_QuickNoteOrganizer:Date_Enter.value = Date()
varP_QuickNoteOrganizer:Contact_ID.value = “99999999999999”
varP_QuickNoteOrganizer:ActivityDate.value = ActDate
varP_QuickNoteOrganizer:Cont_Type.value = “Quick Note”
varP_QuickNoteOrganizer.show()
varP_QuickNoteOrganizer:ActivityDate.activate()
varP_QuickNoteOrganizer.commit()
form.close()
end if
else if xchoice = “View Notes for this date” then
ui_freeze(.t.)
DIM layout_ptr as P
layout_ptr = :Form.load(“QuickNoteOrganizer”,”popup”,””,”center”,”top”)
layout_ptr:tables:Activity.filter_expression=”Cont_Date = Var->ActDate”
layout_ptr:tables:Activity.order_expression=””
layout_ptr:tables:Activity.query()
layout_ptr.show()
layout_ptr.activate()
ui_freeze(.f.)
form.close()
xbasic_wait_for_idle()
else if xchoice = “View Follow Up Reminders for this date” then
ui_freeze(.t.)
DIM layout_ptr as P
layout_ptr = :Form.load(“QuickNoteOrganizer”,”popup”,””,”center”,”top”)
layout_ptr:tables:Activity.filter_expression=”FU_Date = Var->ActDate “
layout_ptr:tables:Activity.order_expression=””
layout_ptr:tables:Activity.query()
layout_ptr.show()
layout_ptr.activate()
ui_freeze(.f.)
form.close()
xbasic_wait_for_idle()
else if xchoice = “View All for this date” then
ui_freeze(.t.)
DIM layout_ptr as P
layout_ptr = :Form.load(“QuickNoteOrganizer”,”popup”,””,”center”,”top”)
layout_ptr:tables:Activity.filter_expression=”Cont_Date = Var->ActDate .or. FU_Date = Var->ActDate”
layout_ptr:tables:Activity.order_expression=””
layout_ptr:tables:Activity.query()
layout_ptr.show()
layout_ptr.activate()
ui_freeze(.f.)
form.close()
xbasic_wait_for_idle()
else if xchoice = “Mark All as Complete for this date” then
ui_freeze(.t.)
a_tbl = table.open(“activity”)
update.fields = 1
update.field1 = “COMPLETE”
update.expr1 = “if(Cont_Date = Var->ActDate .or. FU_Date = Var->ActDate,.t.,COMPLETE)”
a_tbl.update()
a_tbl.close()
xbasic_wait_for_idle()
else if xchoice = “Delete Notes for this date” then
dim list as C
list = “”
t = table.open(“activity”)
t.fetch_first()
while .not. t.fetch_eof()
if t.cont_date = Var->ActDate .or. t.fu_date = Var->ActDate then
list = list+t.act_id+crlf()
end if
t.fetch_next()
wend
t.close()
mt = table.open(“act_memos”)
mt.fetch_first()
while .not. mt.fetch_eof()
for each id in list
if mt.act_id = id.value
mt.change_begin()
mt.delete()
mt.change_end()
end if
next
mt.fetch_next()
wend
mt.close()
a_tbl = table.open(“activity”)
a_tbl.delete_range(“Cont_Date = Var->ActDate .or. FU_Date = Var->ActDate”)
a_tbl.close()
xbasic_wait_for_idle()
ui_msg_box(“Thank You for Waiting!”,”All Notes and Activities for “+ActDate+”have been deleted.”)
else if xchoice = “Print Notes for this date” then
query.filter = “(fu_date = Var->ActDate ) .or. (fu_date = Var->ActDate )”
query.order = “recno()”
‘replace variables in the filter with their actual values
query.filter = convert_expression(query.filter,”VE”)
:Report.Print(“Quick Note Report”,query.filter,query.order)
else
end if
startdate = ctod(padl(alltrim(str(month(ActDate))),2,”0″)+”/01/”+alltrim(str(year(ActDate))))
startnum = dow(ctod(padl(alltrim(str(month(ActDate))),2,”0″)+”/01/”+alltrim(str(year(ActDate)))))
FOR i = 1 to 42 step 1
daynum = padl(alltrim(str(i)),2,”0″)
eval(“Button”+daynum+”.text”) = alltrim(str(day(startdate-startnum+i)))
BtnList[i] = dtoc(startdate-startnum+i)
if month(startdate-startnum+i) = month(startdate)
eval(“Button”+daynum+”.font.color”) = “dark blue”
else
eval(“Button”+daynum+”.font.color”) = “gray-50”
end if
if day(startdate-startnum+i) = day(ActDate) .and.month(startdate-startnum+i) = month(ActDate)
eval(“Button”+daynum+”.Border.Style”) = “Small-Rounded-Indented”
eval(“Button”+daynum+”.Activate()”)
end if
dim rec_count as N
dim ckdate as D
ckDate = startdate-startnum+i
rec_count = tablecount(“activity”,”DTOC(Cont_Date) = ‘” +DTOC(Var->ckDate)+ “‘”)
if rec_count >= 1 then
eval(“Button”+daynum+”.font.color”) = “Red”
end if
NEXT
That’s all the changes for the day. I hope you found this useful. If so leave a comment. If you have any questions or are looking for help, I am available to take your call.
Nick Lawson
cdcTakecharge
Natn0525@gmail.com
(713) 417-6831
Leave a comment