Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Embedded Calendar Supercontrol

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Embedded Calendar Supercontrol

    I am using the embedded Calendar for users to select a date. I am also disabling dates if they are before "today" or if a condition exists on a matching date record in a specific table.

    I have it working correctly for "This month", but I am stumped as to where to put code defining the "disabled" dates when we navigate to a new month.

    This is the code I use when we first initialize the calendar, and it works exactly as needed.

    Code:
    DIM SHARED V_DATE as D
    DIM end_month as N = day(month_end(date()))
    DIM SHARED varC_result as C
    DIM V_DATE_EmbeddedCalendar as P
    DIM V_DATE_EmbeddedCalendar.startWeekOnMonday as L
    DIM V_DATE_EmbeddedCalendar.disabled as P
    DIM V_DATE_EmbeddedCalendar.disabled.dates[end_month] as P
    
    dim tbl as P
    tbl = table.open("appt_control",FILE_RO_SHARED)
    tbl.index_primary_put("A_date")
    tbl.fetch_find(month_start(date()))
    dim j as N = 1
    while tbl.a_date<=month_end(date())
    	dim tdate as D = {}
    	if tbl.a_date<date() .or. tbl.date_closed
    		tdate = tbl.a_date
    		evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{j}].date as D = \{{tdate}\}"))
    		evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{j}].ignoreYear as L"))
    		j=j+1
    	end if
    	tbl.fetch_next()
    end while
    tbl.close()
    V_DATE_EmbeddedCalendar.disabled.dates.resize(j-1)
    it defines the fields in the pointer arrary "V_DATE_EmbeddedCalendar.disabled.dates".

    What I need to do is to redefine these fields and refresh the calendar when we navigate to another month.

    I added the code in RED to the "<<code>>" section of the dialog which doesn't work.

    Code:
    if a_dlg_button = "update_V_DATE_EmbeddedCalendar" then
    	a_dlg_button = ""
    	if V_DATE <> V_DATE_EmbeddedCalendar.date then
    		V_DATE_EmbeddedCalendar.date = V_DATE
    	end if
    	[COLOR="#FF0000"]if month(v_date) <> month(date())
    		tbl = table.open("appt_control",FILE_RO_SHARED)
    		tbl.index_primary_put("A_date")
    		tbl.fetch_find(month_start(v_date))
    		dim j as N = 1
    		while tbl.a_date<=month_end(v_date)
    			dim tdate as D = {}
    			if tbl.date_closed
    				tdate = tbl.a_date
    				evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{j}].date as D = \{{tdate}\}"))
    				evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{j}].ignoreYear as L"))
    				j=j+1
    			end if
    			tbl.fetch_next()
    		end while
    		tbl.close()
    		V_DATE_EmbeddedCalendar.disabled.dates.resize(j-1)		
    	end if[/COLOR]
    end if
    Any assistance would be greatly appreciated.

    Tom

    #2
    Re: Embedded Calendar Supercontrol

    The Help file states that I should be able to update the disabled.dates[] array elements in the "onMonthNavigate" event of the embedded Calendar control. I've been fiddling wit it all afternoon, to no avail. I wound up just pre-loading the array with our holidays, and then checking my appointment table for 6 months out. That seemed to work.

    Code:
    DIM SHARED V_DATE as D
    DIM end_month as N = month_end(addmonths(date(),6))-month_start(date())+15  'add 15 for holidays
    DIM SHARED varC_result as C
    DIM V_DATE_EmbeddedCalendar as P
    DIM V_DATE_EmbeddedCalendar.startWeekOnMonday as L
    DIM V_DATE_EmbeddedCalendar.disabled as P
    DIM V_DATE_EmbeddedCalendar.disabled.dates[end_month] as P
    
    dim j as N = 1
    for j = 1 to end_month
    		evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{j}].date as D "))
    		evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{j}].ignoreYear as L"))
    next j
    
    'lets get the holidays
    dim hd as P
    hd = table.open("holiday",FILE_RO_SHARED)
    hd.index_primary_put("Holiday")
    begyear = Ctod("01/01//"+cyear(date()))
    hd.fetch_find(begyear)
    j=1
    while year(hd.holiday)=year(date())
    	tdate = hd.holiday
    	evaluate_template(evaluate_string("V_DATE_EmbeddedCalendar.disabled.dates[{j}].date = \{{tdate}\}"))
    	j=j+1
    	if hd.eof()
    		exit while
    	end if
    	hd.fetch_next()
    end while
    'now the appointment dates
    'don't re-initialize "j" as it is pointing to the next array slot
    hd.close()
    dim tbl as P
    tbl = table.open("appt_control",FILE_RO_SHARED)
    tbl.index_primary_put("A_date")
    tbl.fetch_find(month_start(date()))
    while tbl.a_date<=month_end(addmonths(date(),6))
    	if tbl.eof()
    		exit while
    	end if
    	dim tdate as D = {}
    	if tbl.a_date<date() .or. tbl.date_closed
    		tdate = tbl.a_date
    		evaluate_template(evaluate_string("V_DATE_EmbeddedCalendar.disabled.dates[{j}].date = \{{tdate}\}"))
    		j=j+1
    	end if
    	tbl.fetch_next()
    end while
    tbl.close()
    V_DATE_EmbeddedCalendar.disabled.dates.resize(j-1)
    Note that dates before "today" are disabled, and the date of the 11th has no available appointments, now switch to April and see that Good Friday (a holiday) is disaBLED.

    Calendars.jpg

    Tom

    Comment


      #3
      Re: Embedded Calendar Supercontrol

      Nice one Tom.

      Comment


        #4
        Re: Embedded Calendar Supercontrol

        Now there is a new twist. I need to DYNAMICALLY build the Disabled dates based on the value of a radio button selected earlier in the Dialog. Is there an event to trap on a radio button in x_dialog?

        We have 2 types of appointments, face-to-face, and telephone. The disabled dates are based on the number of available face-to-face or telephone slots available on a given date.
        If there are no face-to-face slots available, I want to disable that date only if the selected interview type is for face-to-face, however, if it is a telephone interview, and there is an available telephone interview on that same date, I need to make it enabled.

        Tom

        Comment


          #5
          Re: Embedded Calendar Supercontrol

          I figured it out.

          I used the "change" event on the radio button to determine which type of dates to close.
          in the event code, I resize the disabled dates array back to its original size, then beginning after the holidays, populate it based on the type of dates I want to close.

          Works like a charm!!!!!

          Code:
          'Date Created: 07-Mar-2014 03:54:58 PM
          'Last Updated: 12-Mar-2014 12:32:22 PM
          'Created By  : Thomas Henkel
          'Updated By  : Thomas Henkel
          'Create an XDialog dialog box to prompt for parameters.
          'debugcheck()
          DIM SHARED V_DATE as D = Date()
          DIM end_month as N = month_end(addmonths(date(),6))-month_start(date())+15  'add 15 for holidays
          DIM SHARED varC_result as C
          DIM V_DATE_EmbeddedCalendar as P
          DIM V_DATE_EmbeddedCalendar.startWeekOnMonday as L
          DIM V_DATE_EmbeddedCalendar.disabled as P
          DIM V_DATE_EmbeddedCalendar.disabled.dates[end_month] as P
          DIM V_Type as C = ""
          dim j as N = 1
          for j = 1 to end_month
          		evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{j}].date as D "))
          		evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{j}].ignoreYear as L"))
          next j
          
          'lets get the holidays
          dim hd as P
          hd = table.open("holiday",FILE_RO_SHARED)
          hd.index_primary_put("Holiday")
          begyear = Ctod("01/01//"+cyear(date()))
          hd.fetch_find(begyear)
          j=1
          while year(hd.holiday)=year(date())
          	tdate = hd.holiday
          	evaluate_template(evaluate_string("V_DATE_EmbeddedCalendar.disabled.dates[{j}].date = \{{tdate}\}"))
          	j=j+1
          	if hd.eof()
          		exit while
          	end if
          	hd.fetch_next()
          end while
          'now the appointment dates
          'don't re-initialize "j" as it is pointing to the next array slot
          DIM i as N = j
          hd.close()
          'dim tbl as P
          'tbl = table.open("appt_control",FILE_RO_SHARED)
          'tbl.index_primary_put("A_date")
          'tbl.fetch_find(month_start(date()))
          'while tbl.a_date<=month_end(addmonths(date(),6))
          '	if tbl.eof()
          '		exit while
          '	end if
          '	dim tdate as D = {}
          '	if tbl.a_date<date() .or. tbl.date_closed
          '		tdate = tbl.a_date
          '		evaluate_template(evaluate_string("V_DATE_EmbeddedCalendar.disabled.dates[{j}].date = \{{tdate}\}"))
          '		j=j+1
          '	end if
          '	tbl.fetch_next()
          'end while
          'tbl.close()
          'V_DATE_EmbeddedCalendar.disabled.dates.resize(j-1)
          DIM V_DATE_EmbeddedCalendar.range as P
          DIM V_DATE_EmbeddedCalendar.range.useRange as L
          DIM V_DATE_EmbeddedCalendar.range.startDate as D
          DIM V_DATE_EmbeddedCalendar.range.endDate as D
          DIM V_DATE_EmbeddedCalendar.range.ignoreYear as L
          DIM V_DATE_EmbeddedCalendar.useDropdowns as L = .T.
          DIM V_DATE_EmbeddedCalendar.events as C = <<%str%
          ' The variable "ptr" provides a pointer to the calendar's properties.
          ' Properties that can be set at runtime are:
          '	ptr.date					as D - the date that is currently selected.
          '	ptr.focusDate				as D - the date that currently has focus on the calendar (setting this will navigate the calendar to the date).
          '	ptr.range.useRange			as L - whether to use the range restrictions.
          '	ptr.range.startDate			as D - start date of the range.
          '	ptr.range.startDate			as D - end date of the range.
          '	ptr.range.ignoreYear		as L - whether the range should be used every year.
          '	ptr.disabled.weekDays		as C - a comma separated list of days of the week to disable. (Note: if you have set the calendar to show Monday as the first day of the week, settings ptr.disabled.weekDays = "1" would disable Monday not Sunday)
          '	ptr.disabled.dates[]		as P - a property array of dates that will be rendered as disabled.
          '					.date		as D - the date to disable.
          '					.ignoreYear	as L - whether the date should be disabled every year.
          '	ptr.flaggedDates[]			as P - a property array of dates that will be rendered as flagged in the calendar.
          '					.date		as D - the date to flag.
          '					.color		as C - the color of the flag.
          '					.ignoreYear	as L - whether the date should be flagged every year.
          
          function onInitialize as v (ptr as p)
          	
          end function
          
          function onDateSelect as v (date as d, ptr as p)
          	
          	' Generated code. Do not delete!
          	' ------------------------------------------------------------------------
          	if eval_valid("ptr.variableName") then
          		dim sv as p
          		sv = session_variables()
          		evaluate_template("sv."+ptr.variableName+" = date")
          	end if
          	' ------------------------------------------------------------------------
          end function
          
          function onDateRightClick as v (date as d, ptr as p)
          	
          	' Generated code. Do not delete!
          	' ------------------------------------------------------------------------
          	if eval_valid("ptr.variableName") then
          		dim sv as p
          		sv = session_variables()
          		evaluate_template("sv."+ptr.variableName+" = date")
          	end if
          	' ------------------------------------------------------------------------	
          end function
          
          function onMonthNavigate as v (year as n, month as n, ptr as p)
          
          end function
          
          function onYearNavigate as v (year as n, month as n, ptr as p)
          	
          end function
          %str%
          DIM V_DATE_EmbeddedCalendar.style as P
          DIM V_DATE_EmbeddedCalendar.style.font as P
          DIM V_DATE_EmbeddedCalendar.style.font.size as N = 8
          DIM V_DATE_EmbeddedCalendar.style.font.bold as L
          DIM V_DATE_EmbeddedCalendar.style.font.italic as L
          
          DIM V_DATE_EmbeddedCalendar.date as D = V_DATE
          DIM V_DATE_EmbeddedCalendar.variableName as C = "V_DATE"
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          varC_result = ui_dlg_box("Alpha Five",<<%dlg%
          {region}
          Please select Interview Type:  (v_type={In Person, Telephone}!v_type_*);
          
          Please select Date:| {DatePicker=50,10V_DATE_EmbeddedCalendar}{watch=V_DATE!update_V_DATE_EmbeddedCalendar};
          {endregion};
          {line=1,0};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%,<<%code%
          'debugcheck()
          'traceln(a_dlg_button)
          if left(a_dlg_button,7)="v_type_"
          	if a_dlg_button = "v_type_change"
          	'debugcheck()		
          		'put code her to dynamically select disabled dates
          		if alltrim(v_type) = "Telephone"
          		  	expr1 = "tbl.phone_closed"
          		  else
          			expr1 = "tbl.date_closed"
          		end if
          		dim tbl as P
          '	Resize the disable date back to the original size
          '		Clear the disabled dates from j to the end
          		V_DATE_EmbeddedCalendar.disabled.dates.resize(end_month)
          		V_DATE_EmbeddedCalendar.disabled.dates.clear(i,end_month)
          		'populate the array with valid disabled dates
          		for n = i to end_month
          			evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{n}].date as D "))
          			evaluate_template(evaluate_string("DIM V_DATE_EmbeddedCalendar.disabled.dates[{n}].ignoreYear as L"))
          		next n
          		j=i
          		tbl = table.open("appt_control",FILE_RO_SHARED)
          		tbl.index_primary_put("A_date")
          		tbl.fetch_find(month_start(v_date))
          		while tbl.a_date<=month_end(v_date)
          			dim tdate as D = {}
          			if tbl.a_date<date() .or. eval(expr1)
          				tdate = tbl.a_date
          				evaluate_template(evaluate_string("V_DATE_EmbeddedCalendar.disabled.dates[{j}].date = \{{tdate}\}"))
          				j=j+1
          			end if
          			tbl.fetch_next()
          		end while
          		tbl.close()
          		V_DATE_EmbeddedCalendar.disabled.dates.resize(j-1)
          	end if
          	a_dlg_button=""
          end if
          if a_dlg_button = "update_V_DATE_EmbeddedCalendar" then
          	a_dlg_button = ""
          	if V_DATE <> V_DATE_EmbeddedCalendar.date then
          		V_DATE_EmbeddedCalendar.date = V_DATE
          	end if
          
          end if
          %code%)
          Examples: I closed the 18th for "In person" appointments and the 17th for "telephone". Notice that the days are properly disabled.

          datepicker.jpg

          Hope this is helpful to anyone who need it.

          Tom

          Comment

          Working...
          X