Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar Report.

Status
Not open for further replies.

muncter

Technical User
May 18, 2011
11
AU
Hi,

I have created a report in Clarion Vers 5.5 which collects data from a file based on days of the month with each day assigned to one record.

I need to know how to get the report to print with the first Monday of the month not the first day. It is printing the calendar in the correct order but the first day of the month is printed in the first column instead of the first Monday.

I am uncertain as to whether I can put a filter on the report to set the order.

The code for the report follows -



MEMBER('pgbook.clw') ! This is a MEMBER module


INCLUDE('ABREPORT.INC'),ONCE

MAP
INCLUDE('PGBOO009.INC'),ONCE !Local module procedure declarations
INCLUDE('PGBOO010.INC'),ONCE !Req'd for module callout resolution
END


BookingDaysReport PROCEDURE !Generated from procedure template - Report

Progress:Thermometer BYTE
TotalNumberofDays REAL
MonthNow STRING(20)
YearNow SHORT
ReportDate STRING(20)
WeekDay STRING(20)
Process:View VIEW(Bookings)
PROJECT(BKG:Date)
PROJECT(BKG:UserID)
JOIN(USR:KeyUserID,BKG:UserID)
PROJECT(USR:ShortName)
END
END
ProgressWindow WINDOW('Progress...'),AT(,,142,59),CENTER,TIMER(1),GRAY,DOUBLE
PROGRESS,USE(Progress:Thermometer),AT(15,15,111,12),RANGE(0,100)
STRING(''),AT(0,3,141,10),USE(?Progress:UserString),CENTER
STRING(''),AT(0,30,141,10),USE(?Progress:pctText),CENTER
BUTTON('Cancel'),AT(45,42,50,15),USE(?Progress:Cancel)
END

