Web Apps – Current Week Timecard Button

A little while ago I posted about using a custom stored procedure called zsp_getMenuNotifications in the Web Apps Menu() function.   Now I’ll show you what I did with some of the results of that procedure.

Part of my SQL code returns the most recent in-process timecard where the week-ending date is no older than 1 week from today.

insert into #temp (pe_date, aww)
select top 1 cast(h.pe_date as date), LEFT(le_id02,3) as AWW
from PJLABHDR h (nolock) 
where h.employee = @employee 
	and h.le_status = 'i'
	and h.pe_date > GETDATE()-7
order by pe_date

Then, in the Menu.vbhtml, I added a test to see if the user has an open timecard. If they do, I display a button (the label is the week ending date) that will take them directly to that timecard. We support multiple week ending dates, so the AWW transforms the displayed ending date for some users.

 @If Session("CurTCExists") > "1900-01-01" Then
     @If Session("AWW") = "FRI" Then
         datedisplay = datedisplay.AddDays(-1)
      End If       
      @<a data-role="none" class="btn btn-primary btn-md" href="javascript:MenuSelection('/ProjectTimecard/Periods?CalledBy=Current','',false,'Timecard Entry (MD.TMT.CE)',true)">@datedisplay.ToShortDateString</a>
 End If 

The key to making it work is editing the Periods() function. I added an optional Parameter for CalledBy, to which my custom button passes the value ‘Current’

<HttpGet()> _
Public Function Periods(Optional ByVal CalledBy As String = "") As ActionResult

The, at the end of the function, I added code to test if the function was CalledBy = 'Current'If so, go straight to My Assignments for that week passing the week ending date we assigned earlier.  

'MSDE added to go directly to MyAssign from Menu - 9/10/18
If CalledBy = "Current" Then

    Dim DateToStart As Date
    DateToStart = Session("CurTCExists")

    Return MyAssignments(DateToStart)
Else
    Return View("Periods", ProjectTimecardUIHelper.CurrentTimecardModel)
End If

Our new button:

Feel free to share...

Leave a Reply

Close Menu