added fabtime shift calendar

This commit is contained in:
Infineon\StieberD 2024-10-03 17:36:01 -07:00 committed by Stieber Daniel (CSC FI SPS MESLEO)
parent 291f050338
commit b443f237a1
7 changed files with 640 additions and 4419 deletions

View File

@ -116,3 +116,4 @@ end
Return Ans Return Ans

View File

@ -0,0 +1,36 @@
Compile function Copy_SHIFT_CALENDAR_Record_To_SQL(Connection, Key, Record)
/*****************************************************************************\
Copies the given SHIFT_CALENDAR record to the MSSQL database.
History
-------
10/02/2024 DJS Original Programmer
\*****************************************************************************/
$insert SHIFT_CALENDAR_EQUATES
Declare function SQL_Write, SQL_Write_MV, SQL_Format
Ans = ""
// Parse record into a dimensioned array for speed
Dim Rec(6)
MatParse Record into Rec
// List of key names and their values
Keys = "DAY" :@VM:SQL_Format(Field(Key, "*", 1), "STR"):@FM
Keys := "FISCAL_YEAR":@VM:SQL_Format(Field(Key, "*", 2), "INT"):@FM
Keys := "SHIFT":@VM:SQL_Format(Field(Key, "*", 3), "STR")
// List of data fields and their values
DataFields = "START_DTM" :@VM:SQL_Format(Rec(SHIFT_CALENDAR.START_DTM$), "DATETIME"):@FM
DataFields := "END_DTM" :@VM:SQL_Format(Rec(SHIFT_CALENDAR.END_DTM$), "DATETIME"):@FM
DataFields := "FISCAL_WEEK" :@VM:SQL_Format(Rec(SHIFT_CALENDAR.FISCAL_WEEK$), "STR"):@FM
DataFields := "FISCAL_MONTH" :@VM:SQL_Format(Rec(SHIFT_CALENDAR.FISCAL_MONTH$), "INT"):@FM
DataFields := "FISCAL_QUARTER" :@VM:SQL_Format(Rec(SHIFT_CALENDAR.FISCAL_QUARTER$), "STR")
// Write the data to the SQL database
Ans = SQL_Write(Connection, "SHIFT_CALENDAR", Keys, DataFields);
Return Ans

View File