report REPORT,AT(200,1323,11500,6760),PAPER(PAPER:A4),PRE(RPT),FONT('Arial',10,,),LANDSCAPE,THOUS
HEADER,AT(200,500,11500,802),USE(?unnamed:2)
STRING('Parade Ground Bookings'),AT(1979,21,6500,375),USE(?unnamed),CENTER,FONT(,20,,FONT:bold)
IMAGE('TAFE_BLACK.jpg'),AT(73,42,635,698),USE(?Image1)
STRING(@s20),AT(4250,385),USE(ReportDate),CENTER,FONT(,12,,FONT:bold,CHARSET:ANSI)
END
detail2 DETAIL,AT(,,1500,1208),USE(?unnamed:5)
STRING(@d6),AT(135,313),USE(BKG:Date,,?BKG:Date:2),FONT(,14,,FONT:regular,CHARSET:ANSI)
STRING(@s20),AT(63,83,1302,208),USE(WeekDay),CENTER
BOX,AT(0,0,1479,1188),USE(?Box1),COLOR(COLOR:Black),LINEWIDTH(20)
STRING(@s20),AT(52,719,1365,208),USE(USR:ShortName),CENTER(1),FONT(,12,,FONT:bold,CHARSET:ANSI)
END
FOOTER,AT(200,8000,11500,219),USE(?unnamed:3)
STRING(@pPage <<<#p),AT(5250,30,700,135),PAGENO,USE(?PageCount),FONT('Arial',8,,FONT:regular)
END
END
MouseWheel:BookingDaysReport vsMouseWheelClass
ThisWindow CLASS(ReportManager)
Init PROCEDURE(),BYTE,PROC,DERIVED
Init PROCEDURE(ProcessClass PC,<REPORT R>,<PrintPreviewClass PV>)
Kill PROCEDURE(),BYTE,PROC,DERIVED
Next PROCEDURE(),BYTE,PROC,DERIVED
Reset PROCEDURE(BYTE Force=0),DERIVED
Update PROCEDURE(),DERIVED
END

ThisReport CLASS(ProcessClass) !Process Manager
TakeRecord PROCEDURE(),BYTE,PROC,DERIVED
END

Previewer PrintPreviewClass !Print Previewer

CODE
GlobalResponse = ThisWindow.Run()


ThisWindow.Init PROCEDURE

ReturnValue BYTE,AUTO

CODE
GlobalErrors.SetProcedureName('BookingDaysReport')
SELF.Request = GlobalRequest
ReturnValue = PARENT.Init()
IF ReturnValue THEN RETURN ReturnValue.
SELF.FirstField = ?Progress:Thermometer
SELF.VCRRequest &= VCRRequest
SELF.Errors &= GlobalErrors
CLEAR(GlobalRequest)
CLEAR(GlobalResponse)
Relate:Bookings.Open
SELF.FilesOpened = True
OPEN(ProgressWindow)
SELF.Opened=True
MouseWheel:BookingDaysReport.Init()
ThisReport.Init(Process:View, Relate:Bookings, ?Progress:pctText, Progress:Thermometer)
ThisReport.AddSortOrder()
ThisReport.AppendOrder('BKG:Date')
ThisReport.SetFilter('bkg:date <<> 0')
SELF.AddItem(?Progress:Cancel,RequestCancelled)
SELF.Init(ThisReport,report,Previewer)
?Progress:UserString{Prop:Text}=''
Relate:Bookings.SetQuickScan(1,Propagate:OneMany)
SELF.Zoom = 100
Previewer.AllowUserZoom=True
Previewer.Maximize=True
SELF.SetAlerts()
RETURN ReturnValue


ThisWindow.Init PROCEDURE(ProcessClass PC,<REPORT R>,<PrintPreviewClass PV>)

CODE
PARENT.Init(PC,R,PV)
GlobalRequest = SelectRecord ! Set Action for Lookup
selectdaterange ! Call the Lookup Procedure
GlobalResponse = RequestCancelled ! Clear Result


ThisWindow.Kill PROCEDURE

ReturnValue BYTE,AUTO

CODE
ReturnValue = PARENT.Kill()
IF ReturnValue THEN RETURN ReturnValue.
IF SELF.FilesOpened
Relate:Bookings.Close
END
MouseWheel:BookingDaysReport.Kill
GlobalErrors.SetProcedureName
RETURN ReturnValue


ThisWindow.Next PROCEDURE

ReturnValue BYTE,AUTO

CODE
ReturnValue = PARENT.Next()
If month(BKG:Date) = 1
MonthNow = 'January'
elsif month(BKG:Date) = 2
MonthNow = 'February'
elsif month(BKG:Date) = 3
MonthNow = 'March'
elsif month(BKG:Date) = 4
MonthNow = 'April'
elsif month(BKG:Date) = 5
MonthNow = 'May'
elsif month(BKG:Date) = 6
MonthNow = 'June'
elsif month(BKG:Date) = 7
MonthNow = 'July'
elsif month(BKG:Date) = 8
MonthNow = 'August'
elsif month(BKG:Date) = 9
MonthNow = 'September'
elsif month(BKG:Date) = 10
MonthNow = 'October'
elsif month(BKG:Date) = 11
MonthNow = 'November'
elsif month(BKG:Date) = 12
MonthNow = 'December'
end
!YearNow = year(BKG:Date)
ReportDate=clip(MonthNow)&' '&Year(BKG:Date)
!!Day of the week calculations!!
!!I'm not quite sure what you want your function to do
!!However I think that this is close
!!Note: % is the modulus operator
!!Clarion dates are LONGS, representing the number of days
!!Since Dec 28th, 1800
!!----------------------------------------------------------
! MAP
! GetWeekEndingDate(DATE xInputDate),DATE
! END

!GetWeekEndingDate PROCEDURE(DATE xInputDate)!,DATE
!DayOfWeek LONG
!RetVal DATE
! CODE
! DayOfWeek = xInputDate % 7 !0 is Sunday, 1 is Monday, ... 6 is Saturday
! RetVal = xInputDate + (6 - DayOfWeek) !Always return a Saturday
! !The code gets slightly trickier
! ! if you want a different day of the week.
! RETURN RetVal
!!======================================================================

if BKG:Date % 7 =0
WeekDay = 'Sunday'
elsif BKG:Date % 7 =1
WeekDay = 'Monday'
elsif BKG:Date % 7 =2
WeekDay = 'Tuesday'
elsif BKG:Date % 7 =3
WeekDay = 'Wednesday'
elsif BKG:Date % 7 =4
WeekDay = 'Thursday'
elsif BKG:Date % 7 =5
WeekDay = 'Friday'
elsif BKG:Date % 7 =6
WeekDay = 'Saturday'
end
Display()

!NextWeek = TODAY() + 7
!NextMonth = DATE( MONTH(TODAY()) + 1, DAY(TODAY()), YEAR(TODAY())
!NextYear = DATE( MONTH(TODAY()), DAY(TODAY()), YEAR(TODAY()+1)

!Date % 7 ! % is the MODULUS operator
!0 -> Sunday
!1 -> Monday
!...
!6 -> Saturday

!Note: CW's DATE command handle values outside of the normal range.
!So DATE( 13, 25, 2006) = DATE( 1, 25, 2007)

!HTH,
!-- Mark

!!======================================================================

!! New Week
! NewDate = Date(Month(Today()),Day(Today())+7,Year(Today()))
!!End

!! New Month
! NewDate = Date(Month(Today())+1,Day(Today()),Year(Today()))
!!End

!! New Year
! NewDate = Date(Month(Today()),Day(Today()),Year(Today())+1)
!!End

!======================================================================
RETURN ReturnValue


ThisWindow.Reset PROCEDURE(BYTE Force=0)

CODE
SELF.ForcedReset += Force
IF ProgressWindow{Prop:AcceptAll} THEN RETURN.
USR:UserID = BKG:UserID ! Assign linking field value
Access:Users.Fetch(USR:KeyUserID)
PARENT.Reset(Force)


ThisWindow.Update PROCEDURE

CODE
PARENT.Update
USR:UserID = BKG:UserID ! Assign linking field value
Access:Users.Fetch(USR:KeyUserID)


ThisReport.TakeRecord PROCEDURE

ReturnValue BYTE,AUTO

SkipDetails BYTE
CODE
YearNow = YEAR(BKG:Date)
ReturnValue = PARENT.TakeRecord()
IF month(bkg:date) = month(StartDate) and year(bkg:date) = year(Startdate)
PRINT(RPT:detail2)
END
RETURN ReturnValue

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top