@ -0,0 +1,273 @@
Function FISCAL_YR_Actions(Action, CalcColName, FSList, Handle, Name, FMC, Record, Status, OrigRecord, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10)
/***********************************************************************************************************************
This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
permission from Infineon.
Name : Fiscal_Yr_Actions
Description : Handles calculated columns and MFS calls for the current table.
Notes : This function uses @ID, @RECORD, and @DICT to make sure {ColumnName} references work correctly.
If called from outside of a calculated column these will need to be set and restored.
Parameters :
Action [in] -- Name of the action to be taken
CalcColName [in] -- Name of the calculated column that needs to be processed. Normally this should only be
populated when the CalcField action is being used.
FSList [in] -- The list of MFSs and the BFS name for the current file or volume. This is an @SVM
delimited array, with the current MFS name as the first value in the array, and the BFS
name as the last value. Normally set by a calling MFS.
Handle [in] -- The file handle of the file or media map being accessed. Note, this does contain the
entire handle structure that the Basic+ Open statement would provide. Normally set by a
calling MFS.
Name [in] -- The name (key) of the record or file being accessed. Normally set by a calling MFS.
FMC [in] -- Various functions. Normally set by a calling MFS.
Record [in] -- The entire record (for record-oriented functions) or a newly-created handle (for
"get handle" functions). Normally set by a calling MFS.
Status [in/out] -- Indicator of the success or failure of an action. Normally set by the calling MFS but
for some actions can be set by the action handler to indicate failure.
OrigRecord [in] -- Original content of the record being processed by the current action. This is
automatically being assigned by the WRITE_RECORD and DELETE_RECORD actions within
BASE_MFS.
Param1-10 [in/out] -- Additional request parameter holders
ActionFlow [out] -- Used to control the action chain (see the ACTION_SETUP insert for more information.)
Can also be used to return a special value, such as the results of the CalcField
method.
History : (Date, Initials, Notes)
10/03/24 djs Original programmer.
***********************************************************************************************************************/
#pragma precomp SRP_PreCompiler
$Insert FILE.SYSTEM.EQUATES
$Insert ACTION_SETUP
$Insert APP_INSERTS
$Insert FISCAL_YR_EQUATES
$Insert SHIFT_CALENDAR_EQUATES
Declare function LSL_Users_Services
Declare subroutine Database_Services
If KeyID then GoSub Initialize_System_Variables
Begin Case
Case Action _EQC 'CalculateColumn' ; GoSub CalculateColumn
Case Action _EQC 'READ_RECORD_PRE' ; GoSub READ_RECORD_PRE
Case Action _EQC 'READ_RECORD' ; GoSub READ_RECORD
Case Action _EQC 'READONLY_RECORD_PRE' ; GoSub READONLY_RECORD_PRE
Case Action _EQC 'READONLY_RECORD' ; GoSub READONLY_RECORD
Case Action _EQC 'WRITE_RECORD_PRE' ; GoSub WRITE_RECORD_PRE
Case Action _EQC 'WRITE_RECORD' ; GoSub WRITE_RECORD
Case Action _EQC 'DELETE_RECORD_PRE' ; GoSub DELETE_RECORD_PRE
Case Action _EQC 'DELETE_RECORD' ; GoSub DELETE_RECORD
Case Otherwise$ ; Status = 'Invalid Action'
End Case
If KeyID then GoSub Restore_System_Variables
If Assigned(ActionFlow) else ActionFlow = ACTION_CONTINUE$
Return ActionFlow
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Calculated Columns
//
// The typical structure of a calculated column will look like this:
//
// Declare function Database_Services
//
// @ANS = Database_Services('CalculateColumn')
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CalculateColumn:
// Make sure the ActionFlow return variable is cleared in case nothing is calculated.
ActionFlow = ''
return
// ----- MFS calls -----------------------------------------------------------------------------------------------------
READ_RECORD_PRE:
// In order to stop a record from being read in this action these lines of code must be used:
//
// OrigFileError = 100 : @FM : KeyID
// Status = 0
// Record = ''
// ActionFlow = ACTION_STOP$
return
READ_RECORD:
// In order to stop a record from being read in this action these lines of code must be used:
//
// OrigFileError = 100 : @FM : KeyID
// Status = 0
// Record = ''
return
READONLY_RECORD_PRE:
// In order to stop a record from being read in this action these lines of code must be used:
//
// OrigFileError = 100 : @FM : KeyID
// Status = 0
// Record = ''
// ActionFlow = ACTION_STOP$
return
READONLY_RECORD:
// In order to stop a record from being read in this action these lines of code must be used:
//
// OrigFileError = 100 : @FM : KeyID
// Status = 0
// Record = ''
return
WRITE_RECORD_PRE:
return
WRITE_RECORD:
If OrigRecord NE Record then
FiscalYear = Name
FiscalWeeks = {WK_NO}
FiscalStartDts = {WK_START_DT}
FiscalEndDts = {WK_END_DT}
FiscalMonthNos = {WK_MONTH_NO}
FiscalQtrs = {WK_QTR_NO}
For each FiscalWeek in FiscalWeeks using @VM setting vPos
FiscalStartDt = FiscalStartDts<0, vPos>
FiscalEndDt = FiscalEndDts<0, vPos>
If FiscalMonthNos<0, vPos> NE '' then
FiscalMonthNo = FiscalMonthNos<0, vPos>
end
If FiscalQtrs<0, vPos> NE '' then
FiscalQtr = FiscalQtrs<0, vPos>
end
For InternalDate = FiscalStartDt to FiscalEndDt Step 1
FirstShiftRec = ''
SecondShiftRec = ''
OutDate = OConv(InternalDate, 'D4/')
OutDatePlusOne = OConv(InternalDate + 1, 'D4/')
FirstShiftStartTime = '06:00:00AM'
FirstShiftStartDtm = OutDate : ' ' : FirstShiftStartTime
FirstShift = LSL_Users_Services('GetShiftByDate', FirstShiftStartDtm)
FirstShiftEndDtm = OutDate : ' 5:59:59PM'
SecondShiftStartTime = '06:00:00PM'
SecondShiftStartDtm = OutDate : ' ' : SecondShiftStartTime
SecondShift = LSL_Users_Services('GetShiftByDate', SecondShiftStartDtm)
SecondShiftEndDtm = OutDatePlusOne : ' 05:59:59AM'
ShiftDate = OConv(InternalDate, 'DH')
ShiftMonth = Field(ShiftDate, ' ', 1, 1)
ShiftDay = Field(ShiftDate, ' ', 1, 2)
Convert ' ' to '' in ShiftDay
ShiftYear = Field(ShiftDate, ' ', 3, 1)
FirstShiftKey = ShiftDay : '*' : FiscalYear : '*' : FirstShift
SecondShiftKey = ShiftDay : '*' : FiscalYear : '*' : SecondShift
FirstShiftRec<SHIFT_CALENDAR.START_DTM$> = IConv(FirstShiftStartDtm, 'DT')
FirstShiftRec<SHIFT_CALENDAR.END_DTM$> = IConv(FirstShiftEndDtm, 'DT')
FirstShiftRec<SHIFT_CALENDAR.FISCAL_WEEK$> = 'WW':FiscalWeek
FirstShiftRec<SHIFT_CALENDAR.FISCAL_MONTH$> = FiscalMonthNo
FirstShiftRec<SHIFT_CALENDAR.FISCAL_QUARTER$> = 'Q':FiscalQtr
Database_Services('WriteDataRow', 'SHIFT_CALENDAR', FirstShiftKey, FirstShiftRec)
SecondShiftRec<SHIFT_CALENDAR.START_DTM$> = IConv(SecondShiftStartDtm, 'DT')
SecondShiftRec<SHIFT_CALENDAR.END_DTM$> = IConv(SecondShiftEndDtm, 'DT')
SecondShiftRec<SHIFT_CALENDAR.FISCAL_WEEK$> = 'WW':FiscalWeek
SecondShiftRec<SHIFT_CALENDAR.FISCAL_MONTH$> = FiscalMonthNo
SecondShiftRec<SHIFT_CALENDAR.FISCAL_QUARTER$> = 'Q':FiscalQtr
Database_Services('WriteDataRow', 'SHIFT_CALENDAR', SecondShiftKey, SecondShiftRec)
Next InternalDate
Next FiscalWeek
end
return
DELETE_RECORD_PRE:
return
DELETE_RECORD:
return
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal GoSubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ClearCursors:
For counter = 0 to 8
ClearSelect counter
Next counter
return
Initialize_System_Variables:
// Save these for restoration later
SaveDict = @DICT
SaveID = @ID
SaveRecord = @RECORD
OrigFileError = @FILE.ERROR
// Now make sure @DICT, ID, and @RECORD are populated
CurrentDictName = ''
If @DICT then
DictHandle = @DICT<1, 2>
Locate DictHandle in @TABLES(5) Using @FM Setting fPos then
CurrentDictName = Field(@TABLES(0), @FM, fPos, 1)
end
end
If CurrentDictName NE DictName then
Open DictName to @DICT else Status = 'Unable to initialize @DICT'
end
@ID = KeyID
If Record else
// Record might not have been passed in. Read the record from the database table just to make sure.
@FILE.ERROR = ''
Open TableName to hTable then
FullFSList = hTable[1, 'F' : @VM]
BFS = FullFSList[-1, 'B' : @SVM]
LastHandle = hTable[-1, 'B' : \0D\]
FileHandle = \0D\ : LastHandle[1, @VM]
Call @BFS(READO.RECORD, BFS, FileHandle, KeyID, FMC, Record, ReadOStatus)
end
end
@RECORD = Record
return
Restore_System_Variables:
Transfer SaveDict to @DICT
Transfer SaveID to @ID
Transfer SaveRecord to @RECORD
@FILE.ERROR = OrigFileError
return

View File

@ -167,7 +167,11 @@ Service GetOnShiftUsersByClass(Class, IncludeNextShift)
SearchString = '' SearchString = ''
SearchString := 'CLASSIFICATION':@VM:Class:@FM SearchString := 'CLASSIFICATION':@VM:Class:@FM
SearchString := 'SHIFT' : @VM : CurrentShift<1,1>: @VM : CurrentShift<1,2>: @VM : CurrentShift<1,3>: @VM : CurrentShift<1,4> :@FM SearchString := 'SHIFT'
For each Shift in CurrentShift using @VM setting vPos
SearchString := @VM : Shift
Next Shift
SearchString := @VM : '' : @FM ; // Include office personnel (i.e. no shift assigned)
SearchString := 'ACTIVE' : @VM : True$ : @FM SearchString := 'ACTIVE' : @VM : True$ : @FM
LSLUsersKeys = '' LSLUsersKeys = ''
Btree.Extract(SearchString, 'LSL_USERS', DictLSLUsers, LSLUsersKeys, '', '') Btree.Extract(SearchString, 'LSL_USERS', DictLSLUsers, LSLUsersKeys, '', '')
@ -191,7 +195,7 @@ Service GetShiftByDate(Date, GenerateFlag)
return return
end end
DateConv = Iconv(Date, "DT") DateConv = Iconv(Date, "DT")
CalStartDate = 20097; *Arbitrary Start Date to base calendar off of. February 6th 2022 CalStartDate = 18998; *Arbitrary Start Date to base calendar off of. Jan 5, 2020 Beginning of short shift 1
DaysSinceStart = SRP_DateTime("DaySpan", CalStartDate, DateConv, 0) DaysSinceStart = SRP_DateTime("DaySpan", CalStartDate, DateConv, 0)
WeeksSinceStart = SRP_Math("FLOOR", DaysSinceStart / 7) WeeksSinceStart = SRP_Math("FLOOR", DaysSinceStart / 7)
WeekType = '' WeekType = ''
@ -225,55 +229,55 @@ Service GetShiftByDate(Date, GenerateFlag)
Case Weekday EQ SUNDAY$ Case Weekday EQ SUNDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 1 OnShift = 'A'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 2 OnShift = 'B'
End Case End Case
Case Weekday EQ MONDAY$ Case Weekday EQ MONDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F' OnShift = 'A'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 2 OnShift = 'B'
End Case End Case
Case Weekday EQ TUESDAY$ Case Weekday EQ TUESDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F' OnShift = 'A'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 2 OnShift = 'B'
End Case End Case
Case Weekday EQ WEDNESDAY$ Case Weekday EQ WEDNESDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F' OnShift = 'A'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then if ShiftTime LT 21600 then
OnShift = 2 OnShift = 'B'
end else end else
OnShift = 4 OnShift = 'D'
end end
End Case End Case
Case Weekday EQ THURSDAY$ Case Weekday EQ THURSDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F' OnShift = 'C'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 4 OnShift = 'D'
End Case End Case
Case Weekday EQ FRIDAY$ Case Weekday EQ FRIDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F' OnShift = 'C'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 4 OnShift = 'D'
End Case End Case
Case Weekday EQ SATURDAY$ Case Weekday EQ SATURDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 3 OnShift = 'C'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 4 OnShift = 'D'
End Case End Case
End Case End Case
Case WeekType = 'Long3' Case WeekType = 'Long3'
@ -281,63 +285,63 @@ Service GetShiftByDate(Date, GenerateFlag)
Case Weekday EQ SUNDAY$ Case Weekday EQ SUNDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 1 OnShift = 'A'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then if ShiftTime LT 21600 then
OnShift = 4 OnShift = 'D'
end else end else
OnShift = 2 OnShift = 'B'
end end
End Case End Case
Case Weekday EQ MONDAY$ Case Weekday EQ MONDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F' OnShift = 'A'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 2 OnShift = 'B'
End Case End Case
Case Weekday EQ TUESDAY$ Case Weekday EQ TUESDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 1 : @VM : 'M-F' OnShift = 'A'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 2 OnShift = 'B'
End Case End Case
Case Weekday EQ WEDNESDAY$ Case Weekday EQ WEDNESDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F' OnShift = 'C'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then if ShiftTime LT 21600 then
OnShift = 2 OnShift = 'B'
end else end else
OnShift = 4 OnShift = 'D'
end end
End Case End Case
Case Weekday EQ THURSDAY$ Case Weekday EQ THURSDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F' OnShift = 'C'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 4 OnShift = 'D'
End Case End Case
Case Weekday EQ FRIDAY$ Case Weekday EQ FRIDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 3 : @VM : 'M-F' OnShift = 'C'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
OnShift = 4 OnShift = 'D'
End Case End Case
Case Weekday EQ SATURDAY$ Case Weekday EQ SATURDAY$
Begin Case Begin Case
Case DayOrNight EQ 'Day' Case DayOrNight EQ 'Day'
OnShift = 3 OnShift = 'C'
Case DayOrNight EQ 'Night' Case DayOrNight EQ 'Night'
if ShiftTime LT 21600 then if ShiftTime LT 21600 then
OnShift = 4 OnShift = 'D'
end else end else
OnShift = 2 OnShift = 'B'
end end
End Case End Case
End Case End Case
@ -346,5 +350,3 @@ Service GetShiftByDate(Date, GenerateFlag)
end service end service

View File

@ -256,3 +256,4 @@ Do_Insert:
return return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
compile insert SHIFT_CALENDAR_EQUATES
/*----------------------------------------
Author : Table Create Insert Routine
Written : 03/10/2024
Description : Insert for Table SHIFT_CALENDAR
----------------------------------------*/
#ifndef __SHIFT_CALENDAR_EQUATES__
#define __SHIFT_CALENDAR_EQUATES__
equ SHIFT_CALENDAR.START_DTM$ to 1
equ SHIFT_CALENDAR.END_DTM$ to 2
equ SHIFT_CALENDAR.FISCAL_WEEK$ to 3
equ SHIFT_CALENDAR.FISCAL_MONTH$ to 4
equ SHIFT_CALENDAR.FISCAL_QUARTER$ to 5
#endif