Professional Documents
Culture Documents
entries?';
Text102@1101908003 : TextConst 'ENU=It was not possible to plan activities.';
ServLaborApplicationGlobTmp@1101901003 : TEMPORARY Record 25006277;
ServiceLine@1101908004 : TEMPORARY Record 25006146;
ReasonCodeGlobal@1190006 : Code[20];
SplitTracking@1101908005 : 'No,Yes,Undef';
Text103@1101908007 : TextConst 'ENU=Replan all entries after this event?';
AllocationStatus@1000 : 'Pending,In Process,Finished,On Hold';
AllocationStatusAction@1101904015 : 'Pending,In Process,Finish All,Finish
Part,On Hold';
ScheduleAction@1101908043 : 'Planning,Time Registration';
DoServiceSpliting@1101908009 : Boolean;
ChangeAllocationStatus@1101908011 : Boolean;
Text106@1101908014 : TextConst 'ENU=You have to finish labor in progress: %1
%2!';
Text107@1101908015 : TextConst 'ENU=Resource %1 have to start work time
first.';
Text108@1101908016 : TextConst 'ENU=You can start only service labors.';
PROCEDURE GetMatrixCellValue@1190000(ResourceNo@1190002 :
Code[20];StartingDateTime@1190001 : Decimal;EndingDateTime@1190000 :
Decimal;CellType@1190005 : 'Allocation,Capacity,Availability') CellValueText :
Text[250];
VAR
TempLaborAllocEntry@1190003 : TEMPORARY Record 25006271;
ServiceHour@1190006 : Record 25006129;
RecordCount@1190004 : Integer;
BEGIN
ServiceScheduleSetup.GET;
FillAllocEntryBuffer(TempLaborAllocEntry,ResourceNo,StartingDateTime,EndingDateTime
);
IF BufferContainsSelectedEntry(TempLaborAllocEntry) THEN
CellValueText := COPYSTR(CellValueText +
GetAllocRecDescr(TempLaborAllocEntry), 1, 250)
ELSE
BEGIN
RecordCount := 0;
TempLaborAllocEntry.RESET;
IF TempLaborAllocEntry.FINDFIRST THEN
REPEAT
RecordCount += 1;
IF RecordCount > 1 THEN
CellValueText := COPYSTR(CellValueText + '; ', 1, 250);
CellValueText := COPYSTR(CellValueText +
GetAllocRecDescr(TempLaborAllocEntry), 1, 250);
UNTIL (TempLaborAllocEntry.NEXT = 0) OR (RecordCount=3)
ELSE BEGIN
IF ServiceScheduleSetup."Show Unavailable Time" THEN
IF NOT GetTimeAvailable(ResourceNo, StartingDateTime,EndingDateTime)
THEN
CellValueText := Text001;
END;
END;
END;
IF CellType IN [CellType::Capacity, CellType::Availability] THEN BEGIN
IF CellType = CellType::Capacity THEN
CellValueText := FORMAT(ROUND(GetCapacity(ResourceNo, StartingDateTime,
EndingDateTime), 0.01)) + ' h'
ELSE
CellValueText := FORMAT(ROUND(GetCapacity(ResourceNo, StartingDateTime,
EndingDateTime) -
GetNotAvailabilityTime(TempLaborAllocEntry,
StartingDateTime, EndingDateTime), 0.01)) + ' h';
END;
EXIT;
END;
ResourceCodeBufferFilter.COPY(ResourceCodeBuffer);
ResourceCodeBuffer.RESET;
IF ResourceCodeBuffer.FINDFIRST THEN
REPEAT
IF ResourceCodeBuffer."Applies-to Code" = GroupCode THEN BEGIN
TempLaborAllocEntry.DELETEALL;
IF CellType IN [CellType::Allocation, CellType::Availability] THEN BEGIN
FillAllocEntryBuffer(TempLaborAllocEntry,ResourceCodeBuffer.Code,StartingDateTime,E
ndingDateTime);
AllocatedHours += GetNotAvailabilityTime(TempLaborAllocEntry,
StartingDateTime, EndingDateTime);
END;
IF CellType IN [CellType::Availability, CellType::Capacity] THEN
CapacityHours +=
GetCapacity(ResourceCodeBuffer.Code,StartingDateTime,EndingDateTime);
END;
UNTIL ResourceCodeBuffer.NEXT = 0;
ResourceCodeBuffer.COPY(ResourceCodeBufferFilter);
CASE CellType OF
CellType::Allocation:
BEGIN
CellValueText := FORMAT(ROUND(AllocatedHours,0.01)) + ' h';
//Temporary solution
IF AllocatedHours = 0 THEN
CellValueText := '';
END;
CellType::Capacity:
CellValueText := FORMAT(ROUND(CapacityHours, 0.01)) + ' h';
CellType::Availability:
IF CapacityHours - AllocatedHours < 0 THEN
CellValueText := FORMAT(0) + ' h'
ELSE
CellValueText := FORMAT(ROUND(CapacityHours - AllocatedHours,0.01)) + '
h';
END;
EXIT;
END;
PROCEDURE GetMatrixCellFormat@1190007(ResourceNo@1190002 :
Code[20];StartingDateTime@1190001 : Decimal;EndingDateTime@1190000 : Decimal;VAR
Bold@1190005 : Boolean;VAR ForeColor@1190006 : Integer) CellValueText : Text[250];
VAR
TempLaborAllocEntry@1190003 : TEMPORARY Record 25006271;
RecordCount@1190004 : Integer;
BEGIN
FillAllocEntryBuffer(TempLaborAllocEntry,ResourceNo,StartingDateTime,EndingDateTime
);
ForeColor := 0; //Black
BackColor := 16777215; //White
ColorConfig.RESET;
//ColorConfig.SETRANGE("Active Allocation", FALSE);
//ColorConfig.SETRANGE("Mixed Allocation", FALSE);
ColorConfig.SETRANGE(Status, LaborAllocEntry.Status);
PROCEDURE SelectAllocation@1190004(ResourceNo@1190002 :
Code[20];StartingDateTime@1190001 : Decimal;EndingDateTime@1190000 : Decimal);
VAR
TempLaborAllocEntry@1190003 : TEMPORARY Record 25006271;
RecordCount@1190004 : Integer;
BEGIN
IF NOT CheckUserRightsAdv(1, TempLaborAllocEntry) THEN EXIT;
ScheduleAction := ScheduleAction::Planning;
FillAllocEntryBuffer(TempLaborAllocEntry,ResourceNo,StartingDateTime,EndingDateTime
);
RecordCount := TempLaborAllocEntry.COUNT;
IF RecordCount = 0 THEN
EXIT;
//EntryNo := SingleInstanceMgt.GetAllocationEntryNo;
PROCEDURE DeallocateIncSplit@1101908009(EntryNo@1101908000 :
Integer;DeleteAll@1101908004 : Boolean);
VAR
LaborAllocEntryTemp@1101908001 : TEMPORARY Record 25006271;
LaborEntry@1101908003 : Integer;
ReplanOtherEntries@1101908002 : Boolean;
ProceedMode@1101904000 : Integer;
BEGIN
FindSplitEntries(EntryNo, LaborAllocEntryTemp, 0, 0); //15.08.2013 EDMS P8
LaborAllocEntryTemp.RESET;
LaborAllocEntryTemp.SETCURRENTKEY("Resource No.", "End Date-Time");
PROCEDURE MoveAllocation@1190014(EntryNo@1101904000 :
Integer;NewResourceNo@1190003 : Code[20];NewStartingDateTime@1190002 : Decimal);
VAR
ServiceLine@1101908000 : TEMPORARY Record 25006146;
ServiceLine2@1190001 : Record 25006146;
LaborAllocAppTemp@1190004 : TEMPORARY Record 25006277;
AllocationForm@1000 : Page 25006369;
BEGIN
CLEAR(AllocationForm);
IF NOT LaborAllocEntry.GET(EntryNo) THEN BEGIN
MESSAGE(Text121);
EXIT;
END;
IF NOT CheckUserRightsAdv(300, LaborAllocEntry) THEN EXIT;
AllocationForm.SetParam(EntryNo,NewResourceNo,NewStartingDateTime,LaborAllocEntry."
Quantity (Hours)",
LaborAllocEntry."Source Type",LaborAllocEntry."Source
Subtype",LaborAllocEntry."Source ID",1, ServiceLine,0);
AllocationForm.LOOKUPMODE(TRUE); //03.04.2013 P8
COMMIT; //28.06.2013 EDMS P8
AllocationForm.RUNMODAL;
END;
PROCEDURE StartEndAllocation@1101908002(AllocationStatus1@1101908002 :
'Pending,In Progress,Finish All,Finish Part,On Hold');
VAR
WorkTimeEntry@1101908004 : Record 25006276;
LaborAllocEntryTemp@1101908005 : TEMPORARY Record 25006271;
LaborAllocEntryLoc@1101908006 : Record 25006271;
CurrDateTime@1101908000 : Decimal;
HoldHours@1101908003 : Decimal;
StartFinishAllocation@1000 : Page 25006355;
BEGIN
CLEAR(StartFinishAllocation);
IF NOT LaborAllocEntry.GET(SingleInstanceMgt.GetAllocationEntryNo) THEN BEGIN
MESSAGE(Text121);
EXIT;
END;
IF NOT CheckUserRightsAdv(1, LaborAllocEntry) THEN EXIT;
StartFinishAllocation.SetParam(LaborAllocEntry."Resource
No.",CurrDateTime,LaborAllocEntry."Quantity (Hours)",
LaborAllocEntry."Source
Type",LaborAllocEntry."Source Subtype",LaborAllocEntry."Source ID",
AllocationStatus1, HoldHours);
StartFinishAllocation.LOOKUPMODE(TRUE); //03.04.2013 P8
COMMIT; //28.06.2013 EDMS P8
ResourceTimeRegMgt.AddTimeRegEntries('START',LaborAllocEntry,LaborAllocEntry."Resou
rce No.",WORKDATE,TIME);
END;
END;
PROCEDURE StartEndWorktime@1101908046(ResourceNo@1101908000 :
Code[20];Status@1101908001 : 'Start,End');
VAR
CurrDateTime@1101908003 : Decimal;
WorktimeRegistration@1000 : Page 25006353;
PageAction@1000000000 : Action;
BEGIN
IF NOT CheckUserRightsAdv(1, LaborAllocEntry) THEN EXIT;
PROCEDURE CalcEndDTOnlyWorktime@1000000000(StartDT@1000000001 :
Decimal;EndDT@1000000000 : Decimal;NewResNo@1000000007 : Code[20]) RetValue :
Decimal;
VAR
DateRec@1000000003 : Record 2000000007;
UnavailAllocEntry@1000000002 : TEMPORARY Record 25006271;
DateTimeMgt@1000000004 : Codeunit 25006012;
CurrDT@1000000005 : Decimal;
NewCurrDT@1000000006 : Decimal;
UnavailAllocEntryCount@1000000008 : Integer;
CurrRecIndex@1000000009 : Integer;
BEGIN
UnavailAllocEntry.RESET;
UnavailAllocEntry.DELETEALL;
RetValue := EndDT;
IF ServiceScheduleSetup."Show Unavailable Time" THEN BEGIN
DateRec.RESET;
DateRec.SETRANGE("Period Type",DateRec."Period Type"::Date);
DateRec.SETRANGE("Period
Start",DateTimeMgt.Datetime2Date(StartDT),DateTimeMgt.Datetime2Date(EndDT));
IF DateRec.FINDFIRST THEN REPEAT
FillUnavailableTimeEntries(UnavailAllocEntry,NewResNo,
DateRec."Period Start");
UNTIL DateRec.NEXT=0;
CurrDT := StartDT;
UnavailAllocEntryCount := UnavailAllocEntry.COUNT;
IF UnavailAllocEntryCount > 1 THEN BEGIN
CurrRecIndex := 1;
UnavailAllocEntry.FINDFIRST;
WHILE ((CurrDT<EndDT) AND (CurrRecIndex<=UnavailAllocEntryCount)) DO
BEGIN
IF (UnavailAllocEntry."Start Date-Time" <= CurrDT) AND (CurrDT <=
UnavailAllocEntry."End Date-Time") THEN BEGIN
IF (UnavailAllocEntry."End Date-Time" > EndDT) THEN BEGIN
NewCurrDT := EndDT;
END ELSE BEGIN
NewCurrDT := UnavailAllocEntry."End Date-Time";
END;
RetValue -= (NewCurrDT - CurrDT);
RetValue -= DateTimeMgt.Datetime(0D, 000000.001T); //minus one
millisecond
END ELSE BEGIN
IF (UnavailAllocEntry."Start Date-Time" >= CurrDT) AND (CurrDT <=
UnavailAllocEntry."End Date-Time") THEN BEGIN
IF (UnavailAllocEntry."Start Date-Time" >= EndDT) THEN BEGIN
NewCurrDT := EndDT;
END ELSE BEGIN
CurrDT := UnavailAllocEntry."Start Date-Time";
IF (UnavailAllocEntry."End Date-Time" > EndDT) THEN
NewCurrDT := EndDT
ELSE
NewCurrDT := UnavailAllocEntry."End Date-Time";
RetValue -= (NewCurrDT - CurrDT);
RetValue -= DateTimeMgt.Datetime(0D, 000000.001T); //minus one
millisecond
END;
END ELSE BEGIN
NewCurrDT := CurrDT;
RetValue -= 0;
END;
END;
CurrDT := NewCurrDT;
CurrRecIndex += 1;
UnavailAllocEntry.NEXT;
END;
END;
END;
EXIT(RetValue);
END;
PROCEDURE BreakAllocation@1101908043();
VAR
CurrDateTime@1101908001 : Decimal;
AllocationForm@1101904000 : Page 25006369;
BEGIN
CurrDateTime := DateTimeMgt.Datetime(WORKDATE, TIME);
AllocationForm.SetParam(LaborAllocEntry."Entry No.",
LaborAllocEntry."Resource No.", CurrDateTime,
LaborAllocEntry."Quantity (Hours)",
LaborAllocEntry."Source Type",LaborAllocEntry."Source
Subtype",LaborAllocEntry."Source ID",3, ServiceLine,0);
AllocationForm.LOOKUPMODE(TRUE); //03.04.2013 P8
COMMIT; //28.06.2013 EDMS P8
AllocationForm.RUNMODAL;
//END;//30.10.2012 EDMS
END;
PROCEDURE ProcessMovement@1190017(EntryNo@1101904000 :
Integer;NewResourceNo@1190005 : Code[20];NewStartingDateTime@1190004 :
Decimal;NewQtyToAllocate@1190003 : Decimal;SplitTracking1@1101908000 :
'No,Yes';NewStatus@1000 : 'Pending,In Process,Finished,On Hold';Operation@1001 :
Integer;Travel@25006000 : Boolean);
VAR
LaborAllocEntryTemp@1101908005 : TEMPORARY Record 25006271;
OldResourceNo@1101908002 : Code[20];
OldStartingDateTime@1101908001 : Decimal;
OldEndingDateTime@1101908003 : Decimal;
OldHours@1101908004 : Decimal;
DoReplan@1190001 : Boolean;
MainAllocEntrNo@1101904001 : Integer;
BEGIN
// Operation codes:
// -1 UNDEFINED
// 0 view; 1 - time registration; 2 - Planning; 3 - Reallocate (manager); 4 -
BREAK; 100 - allocate lines; 110 - allocate header; 120 - ALLOCATE standart event
// 200 - spliting
// 300 - move; 310 - change end time of finished
// 400 - delete entry
ScheduleAction := ScheduleAction::Planning;
SplitTracking := SplitTracking1;
LaborAllocEntry.GET(EntryNo);
IF Operation < 0 THEN
Operation := 300;
IF NOT CheckUserRightsAdv(Operation, LaborAllocEntry) THEN EXIT;
ServiceScheduleSetup.GET;
IF SplitAllocTracking(EntryNo, 0) THEN BEGIN
MainAllocEntrNo := GetMainAllocEntrNo(LaborAllocEntry."Entry No.", 1011);
//MESSAGE('msg in processmovement 01');
MovementIncSplit(EntryNo, NewResourceNo, NewStartingDateTime,
NewQtyToAllocate, NewStatus);
// in routine MovementIncSplit is deleted EntryNo, then need continue with
MainAllocEntrNo
EntryNo := MainAllocEntrNo;
END ELSE BEGIN
WriteAllocationEntries(NewResourceNo, NewStartingDateTime,
NewQtyToAllocate,
LaborAllocEntry."Source Type",
LaborAllocEntry."Source Subtype",
LaborAllocEntry."Source ID", 1, EntryNo, DoReplan,
NewStatus, FALSE,Travel);
PROCEDURE ProcessMovementApp@1101904025(VAR
ServLaborAllocApplicationPar@1101904001 : Record 25006277;EntryNo@1101904000 :
Integer;NewResourceNo@1190005 : Code[20];NewStartingDateTime@1190004 :
Decimal;NewQtyToAllocate@1190003 : Decimal;SplitTracking1@1101908000 : 'No,Yes')
MainAllocEntrNo : Integer;
VAR
LaborAllocEntryTemp@1101908005 : TEMPORARY Record 25006271;
OldResourceNo@1101908002 : Code[20];
OldStartingDateTime@1101908001 : Decimal;
OldEndingDateTime@1101908003 : Decimal;
OldHours@1101908004 : Decimal;
DoReplan@1190001 : Boolean;
ResourceTmp@1101904002 : TEMPORARY Record 156;
Resource@1101904003 : Record 156;
ServLaborAllocEntryTmp@1101904007 : TEMPORARY Record 25006271;
PreviousAllocEntryNo@1101904006 : Integer;
BEGIN
// at first create new entries
LaborAllocEntry.GET(EntryNo);
ResourceTmp.RESET;
ResourceTmp.DELETEALL;
WITH ServLaborAllocApplicationPar DO BEGIN
IF FINDFIRST THEN
REPEAT
//�eit vai nu ar setrange atrast vai t�ds jau exist�, vai pirms tam jau
padot ar� exist�jo�as rindas ar pareizu LineNo.
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Allocation Entry No.","Allocation Entry No.");
LaborAllocApp.SETRANGE("Document Type","Document Type");
LaborAllocApp.SETRANGE("Document No.","Document No.");
LaborAllocApp.SETRANGE("Document Line No.","Document Line No.");
LaborAllocApp.SETRANGE("Resource No.","Resource No.");
//IF NOT LaborAllocApp.GET("Allocation Entry No.", "Document Type",
"Document No.", "Document Line No.","Line No.") THEN BEGIN
IF NOT LaborAllocApp.FINDFIRST THEN BEGIN
IF NOT ResourceTmp.GET("Resource No.") THEN BEGIN
IF Resource.GET("Resource No.") THEN BEGIN
ResourceTmp := Resource;
ResourceTmp.INSERT;
END;
END;
END;
UNTIL NEXT = 0;
//'NewStartingDateTime:'+FORMAT(NewStartingDateTime)+',
NewQtyToAllocate:'+FORMAT(NewQtyToAllocate)); //
IF ResourceTmp.FINDFIRST THEN BEGIN
MainAllocEntrNo := GetMainAllocEntrNo(LaborAllocEntry."Entry No.", 1011);
FindSplitEntries(MainAllocEntrNo, ServLaborAllocEntryTmp, 0, 1111);
PreviousAllocEntryNo := 0;
REPEAT
ServLaborAllocEntryTmp.FINDFIRST;
REPEAT
PreviousAllocEntryNo :=
AddResourceToAllocEntry(ServLaborAllocEntryTmp, LaborAllocApp,
ResourceTmp."No.", PreviousAllocEntryNo, LaborAllocEntry,
LaborAllocApp);
UNTIL ServLaborAllocEntryTmp.NEXT = 0;
UNTIL ResourceTmp.NEXT = 0;
END;
END;
ProcessMovement(EntryNo, NewResourceNo, NewStartingDateTime,
NewQtyToAllocate, SplitTracking1, LaborAllocEntry.Status,
-1,LaborAllocEntry.Travel);
EXIT(MainAllocEntrNo);
END;
PROCEDURE MovementIncSplit@1101908011(EntryNo@1101908000 :
Integer;NewResourceNo@1101908001 : Code[20];NewStartingDateTime@1101908002 :
Decimal;NewQtyToAllocate@1101908003 : Decimal;NewStatus@1101904005 : Integer);
VAR
ServLaborAllocEntryTmp@1101908004 : TEMPORARY Record 25006271;
ServLaborAllocApplication@1101904001 : Record 25006277;
ServiceLineLoc@1101908009 : TEMPORARY Record 25006146;
NewSourceID@1101908007 : Code[20];
NewSourceType@1101908005 : ',Service Document,Standard Event';
NewSourceSubType@1101908006 : 'Qoute,Order';
NewTotalHours@1101908008 : Decimal;
DoReplan@1190000 : Boolean;
RecalcQtyToAllocate@1101904000 : Decimal;
QtyToMove@1101904002 : Decimal;
OldStartingDateTime@1101904003 : Decimal;
MainAllocEntrNo@1101904004 : Integer;
Travel@25006000 : Boolean;
BEGIN
ServiceScheduleSetup.GET;
LaborAllocEntry.GET(EntryNo);
Travel := LaborAllocEntry.Travel;
NewSourceType := LaborAllocEntry."Source Type";
NewSourceSubType := LaborAllocEntry."Source Subtype";
NewSourceID := LaborAllocEntry."Source ID";
//NewStatus := LaborAllocEntry.Status;
DoReplan := FALSE;
ServiceLineLoc.DELETEALL;
IF LaborAllocEntry."Source Type" = LaborAllocEntry."Source Type"::"Service
Document" THEN BEGIN
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Allocation Entry No.", LaborAllocEntry."Entry
No.");
IF LaborAllocApp.FINDFIRST THEN
REPEAT
FillServiceLine2(ServiceLineLoc, LaborAllocApp."Document Type",
LaborAllocApp."Document No.",
LaborAllocApp."Document Line No.");
UNTIL LaborAllocApp.NEXT = 0;
END;
RecalcQtyToAllocate := 0;
FindSplitEntries(EntryNo, ServLaborAllocEntryTmp, 0, 0); //15.08.2013 EDMS
P8
IF ServLaborAllocEntryTmp.FINDFIRST THEN BEGIN
REPEAT
IF ServLaborAllocEntryTmp."Entry No." = EntryNo THEN
RecalcQtyToAllocate += NewQtyToAllocate
ELSE
RecalcQtyToAllocate += ServLaborAllocEntryTmp."Quantity (Hours)";
UNTIL ServLaborAllocEntryTmp.NEXT = 0;
END;
DeallocateIncSplit(EntryNo, FALSE);
PROCEDURE AllocateStandardEvent@1190008(ResourceNo@1190002 :
Code[20];StartingDateTime@1190001 : Decimal;EndingDateTime@1190000 : Decimal);
VAR
StandardEvents@1190003 : Page 25006357;
StandardEvent@1190004 : Record 25006272;
ServLine@1190005 : Record 25006146;
CurrQtyToAllocate@1000 : Decimal;
ServiceScheduleMgt@1001 : Codeunit 25006201;
RoundMs@1002 : Integer;
BEGIN
//IF ServiceScheduleSetup."Allocation Time Step (Minutes)" > 0 THEN
// RoundMs := ServiceScheduleSetup."Allocation Time Step (Minutes)"
//ELSE
RoundMs := 60000;
CurrQtyToAllocate := ServiceScheduleMgt.CalcWorkHourDifference(ResourceNo,
StartingDateTime, EndingDateTime);
CurrQtyToAllocate := ServiceScheduleMgt.RoundQtyHours(CurrQtyToAllocate, 0);
IF NOT CheckUserRightsAdv(2, LaborAllocEntry) THEN EXIT;
CLEAR(StandardEvents);
StandardEvents.LOOKUPMODE(TRUE);
//Allocate(ResourceNo,StartingDateTime,0,2,0,StandardEvent.Code,ServLine,0);
Allocate(ResourceNo,StartingDateTime,CurrQtyToAllocate,2,0,StandardEvent.Code,ServL
ine,0);
END
ELSE
EXIT;
END;
PROCEDURE AllocateServiceLines@1190009(ResourceNo@1190004 :
Code[20];StartingDateTime@1190003 : Decimal;EndingDateTime@1190002 : Decimal);
VAR
ServiceLinesAllocation@1190000 : Page 25006354;
ServiceLine@1190001 : Record 25006146;
ServiceLine2@1190006 : Record 25006146;
ServiceHdr@1101908000 : Record 25006145;
WhatAllocation@1101908001 : 'Header,Line';
NewLineNo@1190005 : Integer;
CurrQtyToAllocate@1001 : Decimal;
ServiceScheduleMgt@1000 : Codeunit 25006201;
BEGIN
CurrQtyToAllocate := ServiceScheduleMgt.CalcWorkHourDifference(ResourceNo,
StartingDateTime, EndingDateTime);
CLEAR(ServiceLinesAllocation);
ServiceLinesAllocation.LOOKUPMODE(TRUE);
ServiceLine2.CLEARMARKS;
IF ServiceLine.FINDFIRST THEN
REPEAT
NewLineNo := ServiceLine."Line No.";
IF NOT CheckServiceLineResource(ServiceLine."Document Type",
ServiceLine."Document No.",
ServiceLine.Type, ServiceLine."Line No.", 1, ResourceNo) THEN BEGIN
IF CONFIRM(STRSUBSTNO(Text137, ServiceLine."No.")) THEN
NewLineNo := SplitServiceLine(ServiceLine."Document Type",
ServiceLine."Document No.", ServiceLine."Line No.");
END;
ServiceLine2.GET(ServiceLine."Document Type", ServiceLine."Document
No.", NewLineNo);
ServiceLine2.MARK(TRUE);
UNTIL ServiceLine.NEXT = 0;
COMMIT;
ServiceLine2.MARKEDONLY(TRUE);
IF ServiceLine2.FINDFIRST THEN
//Allocate(ResourceNo,StartingDateTime,0,1,ServiceLine2."Document
Type",ServiceLine2."Document No.",ServiceLine2,0);
Allocate(ResourceNo,StartingDateTime,CurrQtyToAllocate,1,ServiceLine2."Document
Type",ServiceLine2."Document No.",ServiceLine2,0);
END
ELSE
EXIT;
END;
PROCEDURE AllocateServiceOrder@1101908060(ResourceNo@1101908002 :
Code[20];StartingDateTime@1101908001 : Decimal;EndingDateTime@1101908000 :
Decimal);
VAR
ServiceHdrsAllocation@1101908004 : Page 25006356;
ServiceHdr@1101908003 : Record 25006145;
ServiceLineLoc@1101908005 : TEMPORARY Record 25006146;
WhatAllocation@1101908006 : 'Header,Line';
CurrQtyToAllocate@1001 : Decimal;
ServiceScheduleMgt@1000 : Codeunit 25006201;
BEGIN
CurrQtyToAllocate := ServiceScheduleMgt.CalcWorkHourDifference(ResourceNo,
StartingDateTime, EndingDateTime);
IF NOT CheckUserRightsAdv(110, LaborAllocEntry) THEN EXIT;
CLEAR(ServiceHdrsAllocation);
ServiceHdrsAllocation.LOOKUPMODE(TRUE);
Allocate(ResourceNo,StartingDateTime,CurrQtyToAllocate,1,ServiceHdr."Document
Type",ServiceHdr."No.",ServiceLine,0);
END
ELSE
EXIT;
END;
StandardEvents.LOOKUPMODE(TRUE);
AllocationForm.SetParam(ResourceNo,StartingDateTime,2,0,StandardEvent.Code);
AllocationForm.LOOKUPMODE(TRUE);
COMMIT; //28.06.2013 EDMS P8
AllocationForm.RUNMODAL;
END
ELSE
EXIT;
END;
PROCEDURE Allocate@1190015(ResourceNo@1190000 :
Code[20];StartingDateTime@1190001 : Decimal;QtyToAllocate@1190002 :
Decimal;SourceType@1190003 : ',Service Document,Standard
Event';SourceSubType@1190004 : 'Qoute,Order';SourceID@1190005 : Code[20];VAR
ServiceLine1@1190007 : Record 25006146;ForceStatus@25006000 : Integer) : Boolean;
VAR
AllocationForm@1190006 : Page 25006369;
LaborAllocAppTemp@1101904000 : TEMPORARY Record 25006277;
BEGIN
CLEAR(AllocationForm);
AllocationForm.SetParam(0,ResourceNo,StartingDateTime,QtyToAllocate,SourceType,Sour
ceSubType,SourceID,0, ServiceLine1,ForceStatus);
AllocationForm.SETTABLEVIEW := LaborAllocAppTemp;
AllocationForm.LOOKUPMODE(TRUE); //03.04.2013 P8
COMMIT; //28.06.2013 EDMS P8
AllocationForm.RUNMODAL;
END;
PROCEDURE AllocateNewVisitQuote@1101904042(ResourceNo@1101908002 :
Code[20];StartingDateTime@1101908001 : Decimal;EndingDateTime@1101908000 :
Decimal);
VAR
ServiceHdr@1101908003 : Record 25006145;
ServiceLineLoc@1101908005 : TEMPORARY Record 25006146;
WhatAllocation@1101908006 : 'Header,Line';
DocumentNo@1101904001 : Code[20];
DocumentType@1101904000 : 'Quote,Order,Return Order';
BEGIN
IF NOT CheckUserRightsAdv(110, LaborAllocEntry) THEN EXIT;
PROCEDURE AllocateNewVisitOrder@1101904037(ResourceNo@1101908002 :
Code[20];StartingDateTime@1101908001 : Decimal;EndingDateTime@1101908000 :
Decimal);
VAR
ServiceHdr@1101908003 : Record 25006145;
ServiceLineLoc@1101908005 : Record 25006146;
WhatAllocation@1101908006 : 'Header,Line';
DocumentNo@1101904001 : Code[20];
DocumentType@1101904000 : 'Quote,Order,Return Order';
BEGIN
IF NOT CheckUserRightsAdv(110, LaborAllocEntry) THEN EXIT;
PROCEDURE ProcessAllocation@1190016(ResourceNo@1190005 :
Code[20];StartingDateTime@1190004 : Decimal;QtyToAllocate@1190003 :
Decimal;SourceType@1190002 : ' ,Service Document,Standard
Event';SourceSubType@1190001 : 'Qoute,Order';SourceID@1190000 : Code[20];VAR
ServiceLine1@1101908011 : Record 25006146;DivideIntoLines@1101908001 :
Boolean;ForceStatus1@25006000 : 'Pending,In Progress,Finished,On
Hold,Cancelled';TravelPar@25006001 : Boolean);
VAR
ServiceLine2@1101908003 : TEMPORARY Record 25006146;
ServiceHours@1101908002 : Decimal;
QtyToAllocate2@1101908004 : Decimal;
JoinStartingDateTime@1101908006 : Decimal;
RecCount@1101908000 : Integer;
EntryNo@1101908005 : Integer;
DoReplan@1190006 : Boolean;
BEGIN
//21.11.2013 EDMS P8
CASE SourceType OF
SourceType::"Service Document":
BEGIN
IF ServiceLine1."Line No." > 0 THEN BEGIN
IF NOT CheckUserRightsAdv(100, LaborAllocEntry) THEN EXIT;
END ELSE
IF NOT CheckUserRightsAdv(110, LaborAllocEntry) THEN EXIT;
END;
SourceType::"Standard Event":
IF NOT CheckUserRightsAdv(120, LaborAllocEntry) THEN EXIT;
ELSE
IF NOT CheckUserRightsAdv(100, LaborAllocEntry) THEN EXIT;
END;
ServiceScheduleSetup.GET;
ScheduleAction := ScheduleAction::Planning;
DoReplan := TRUE;
JoinStartingDateTime := StartingDateTime;
IF NOT DivideIntoLines THEN BEGIN
FillServiceLine(ServiceLine1);
WriteAllocationEntries(ResourceNo, StartingDateTime, QtyToAllocate,
SourceType, SourceSubType, SourceID, 0, 0, DoReplan, ForceStatus1,
FALSE,TravelPar);
END ELSE BEGIN
RecCount := ServiceLine1.COUNT;
IF ServiceLine1.FINDFIRST THEN
REPEAT
ServiceHours += ServiceLine1.GetTimeQty;
UNTIL ServiceLine1.NEXT = 0;
EntryNo := 0;
IF ServiceLine1.FINDFIRST THEN
REPEAT
ServiceLine2.RESET;
ServiceLine2.DELETEALL;
IF ServiceLine1.Quantity <> 0 THEN BEGIN
ServiceLine2 := ServiceLine1;
ServiceLine2.INSERT;
FillServiceLine(ServiceLine2);
QtyToAllocate2 := ROUND((ServiceLine2.GetTimeQty / ServiceHours) *
QtyToAllocate, 0.001);
WriteAllocationEntries(ResourceNo, StartingDateTime, QtyToAllocate2,
SourceType, ServiceLine2."Document Type",
ServiceLine2."Document No.", 0, 0, DoReplan,
ForceStatus1, FALSE,TravelPar);
StartingDateTime := LaborAllocEntry."End Date-Time";
EntryNo := LaborAllocEntry."Entry No.";
END;
UNTIL ServiceLine1.NEXT = 0;
END;
PROCEDURE AllocationSpliting@1101908020(NewResourceNo@1101908001 :
Code[20];NewStartingDateTime@1101908000 : Decimal);
VAR
AllocationForm@1101908003 : Page 25006369;
ServiceLine@1101908002 : Record 25006146;
BEGIN
CLEAR(AllocationForm);
IF NOT LaborAllocEntry.GET(SingleInstanceMgt.GetAllocationEntryNo) THEN BEGIN
MESSAGE(Text121);
EXIT;
END;
IF NOT CheckUserRightsAdv(200, LaborAllocEntry) THEN EXIT;
AllocationForm.SetIsTravel(LaborAllocEntry.Travel);
AllocationForm.SetParam(0,NewResourceNo,NewStartingDateTime,LaborAllocEntry."Quanti
ty (Hours)",
LaborAllocEntry."Source Type",LaborAllocEntry."Source
Subtype",LaborAllocEntry."Source ID",2, ServiceLine,0);
AllocationForm.LOOKUPMODE(TRUE); //03.04.2013 P8
COMMIT; //28.06.2013 EDMS P8
AllocationForm.RUNMODAL;
END;
PROCEDURE ProcessSpliting@1101908021(NewResourceNo@1101908003 :
Code[20];NewStartingDateTime@1101908002 : Decimal;NewQtyToAllocate@1101908001 :
Decimal;SplitTracking1@1101908000 : 'No,Yes');
VAR
LaborAllocEntryTemp@1101908006 : TEMPORARY Record 25006271;
TotalHours@1101908007 : Decimal;
StartDateTime@1101908008 : Decimal;
EntryNo@1101908005 : Integer;
DoReplan@1101908004 : Boolean;
DifferentStatus@1101908009 : Boolean;
BEGIN
IF NewQtyToAllocate <= 0 THEN
EXIT;
ServiceScheduleSetup.GET;
ScheduleAction := ScheduleAction::Planning;
DoReplan := TRUE;
SplitTracking := SplitTracking1;
EntryNo := SingleInstanceMgt.GetAllocationEntryNo;
LaborAllocEntry.GET(EntryNo);
AllocationStatus := LaborAllocEntry.Status;
ChangeAllocationStatus := TRUE;
TotalHours := CalculateTotalHours(EntryNo);
FindSplitEntries(EntryNo, LaborAllocEntryTemp, 0, 1111);
LaborAllocEntryTemp.SETCURRENTKEY("Resource No.", "Start Date-Time");
IF LaborAllocEntryTemp.FINDFIRST THEN
StartDateTime := LaborAllocEntryTemp."Start Date-Time";
WriteAllocationEntries(NewResourceNo, NewStartingDateTime,
NewQtyToAllocate, //insert new entry
LaborAllocEntry."Source Type",
LaborAllocEntry."Source Subtype",
LaborAllocEntry."Source ID", 0, 0, DoReplan,
LaborAllocEntry.Status, FALSE,FALSE);
WriteAllocationEntries(NewResourceNo, NewStartingDateTime,
NewQtyToAllocate,
LaborAllocEntry."Source Type",
LaborAllocEntry."Source Subtype",
LaborAllocEntry."Source ID", 0, 0, DoReplan,
LaborAllocEntry.Status, FALSE,FALSE);
IF LaborAllocEntryTemp.FINDFIRST THEN
REPEAT
StatusChanged := FALSE;
IF LaborAllocEntryTemp."Entry No." <> EntryNo THEN BEGIN
ChangeServiceLineStatus(LaborAllocEntryTemp."Entry No.", FALSE);
StatusChanged := TRUE;
END;
UNTIL (LaborAllocEntryTemp.NEXT = 0) OR StatusChanged;
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Allocation Entry No.", EntryNo);
IF LaborAllocApp.FINDFIRST THEN
REPEAT
FillServiceLine2(ServiceLine, LaborAllocApp."Document Type",
LaborAllocApp."Document No.",
LaborAllocApp."Document Line No.");
UNTIL LaborAllocApp.NEXT = 0;
WriteAllocationEntries(NewResourceNo, NewStartingDateTime,
NewQtyToAllocate,
LaborAllocEntry."Source Type",
LaborAllocEntry."Source Subtype",
LaborAllocEntry."Source ID", 0, 0, DoReplan,
LaborAllocEntry.Status, FALSE,FALSE);
IF isGoingToReplan THEN
ReplanEntries(ResourceNo, EndingDateTime, -HourQty,
ServiceScheduleSetup."Replan Document", SourceSubType, SourceID);
IF isGoingToJoin THEN
IF ServiceScheduleSetup."Handle Linked Entries" <>
ServiceScheduleSetup."Handle Linked Entries"::No THEN
JoinAllocationEntries(ResourceNo, StartingDateTime);
END;
//LaborAllocEntry.RESET;
//IF LaborAllocEntry.FINDLAST THEN
//EntryNo := LaborAllocEntry."Entry No.";
LaborAllocEntry.RESET;
IF LaborAllocEntry.FINDLAST THEN
EntryNo := LaborAllocEntry."Entry No.";
IF LaborAllocEntryPar.FINDLAST THEN
IF LaborAllocEntryPar."Entry No." > EntryNo THEN
EntryNo := LaborAllocEntryPar."Entry No.";
EntryNo += 1;
ControlLaborSequence(ServiceLine."Document Type",
ServiceLine."Document No.", LineNo, StartingDateTime);
ControlSkills(ServiceLine."Document Type", ServiceLine."Document
No.", LineNo, ResourceNo);
InsertAllocApplication(LaborAllocAppPar, EntryNo,
ServiceLine."Document Type", ServiceLine."Document No.",
LineNo, ResourceNo,
DoChangeServLineResource,TravelPar);
UNTIL ServiceLine.NEXT = 0;
DoServiceSpliting := FALSE;
ServiceLine.RESET;
ServiceLine.DELETEALL;
END ELSE BEGIN
LaborAllocApp1.RESET;
LaborAllocApp1.SETRANGE("Allocation Entry No.",
LaborAllocEntryPar."Applies-to Entry No.");
IF LaborAllocApp1.FINDFIRST THEN
REPEAT
LineNo := LaborAllocApp1."Document Line No.";
ControlLaborSequence(LaborAllocApp1."Document Type",
LaborAllocApp1."Document No.", LineNo, StartingDateTime);
ControlSkills(LaborAllocApp1."Document Type",
LaborAllocApp1."Document No.", LineNo, ResourceNo);
InsertAllocApplication(LaborAllocAppPar, EntryNo,
LaborAllocApp1."Document Type", LaborAllocApp1."Document No.",
LineNo, ResourceNo,
DoChangeServLineResource,TravelPar);
UNTIL LaborAllocApp1.NEXT = 0;
END;
END ELSE BEGIN //09.04.2013 EDMS P8
//09.07.2013 EDMS P8 >>
IF ServiceLine.FINDFIRST AND (ApplyToEntry = 0) THEN BEGIN
REPEAT
LineNo := ServiceLine."Line No.";
IF DoServiceSpliting THEN
LineNo := SplitServiceLine(ServiceLine."Document Type",
ServiceLine."Document No.", ServiceLine."Line No.");
ControlLaborSequence(ServiceLine."Document Type",
ServiceLine."Document No.", LineNo, StartingDateTime);
ControlSkills(ServiceLine."Document Type", ServiceLine."Document
No.", LineNo, ResourceNo);
InsertAllocApplication(LaborAllocAppPar, EntryNo,
ServiceLine."Document Type", ServiceLine."Document No.",
LineNo, ResourceNo,
DoChangeServLineResource,TravelPar);
UNTIL ServiceLine.NEXT = 0;
DoServiceSpliting := FALSE;
ServiceLine.RESET;
ServiceLine.DELETEALL;
END ELSE BEGIN
//20.07.2013 EDMS P8 >>
IF ApplyToEntry = 0 THEN BEGIN
//InsertAllocApplication(LaborAllocApp, EntryNo, ServiceLine."Document
Type", ServiceLine."Document No.",
// LineNo, ResourceNo, DoChangeServLineResource);
InsertAllocApplication(LaborAllocAppPar, EntryNo, SourceSubType,
SourceID,
LineNo, ResourceNo,
DoChangeServLineResource,TravelPar);
END ELSE BEGIN
LaborAllocApp1.RESET;
LaborAllocApp1.SETRANGE("Allocation Entry No.",
LaborAllocEntryPar."Applies-to Entry No.");
IF LaborAllocApp1.FINDFIRST THEN
REPEAT
LineNo := LaborAllocApp1."Document Line No.";
ControlLaborSequence(LaborAllocApp1."Document Type",
LaborAllocApp1."Document No.", LineNo, StartingDateTime);
ControlSkills(LaborAllocApp1."Document Type",
LaborAllocApp1."Document No.", LineNo, ResourceNo);
InsertAllocApplication(LaborAllocAppPar, EntryNo,
LaborAllocApp1."Document Type", LaborAllocApp1."Document No.",
LineNo, ResourceNo,
DoChangeServLineResource,TravelPar);
UNTIL LaborAllocApp1.NEXT = 0;
END;
//20.07.2013 EDMS P8 <<
END;
//09.07.2013 EDMS P8 <<
END;
END;
LaborAllocAppLoc.RESET;
LaborAllocAppLoc.SETRANGE("Document Type", DocumentType);
LaborAllocAppLoc.SETRANGE("Document No.", DocumentNo);
LaborAllocAppLoc.SETRANGE("Document Line No.", LineNo);
// IF NOT LaborAllocAppLoc.FINDFIRST THEN BEGIN // P8
// IF LineNo = 0 THEN
// IF CONFIRM(Text145) THEN
// DocAllocAdjustDocLinesResource(DocumentType, DocumentNo, '');
//END;
UNTIL LaborAllocApp.NEXT = 0;
END;
LaborAllocApp.RESET;
IF LaborAllocApp.FINDLAST THEN
EntryNo := LaborAllocApp."Allocation Entry No.";
EntryNo += 1;
LaborAllocApp.INIT;
LaborAllocApp."Allocation Entry No." := AllocationEntry;
LaborAllocApp."Document Type" := DocumentType;
LaborAllocApp."Document No." := DocumentNo;
LaborAllocApp."Document Line No." := LineNo;
LaborAllocApp."Resource No." := ResourceNo;
LaborAllocApp.Travel := Travel;
IF IsTimeLine THEN BEGIN
LaborAllocApp."Time Line" := IsTimeLine;
LaborAllocApp."Remaining Quantity (Hours)" :=
LaborAllocEntryLocal."Quantity (Hours)";
END;
IF ResourceCost.GET(ResourceNo)
THEN //12.05.2015 EB.P30 #T030
LaborAllocApp.VALIDATE("Unit Cost", ResourceCost."Unit
Cost"); //12.05.2015 EB.P30 #T030
LaborAllocApp.INSERT(TRUE);
DateTimeMgt.Datetime(CurrentDay, 235959.999T));
InsertAllocationEntry(ServLaborAlloc, LaborAllocApp, ResourceNo,
DateTimeMgt.Datetime(CurrentDay,
ServiceHour."Ending Time"), QtyToAllocate, 0, 0, 'Err5', 0,
DoChangeServLineResource,FALSE);
END ELSE BEGIN
InsertAllocationEntry(ServLaborAlloc, LaborAllocApp, ResourceNo,
DateTimeMgt.Datetime(CurrentDay,
ServiceHour."Ending Time"), 0, 0, 0, 'Err5', 0,
DoChangeServLineResource,FALSE);
END;
END;
UNTIL ServiceHour.NEXT = 0;
END ELSE
EXIT(FALSE)
//21.02.2010 EDMSB P2 <<
END;
//AB <<
END;
// <<
EXIT(TRUE);
END;
PROCEDURE GetTimeAvailable@1190002(ResourceNo@1190000 :
Code[20];StartingDateTime@1190001 : Decimal;EndingDateTime@1190002 : Decimal) :
Boolean;
VAR
ServiceHour@1190005 : Record 25006129;
ResourceCalendarChange@1190004 : Record 25006279;
ResourceLoc@1190003 : Record 156;
CurrentDay@1190006 : Date;
BEGIN
CurrentDay := DateTimeMgt.Datetime2Date(StartingDateTime);
ServiceHour.RESET;
ServiceHour.SETRANGE("Service Work Group Code", ResourceLoc."Service Work
Group Code");
ServiceHour.SETFILTER("Starting Date", '''''|<=%1', CurrentDay);
ServiceHour.SETFILTER("Ending Date", '''''|>=%1', CurrentDay);
ServiceHour.SETRANGE(Day, DATE2DWY(CurrentDay, 1) - 1);
//18.01.2012 EDMS P8 >>
IF ServiceHour.FINDFIRST THEN BEGIN
REPEAT
IF (DateTimeMgt.Datetime2Time(StartingDateTime) <= ServiceHour."Ending
Time") AND
(DateTimeMgt.Datetime2Time(EndingDateTime) >= ServiceHour."Starting
Time")
THEN
EXIT(TRUE);
UNTIL ServiceHour.NEXT = 0;
EXIT(FALSE);
//18.01.2012 EDMS P8 <<
END;
EXIT(FALSE);
END;
PROCEDURE WriteAllocationEntries@1101908000(ResourceNo@1101908011 :
Code[20];StartingDateTime@1101908012 : Decimal;QtyToAllocate@1101908013 :
Decimal;SourceType@1101908014 : 'Service Document,,Standard
Event';SourceSubType@1101908015 : 'Qoute,Order';SourceID@1101908016 :
Code[20];FunctionMode@1101908017 : 'Insert,Modify';ModifyEntryNo@1101908018 :
Integer;DoReplan@1101908000 : Boolean;Status@1101904000 :
Integer;FirstRowMustTakeFromModify@1000 : Boolean;Travel@25006000 : Boolean);
VAR
ServLaborAlloc@1101908005 : Record 25006271;
ServLaborAllocTemp@1101908010 : TEMPORARY Record 25006271;
ServiceHour@1101908007 : Record 25006129;
RepairStatus@1101908006 : Record 25006166;
CurrentDay@1101908004 : Date;
StartTime@1101908003 : Time;
RetStartDateTime@1101908001 : Decimal;
ReplanHours@1101908002 : Decimal;
QtyToAllocate2@1101908022 : Decimal;
ApplyToEntry@1101908020 : Integer;
FirstEntry@1101908019 : Boolean;
DoChangeServLineResource@1101908008 : Boolean;
ChangeAllocationStatusLocal@1101908009 : Boolean;
DoOneServiceMoving@1101908021 : Boolean;
Allocations@25006001 : Page 25006362;
BEGIN
ServiceScheduleSetup.GET;
CurrentDay := DateTimeMgt.Datetime2Date(StartingDateTime);
StartTime := DateTimeMgt.Datetime2Time(StartingDateTime);
ChangeAllocationStatusLocal := ChangeAllocationStatus;
ChangeAllocationStatus := FALSE;
QtyToAllocate2 := QtyToAllocate;
AllocationStatus := Status; //20.07.2013 EDMS P8
//MESSAGE('AllocationStatus:'+FORMAT(AllocationStatus)+'
AllocationStatusAction: '+FORMAT(AllocationStatusAction)+' ScheduleAction:
'+FORMAT(ScheduleAction));
IF ServLaborAllocTemp.FINDFIRST THEN
REPEAT
//MESSAGE('msg in writeAlloc, 1');
IF FirstEntry AND (FunctionMode = FunctionMode::Modify) THEN BEGIN
IF ServLaborAlloc.GET(ModifyEntryNo) THEN;
IF LaborAllocEntry.GET(ModifyEntryNo) THEN;
IF DoReplan THEN BEGIN
ReplanHours := CheckForTime(ResourceNo, ServLaborAllocTemp."Start
Date-Time",
ServLaborAllocTemp."End Date-Time",
ModifyEntryNo, ServiceScheduleSetup."Replan Document",
SourceSubType, SourceID);
IF ReplanHours > 0 THEN
ReplanEntries(ResourceNo, ServLaborAllocTemp."Start Date-Time",
ReplanHours, ServiceScheduleSetup."Replan Document",
SourceSubType, SourceID)
ELSE BEGIN
ReplanHours := CalculateReplanHours(QtyToAllocate2,
ServLaborAlloc."Quantity (Hours)",
ServLaborAllocTemp."Start Date-
Time", ServLaborAlloc."Start Date-Time",
ServLaborAllocTemp."Resource
No.");
IF ReplanHours <> 0 THEN
ReplanEntries(ResourceNo, ServLaborAlloc."End Date-Time",
ReplanHours, ServiceScheduleSetup."Replan Document",
SourceSubType, SourceID);
END;
END;
ModifyAllocationEntry(LaborAllocEntry, LaborAllocApp, ModifyEntryNo,
ServLaborAllocTemp."Resource No.",
ServLaborAllocTemp."Start Date-Time",
ServLaborAllocTemp."Quantity (Hours)",
DoChangeServLineResource, Status,
ServLaborAllocTemp."Applies-to Entry No.",Travel);
END ELSE BEGIN
IF (NOT FirstEntry) THEN BEGIN
IF (ServiceScheduleSetup."Min. Notability (Hours)" >
ServLaborAllocTemp."Quantity (Hours)") THEN
EXIT;
IF GUIALLOWED THEN BEGIN // 11.12.2018 EB.P7
IF NOT CONFIRM(STRSUBSTNO(Text127, CurrentDay,
ServLaborAllocTemp."Quantity (Hours)")) THEN
EXIT; //Task: 004 25.09.2018 EB.P7
END;
//EXIT;
END;
END;
FirstEntry := FALSE;
ApplyToEntry := LaborAllocEntry."Entry No.";
UNTIL ServLaborAllocTemp.NEXT = 0;
END;
PROCEDURE CalculateReplanHours@1101908039(NewQty@1101908000 :
Decimal;OldQty@1101908001 : Decimal;NewStartDateTime@1101908002 :
Decimal;OldStartDateTime@1101908003 : Decimal;ResourceNo@1101908005 : Code[20]) :
Decimal;
VAR
ReplanHours@1101908004 : Decimal;
BEGIN
ReplanHours := 0;
ReplanHours := NewQty - OldQty;
IF NewStartDateTime <> OldStartDateTime THEN
ReplanHours += CalcWorkHourDifference(ResourceNo, OldStartDateTime,
NewStartDateTime);
EXIT(ReplanHours)
END;
PROCEDURE WriteAllocationEntryEnd@1101908029(EntryNo@1101908001 :
Integer;EndingDateTime@1101908007 : Decimal;DoReplan@1101908000 :
Boolean;ReasonCode@1101908004 : Code[10];Travel@25006000 : Boolean);
VAR
ReplanHours@1101908003 : Decimal;
DoOneServiceMoving@1101908002 : Boolean;
LaborAllocEntryTemp@1101904000 : TEMPORARY Record 25006271;
BEGIN
ServiceScheduleSetup.GET;
LaborAllocEntry.GET(EntryNo);
LaborAllocEntry.GET(EntryNo);
ChangeStatus(LaborAllocEntry);
ModifyAllocationEntry(LaborAllocEntry, LaborAllocApp, LaborAllocEntry."Entry
No.", LaborAllocEntry."Resource No.",
LaborAllocEntry."Start Date-Time",
CalcHourDifference(LaborAllocEntry."Start Date-Time",
EndingDateTime),
FALSE, -1, LaborAllocEntry."Applies-to Entry
No.",Travel);
SynchroniseRelatedEntries(LaborAllocEntry."Entry No.");
END;
IF ServLaborAllocTemp2.FINDFIRST THEN
REPEAT
IF (LastTime <> 0) AND (LastTime < ServLaborAllocTemp2."Start Date-
Time") AND (QtyToAllocate > 0) THEN BEGIN
IF QtyToAllocate > CalcHourDifference(LastTime,
ServLaborAllocTemp2."Start Date-Time") THEN
AllocateCurrentQty := CalcHourDifference(LastTime,
ServLaborAllocTemp2."Start Date-Time")
ELSE
AllocateCurrentQty := QtyToAllocate;
AllocateStartDateTime := LastTime;
InsertAllocationEntry(ServLaborAllocTemp, LaborAllocAppTemp,
ResourceNo, AllocateStartDateTime, AllocateCurrentQty,
0, 0, 'Err6', 0,
DoChangeServLineResource,FALSE);
QtyToAllocate -= AllocateCurrentQty;
END;
ServLaborAllocTemp2.RESET;
ServLaborAllocTemp2.DELETEALL;
CurrentDay := CurrentDay + 1;
StartTime := 000000T;
DayQty += 1;
QtyToAllocate := ROUND(QtyToAllocate, 0.00001);
UNTIL (QtyToAllocate <= 0) OR (DayQty > 1000); //12.12.2014 EB.P8
PROCEDURE ReturnAvailableTimesBackward@1101908013(VAR
ServLaborAllocTemp@1101908001 : TEMPORARY Record 25006271;VAR
QtyToAllocate@1101908007 : Decimal;ResourceNo@1101908002 :
Code[20];CurrentDay@1101908003 : Date;StartTime@1101908004 :
Time;ModifyEntryNo@1101908005 : Integer);
VAR
ServLaborAllocTemp2@1101908000 : TEMPORARY Record 25006271;
LaborAllocAppTemp@1101908009 : TEMPORARY Record 25006277;
LastTime@1101908006 : Decimal;
AllocateCurrentQty@1101908008 : Decimal;
AllocateStartDateTime@1101908010 : Decimal;
DayQty@1101908011 : Integer;
DoChangeServLineResource@1101908012 : Boolean;
BEGIN
DayQty := 0;
DoChangeServLineResource := FALSE;
REPEAT
IF IsTimeAvailable(ServLaborAllocTemp2, ResourceNo, CurrentDay,
ModifyEntryNo) THEN BEGIN
IsStarttimeAvailableBackward(ServLaborAllocTemp2, ResourceNo, CurrentDay,
StartTime);
ServLaborAllocTemp2.RESET;
ServLaborAllocTemp2.SETCURRENTKEY("Resource No.", "End Date-Time");
LastTime := 0;
IF ServLaborAllocTemp2.FINDLAST THEN
REPEAT
IF (LastTime <> 0) AND (LastTime > ServLaborAllocTemp2."End Date-
Time") AND (QtyToAllocate > 0) THEN BEGIN
IF QtyToAllocate > CalcHourDifference(ServLaborAllocTemp2."End
Date-Time", LastTime) THEN BEGIN
AllocateCurrentQty := CalcHourDifference(ServLaborAllocTemp2."End
Date-Time", LastTime);
AllocateStartDateTime := ServLaborAllocTemp2."End Date-Time";
END ELSE BEGIN
AllocateCurrentQty := QtyToAllocate;
AllocateStartDateTime := LastTime - QtyToAllocate*3.6;
END;
InsertAllocationEntry(ServLaborAllocTemp, LaborAllocAppTemp,
ResourceNo, AllocateStartDateTime, AllocateCurrentQty,
0, 0, 'Err7', 0,
DoChangeServLineResource,FALSE);
QtyToAllocate -= AllocateCurrentQty;
END;
ServLaborAllocTemp2.RESET;
ServLaborAllocTemp2.DELETEALL;
CurrentDay := CurrentDay - 1;
StartTime := 000000T;
DayQty += 1;
UNTIL (QtyToAllocate <= 0) OR (DayQty > 1000); //12.12.2014 EB.P8
PROCEDURE CalcHourDifference@1101907009(StartDateTime@1101907000 :
Decimal;EndDateTime@1101907001 : Decimal) : Decimal;
BEGIN
//Returns difference in hours
EXIT((EndDateTime - StartDateTime) / 3.6);
END;
PROCEDURE ChangeApplyTo@1101908019(ChangeFromEntry@1101908001 :
Integer;ChangeToEntry@1101908000 : Integer);
VAR
ServLaborAlloc@1101908002 : Record 25006271;
BEGIN
ServLaborAlloc.RESET;
ServLaborAlloc.SETCURRENTKEY("Applies-to Entry No.");
ServLaborAlloc.SETRANGE("Applies-to Entry No.", ChangeFromEntry);
ServLaborAlloc.SETFILTER("Entry No.", '<>%1', ChangeToEntry);
IF ServLaborAlloc.FINDFIRST THEN
REPEAT
ServLaborAlloc.VALIDATE("Applies-to Entry No.",
ChangeToEntry); //14.03.2014 Elva Baltic P8 #S0003 MMG7.00
ServLaborAlloc.MODIFY;
UNTIL ServLaborAlloc.NEXT = 0;
END;
PROCEDURE SplitAllocTracking@1101908008(EntryNo@1101908000 :
Integer;Mode@1101908001 : 'Move,Delete') : Boolean;
VAR
LaborAllocEntryTemp@1101908002 : TEMPORARY Record 25006271;
QuestionText@1101908003 : Text[200];
BEGIN
ServiceScheduleSetup.GET;
IF ServiceScheduleSetup."Handle Linked Entries" =
ServiceScheduleSetup."Handle Linked Entries"::No THEN
EXIT(FALSE);
EXIT(FALSE);
END;
EXIT(TotalHours);
END;
EXIT(TotalHours);
END;
PROCEDURE ReplanEntries@1101908012(ResourceNo@1101908000 :
Code[20];StartingDateTime@1101908001 : Decimal;ChangeHours@1101908011 :
Decimal;DoOneServiceMoving@1101908018 : Boolean;SourceSubType@1101908019 :
'Qoute,Order';SourceID@1101908020 : Code[20]);
VAR
LaborAllocEntry2@1101908005 : Record 25006271;
LaborAllocApp2@1101908004 : Record 25006277;
LaborAllocEntryTemp@1101908003 : TEMPORARY Record 25006271;
LaborAllocAppTemp@1101908002 : TEMPORARY Record 25006277;
ServiceLineTemp@1101908008 : TEMPORARY Record 25006146;
CurrentDay@1101908009 : Date;
StartTime@1101908010 : Time;
ApplyToEntry@1101908007 : Integer;
NewStartingDateTime@1101908012 : Decimal;
NewEndingDateTime@1101908014 : Decimal;
OldEndingTime@1101908013 : Decimal;
WorkHours@1101908015 : Decimal;
DoReplan@1101908017 : Boolean;
BEGIN
ServiceScheduleSetup.GET;
OldEndingTime := 0;
DoReplan := FALSE;
LaborAllocEntry2.RESET;
LaborAllocEntry2.SETRANGE("Resource No.", ResourceNo);
LaborAllocEntry2.SETFILTER("Start Date-Time", '>=%1', StartingDateTime);
LaborAllocEntry2.SETFILTER(Status, '%1|%2', LaborAllocEntry2.Status::Pending,
LaborAllocEntry2.Status::"On Hold");
LaborAllocEntry2.SETRANGE("Planning Policy", LaborAllocEntry2."Planning
Policy"::Queue);
IF LaborAllocEntry2.FINDFIRST THEN
REPEAT
LaborAllocEntryTemp := LaborAllocEntry2;
LaborAllocEntryTemp.INSERT;
UNTIL LaborAllocEntry2.NEXT = 0;
IF LaborAllocEntryTemp.FINDFIRST THEN
REPEAT
IF OldEndingTime <> 0 THEN BEGIN
WorkHours := CalcWorkHourDifference(ResourceNo, OldEndingTime,
LaborAllocEntryTemp."Start Date-Time");
IF WorkHours <> 0 THEN
NewStartingDateTime := CalculateNewStartDateTime(ResourceNo,
NewEndingDateTime, WorkHours)
ELSE
NewStartingDateTime := NewEndingDateTime;
END ELSE BEGIN
NewStartingDateTime := LaborAllocEntryTemp."Start Date-Time" +
ChangeHours * 3.6;
IF ChangeHours < 0 THEN BEGIN
WorkHours := CalcWorkHourDifference(ResourceNo, StartingDateTime,
LaborAllocEntryTemp."Start Date-Time");
NewStartingDateTime := StartingDateTime + (WorkHours + ChangeHours)*
3.6;
END;
END;
PROCEDURE CalcWorkHourDifference@1101908022(ResourceNo@1101908000 :
Code[20];FromDateTime@1101908001 : Decimal;ToDateTime@1101908002 : Decimal) :
Decimal;
VAR
ServLaborAllocTemp@1101908009 : TEMPORARY Record 25006271;
ServLaborAllocTemp2@1101908008 : TEMPORARY Record 25006271;
LaborAllocAppTemp@1101908007 : TEMPORARY Record 25006277;
CurrentDay@1101908012 : Date;
StartTime@1101908013 : Time;
LastTime@1101908006 : Decimal;
AllocateCurrentQty@1101908005 : Decimal;
AllocateStartDateTime@1101908004 : Decimal;
AllocateCurrentEndDateTime@1101908003 : Decimal;
WorkHours@1101908010 : Decimal;
FromDateTime2@1101908015 : Decimal;
CycleEnd@1101908011 : Boolean;
IsReverse@1101908014 : Boolean;
DoChangeServLineResource@1101908016 : Boolean;
BEGIN
IsReverse := FALSE;
IF FromDateTime > ToDateTime THEN BEGIN
FromDateTime2 := FromDateTime;
FromDateTime := ToDateTime;
ToDateTime := FromDateTime2;
IsReverse := TRUE;
END;
CurrentDay := DateTimeMgt.Datetime2Date(FromDateTime);
StartTime := DateTimeMgt.Datetime2Time(FromDateTime);
CycleEnd := FALSE;
DoChangeServLineResource := FALSE;
REPEAT
IF IsTimeAvailable(ServLaborAllocTemp2, ResourceNo, CurrentDay, 0) THEN
BEGIN
IsStarttimeAvailable(ServLaborAllocTemp2, ResourceNo, CurrentDay,
StartTime);
ServLaborAllocTemp2.RESET;
ServLaborAllocTemp2.SETCURRENTKEY("Resource No.", "Start Date-Time");
LastTime := 0;
IF ServLaborAllocTemp2.FINDFIRST THEN
REPEAT
IF (LastTime <> 0) AND (LastTime < ServLaborAllocTemp2."Start Date-
Time") THEN BEGIN
IF ToDateTime <= ServLaborAllocTemp2."Start Date-Time" THEN BEGIN
AllocateCurrentEndDateTime := ToDateTime;
CycleEnd := TRUE;
END ELSE
AllocateCurrentEndDateTime := ServLaborAllocTemp2."Start Date-
Time";
AllocateStartDateTime := LastTime;
AllocateCurrentQty := CalcHourDifference(AllocateStartDateTime,
AllocateCurrentEndDateTime);
InsertAllocationEntry(ServLaborAllocTemp, LaborAllocAppTemp,
ResourceNo, AllocateStartDateTime, AllocateCurrentQty,
0, 0, 'Err8', 0,
DoChangeServLineResource,FALSE);
END;
ServLaborAllocTemp2.SETFILTER("End Date-Time", '>%1',
ServLaborAllocTemp2."End Date-Time");
LastTime := ServLaborAllocTemp2."End Date-Time";
UNTIL (ServLaborAllocTemp2.NEXT = 0) OR CycleEnd;
END;
ServLaborAllocTemp2.RESET;
ServLaborAllocTemp2.DELETEALL;
CurrentDay := CurrentDay + 1;
StartTime := 000000T;
UNTIL CycleEnd OR (DateTimeMgt.Datetime(CurrentDay, StartTime) > ToDateTime);
WorkHours := 0;
ServLaborAllocTemp.RESET;
IF ServLaborAllocTemp.FINDFIRST THEN
REPEAT
WorkHours += ServLaborAllocTemp."Quantity (Hours)";
UNTIL ServLaborAllocTemp.NEXT = 0;
IF IsReverse THEN
EXIT(-WorkHours);
EXIT(WorkHours);
END;
PROCEDURE CalculateNewStartDateTime@1101908023(ResourceNo@1101908007 :
Code[20];StartingDateTime@1101908006 : Decimal;QtyToAllocate@1101908005 :
Decimal) : Decimal;
VAR
ServLaborAllocTemp@1101908000 : TEMPORARY Record 25006271;
CurrentDay@1101908001 : Date;
StartTime@1101908002 : Time;
BEGIN
CurrentDay := DateTimeMgt.Datetime2Date(StartingDateTime);
StartTime := DateTimeMgt.Datetime2Time(StartingDateTime);
ServLaborAllocTemp.RESET;
IF ServLaborAllocTemp.FINDLAST THEN
EXIT(ServLaborAllocTemp."End Date-Time")
ELSE
EXIT(0);
END;
PROCEDURE CheckForTime@1101908007(ResourceNo@1101908000 :
Code[20];StartingDateTime@1101908001 : Decimal;FinishingDateTime@1101908002 :
Decimal;EntryNo@1101908005 : Integer;DoOneServiceMoving@1101908008 :
Boolean;SourceSubType@1101908006 : 'Qoute,Order';SourceID@1101908007 : Code[20]) :
Decimal;
VAR
ServLaborAlloc@1101908003 : Record 25006271;
ContinueStartingDateTime@1101908004 : Decimal;
BEGIN
ContinueStartingDateTime := FinishingDateTime;
ServLaborAlloc.RESET;
ServLaborAlloc.SETRANGE("Resource No.", ResourceNo);
ServLaborAlloc.SETRANGE("Start Date-Time", StartingDateTime,
FinishingDateTime - 0.00001);
IF EntryNo <> 0 THEN
ServLaborAlloc.SETFILTER("Entry No.", '<>%1', EntryNo);
ServLaborAlloc.SETCURRENTKEY("Resource No.", "Start Date-Time");
IF ServLaborAlloc.FINDFIRST THEN
ContinueStartingDateTime := ServLaborAlloc."Start Date-Time";
EXIT(CalcHourDifference(ContinueStartingDateTime, FinishingDateTime));
END;
PROCEDURE SplitServiceLine@1101908024(DocumentType@1101908007 :
'Quote,Order,Invoice,Credit Memo,Blanket Order,Return
Order';DocumentNo@1101908006 : Code[20];LineNo@1101908005 : Integer) : Integer;
VAR
ServiceLineLoc@1101908002 : Record 25006146;
NewLineNo@1101908003 : Integer;
BEGIN
IF ServiceLineLoc.GET(DocumentType, DocumentNo, LineNo) THEN
NewLineNo := DocumentMgt.ServiceSplitLine(ServiceLineLoc, 2)
ELSE
NewLineNo := LineNo;
EXIT(NewLineNo)
END;
ChangeAllocationStatus := TRUE;
AllocationStatus := AllocationStatus::"In Process";
AskedForAllocationSpliting := TRUE;
//DoReplan := FALSE; // P8 old
DoReplan := TRUE; // P8 new version
//P8 >>
IF Resource."No." <> '' THEN
//THAT COLD BE FILLED IN CompareSchedulePassword from P25006355
ResourceNo := Resource."No." //17.10.2013 EDMS P8
ELSE
ResourceNo := LaborAllocEntry."Resource No.";
SingleInstanceMgt.SetDateFilter(DateTimeMgt.Datetime2Date(StartingDateTime));
OnDate := DateTimeMgt.Datetime2Date(StartingDateTime);
OnTime := DateTimeMgt.Datetime2Time(StartingDateTime);
ResourceTimeRegMgt.FinishDefaultIdleTask(ResourceNo,OnDate,OnTime);
EntryNo := SingleInstanceMgt.GetAllocationEntryNo;
LaborAllocEntry.GET(EntryNo);
Travel := LaborAllocEntry.Travel;
CASE AllocationStatus1 OF
AllocationStatus1::Pending:
AllocationStatus := AllocationStatus::Pending;
AllocationStatus1::"In Process":
AllocationStatus := AllocationStatus::"In Process";
AllocationStatus1::"Finish All", AllocationStatus1::"Finish Part":
AllocationStatus := AllocationStatus::Finished;
AllocationStatus1::"On Hold":
AllocationStatus := AllocationStatus::"On Hold";
END;
ChangeAllocationStatus := TRUE;
AllocationStatus := AllocationStatus::"On Hold";
ReasonCodeGlobal := ReasonCode;
IF HoldHours > 0 THEN
WriteAllocationEntries(LaborAllocEntry."Resource No.",
LaborAllocEntry."End Date-Time", HoldHours,
LaborAllocEntry."Source Type",
LaborAllocEntry."Source Subtype",
// LaborAllocEntry."Source ID", 0, 0, DoReplan,
AllocationStatus, TRUE); //20.07.2013 EDMS P8
// LaborAllocEntry."Source ID", 0,
LaborAllocEntry."Entry No.", DoReplan, AllocationStatus, FALSE); //20.07.2013 EDMS
P8
LaborAllocEntry."Source ID", 0,
LaborAllocEntry."Entry No.", DoReplan, AllocationStatus,
TRUE,Travel); //15.08.2013 EDMS P8
END;
OnDate := DateTimeMgt.Datetime2Date(EndingDateTime);
OnTime := DateTimeMgt.Datetime2Time(EndingDateTime);
IF NOT ResourceTimeRegMgt.HasTasksInProgress(LaborAllocEntry."Resource No.")
THEN
ResourceTimeRegMgt.StartDefaultIdleTask(LaborAllocEntry."Resource
No.",OnDate,OnTime);
END;
PROCEDURE ProcessBreak@1101908041(StandardCode@1101908004 :
Code[20];ReasonCode@1101908006 : Code[10];BreakHours@1101908005 : Decimal);
VAR
LaborAllocEntry2@1101908003 : Record 25006271;
LaborAllocEntry3@25006000 : Record 25006271;
ServStandardEvent@1000 : Record 25006272;
CurrDateTime@1101908000 : Decimal;
FinishedHours@1101908001 : Decimal;
HoldHours@1101908002 : Decimal;
DoReplan@1190000 : Boolean;
Travel@25006001 : Boolean;
BEGIN
ScheduleAction := ScheduleAction::"Time Registration";
ServiceScheduleSetup.GET;
ServStandardEvent.GET(StandardCode); //12.08.2013 EDMS P8
AllocationStatus := AllocationStatus::Finished;
WriteAllocationEntryEnd(SingleInstanceMgt.GetAllocationEntryNo, CurrDateTime,
DoReplan, ReasonCode,Travel);
AllocationStatus := AllocationStatus::Pending;
WriteAllocationEntries(LaborAllocEntry2."Resource No.", CurrDateTime,
BreakHours, 2, 0, StandardCode, 0, 0, DoReplan, 0, FALSE,Travel);
ChangeAllocationStatus := TRUE;
AllocationStatus := AllocationStatus::"On Hold";
WriteAllocationEntries(LaborAllocEntry2."Resource No.", LaborAllocEntry."End
Date-Time", HoldHours,
LaborAllocEntry2."Source Type",
LaborAllocEntry2."Source Subtype",
LaborAllocEntry2."Source ID", 0,
SingleInstanceMgt.GetAllocationEntryNo, DoReplan, -1, FALSE,Travel);
END;
ChangeServiceLineStatus(EntryNo,FALSE);
OnDate := DateTimeMgt.Datetime2Date(CurrentDateTime);
OnTime := DateTimeMgt.Datetime2Time(CurrentDateTime);
IF NOT ResourceTimeRegMgt.HasTasksInProgress(LaborAllocEntryTmp."Resource
No.") THEN
ResourceTimeRegMgt.StartDefaultIdleTask(LaborAllocEntryTmp."Resource
No.",OnDate,OnTime);
}
ServiceScheduleSetup.GET;
ScheduleAction := ScheduleAction::"Time Registration";
EntryNo := SingleInstanceMgt.GetAllocationEntryNo;
LaborAllocEntry.GET(EntryNo);
Travel := LaborAllocEntry.Travel;
ChangeAllocationStatus := TRUE;
AllocationStatus := AllocationStatus::"On Hold";
AskedForAllocationSpliting := TRUE;
DoReplan := TRUE;
IF Resource."No." <> '' THEN
ResourceNo := Resource."No."
ELSE
ResourceNo := LaborAllocEntry."Resource No.";
SingleInstanceMgt.SetDateFilter(DateTimeMgt.Datetime2Date(CurrentDateTime));
OnDate := DateTimeMgt.Datetime2Date(CurrentDateTime);
OnTime := DateTimeMgt.Datetime2Time(CurrentDateTime);
//ResourceTimeRegMgt.FinishDefaultIdleTask(ResourceNo,OnDate,OnTime);
PROCEDURE ChangeServiceLineStatus@1101908026(EntryNo@1101908001 :
Integer;Remove@1190000 : Boolean);
VAR
ServiceHdr@1190002 : Record 25006145;
ServiceLine@1101908000 : Record 25006146;
ServiceLineTemp@1190007 : TEMPORARY Record 25006146;
PostedServiceHdr@1190003 : Record 25006149;
PostedServiceLine@1190004 : Record 25006150;
PostedServRetHdr@1190005 : Record 25006154;
PostedServRetLine@1190006 : Record 25006155;
LaborAllocEntry@1101908003 : Record 25006271;
LaborAllocApp@1101908002 : Record 25006277;
LaborAllocApp2@1101908004 : Record 25006277;
WorkStatus@1101908006 : Record 25006166;
CurrStatus@1101908005 : Integer;
WorkStatusCode@1190001 : Code[10];
Resource@1101904000 : Record 156;
BEGIN
LaborAllocEntry.GET(EntryNo);
IF LaborAllocEntry."Source Type" <> LaborAllocEntry."Source Type"::"Service
Document" THEN
EXIT;
IF DontChangeServiceStatus THEN
EXIT;
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Allocation Entry No.", EntryNo);
IF LaborAllocApp.FINDFIRST THEN
REPEAT
CurrStatus := 999999;
WorkStatusCode := '';
LaborAllocApp2.RESET;
LaborAllocApp2.SETRANGE("Document Type", LaborAllocApp."Document Type");
LaborAllocApp2.SETRANGE("Document No.", LaborAllocApp."Document No.");
IF LaborAllocApp."Document Line No." <> 0 THEN BEGIN
LaborAllocApp2.SETRANGE("Document Line No.", LaborAllocApp."Document
Line No.");
IF Remove THEN
LaborAllocApp2.SETFILTER("Allocation Entry No.", '<>%1', EntryNo);
IF LaborAllocApp2.FINDFIRST THEN
REPEAT
Resource.GET(LaborAllocApp2."Resource No.");
IF NOT (ServiceScheduleSetup."Only Pers. Affect Doc. Status" AND
(Resource.Type = Resource.Type::Machine)) THEN BEGIN
IF LaborAllocEntry.GET(LaborAllocApp2."Allocation Entry No.")
THEN BEGIN
WorkStatus.RESET;
WorkStatus.SETRANGE("Service Order Status",
LaborAllocEntry.Status);
IF WorkStatus.FINDFIRST THEN;
ServiceLine.RESET;
ServiceLine.SETRANGE("Document Type", ServiceLine."Document Type"::Order);
ServiceLine.SETRANGE("Document No.", ServiceHeader."No.");
ServiceLine.SETRANGE(Type, ServiceLine.Type::Labor);
IF ServiceLine.FINDFIRST THEN
REPEAT
IF ServiceWorkStatus.GET(ServiceLine.Status) THEN BEGIN
IF ServiceWorkStatus.Priority < LowestStatus THEN BEGIN
LowestStatus := ServiceWorkStatus.Priority;
StatusCode := ServiceWorkStatus.Code;
END;
END;
UNTIL ServiceLine.NEXT = 0;
ServiceLine.RESET;
ServiceLine.SETRANGE("Document Type", ServiceHeader."Document Type");
ServiceLine.SETRANGE("Document No.", ServiceHeader."No.");
ServiceLine.SETRANGE(Type, ServiceLine.Type::Labor);
IF ServiceLine.FINDFIRST THEN
REPEAT
IF ServiceWorkStatus.GET(ServiceLine.Status) THEN BEGIN
IF ServiceWorkStatus.Priority < LowestStatus THEN BEGIN
LowestStatus := ServiceWorkStatus.Priority;
StatusCode := ServiceWorkStatus.Code;
END;
END;
UNTIL ServiceLine.NEXT = 0;
PROCEDURE ProcessStartWorkday@1101908030(ResourceNo@1101908002 :
Code[20];StartDateTime@1101908003 : Decimal);
VAR
WorkTimeEntry@1101908001 : Record 25006276;
EntryNo@1101908000 : Integer;
ServLaborAllocationEntry@25006000 : Record 25006271;
OnDate@25006001 : Date;
OnTime@25006002 : Time;
BEGIN
ScheduleAction := ScheduleAction::"Time Registration";
WorkTimeEntry.RESET;
WorkTimeEntry.SETRANGE("Resource No.", ResourceNo);
WorkTimeEntry.SETRANGE(Closed, FALSE);
IF WorkTimeEntry.FINDFIRST THEN BEGIN
MESSAGE(STRSUBSTNO(Text120, ResourceNo));
EXIT;
END;
WorkTimeEntry.RESET;
IF WorkTimeEntry.FINDLAST THEN
EntryNo := WorkTimeEntry."Entry No." + 1
ELSE
EntryNo := 1;
WorkTimeEntry.INIT;
WorkTimeEntry."Entry No." := EntryNo;
WorkTimeEntry.VALIDATE("Resource No.", ResourceNo);
WorkTimeEntry.VALIDATE("Worktime Begin", StartDateTime);
WorkTimeEntry.INSERT(TRUE);
OnDate := DateTimeMgt.Datetime2Date(StartDateTime);
OnTime := DateTimeMgt.Datetime2Time(StartDateTime);
ResourceTimeRegMgt.AddWorkTimeRegEntries('STARTWORKTIME',ResourceNo,OnDate,OnTime);
ResourceTimeRegMgt.StartDefaultIdleTask(ResourceNo,OnDate,OnTime);
END;
PROCEDURE ProcessEndWorkday@1101908031(ResourceNo@1101908004 :
Code[20];EndDateTime@1101908000 : Decimal);
VAR
WorkTimeEntry@1101908003 : Record 25006276;
ServLaborAllocationEntryL@1000 : Record 25006271;
DoReplan@1101908001 : Boolean;
ResourceTimeRegMgt@25006000 : Codeunit 25006290;
ServiceSetup@25006001 : Record 25006120;
ServStandardEvent@25006002 : Record 25006272;
OnDate@25006003 : Date;
OnTime@25006004 : Time;
BEGIN
ServiceSetup.GET;
ScheduleAction := ScheduleAction::"Time Registration";
DoReplan := FALSE;
OnDate := DateTimeMgt.Datetime2Date(EndDateTime);
OnTime := DateTimeMgt.Datetime2Time(EndDateTime);
ResourceTimeRegMgt.AddTimeRegEntries('Complete',ServLaborAllocationEntryL,ServLabor
AllocationEntryL."Resource No.",OnDate,OnTime);
UNTIL NEXT = 0
ELSE
ERROR(STRSUBSTNO(Text106, "Source Subtype", "Source ID"));
END ELSE
ERROR(STRSUBSTNO(Text106, "Source Subtype", "Source ID"));
END;
END;
WorkTimeEntry.SETCURRENTKEY("Resource No.",Closed);
WorkTimeEntry.SETRANGE("Resource No.",ResourceNo);
WorkTimeEntry.SETRANGE(Closed,FALSE);
IF NOT WorkTimeEntry.FINDLAST THEN BEGIN
MESSAGE(STRSUBSTNO(Text119, ResourceNo));
EXIT;
END;
ResourceTimeRegMgt.FinishDefaultIdleTask(ResourceNo,OnDate,OnTime);
ResourceTimeRegMgt.AddWorkTimeRegEntries('FINISHWORKTIME',ResourceNo,OnDate,OnTime)
;
END;
PROCEDURE ProcessStartWorkdaySilent@25006003(ResourceNo@1101908002 :
Code[20];StartDateTime@1101908003 : Decimal);
VAR
WorkTimeEntry@1101908001 : Record 25006276;
EntryNo@1101908000 : Integer;
ServLaborAllocationEntry@25006000 : Record 25006271;
OnDate@25006001 : Date;
OnTime@25006002 : Time;
BEGIN
OnDate := DateTimeMgt.Datetime2Date(StartDateTime);
OnTime := DateTimeMgt.Datetime2Time(StartDateTime);
WorkTimeEntry.INIT;
WorkTimeEntry."Entry No." := EntryNo;
WorkTimeEntry.VALIDATE("Resource No.", ResourceNo);
WorkTimeEntry.VALIDATE("Worktime Begin", StartDateTime);
WorkTimeEntry.INSERT(TRUE);
ResourceTimeRegMgt.AddWorkTimeRegEntries('STARTWORKTIME',ResourceNo,OnDate,OnTime);
END;
END;
PROCEDURE CompareSchedulePassword@1101908028(ResourceNo@1101908001 :
Code[20];SchedulePassword@1101908002 : Text[20]);
BEGIN
IF Resource.GET(ResourceNo) THEN
IF Resource."Serv. Schedule Password" = SchedulePassword THEN
EXIT;
ERROR(Text112);
END;
IF ScheduleCellConfig.FINDFIRST THEN
REPEAT
CASE ScheduleCellConfig."Source Type" OF
DATABASE::"Service Header EDMS" :
BEGIN
RecordRef.OPEN(DATABASE::"Service Header EDMS");
RecordRef.GETTABLE(ServHdr);
END;
DATABASE::"Service Line EDMS" :
BEGIN
RecordRef.OPEN(DATABASE::"Service Line EDMS");
RecordRef.GETTABLE(ServLine);
END;
DATABASE::"Posted Serv. Order Header" :
BEGIN
RecordRef.OPEN(DATABASE::"Service Header EDMS");
RecordRef.GETTABLE(PostedServHdr);
END;
DATABASE::"Posted Serv. Order Line" :
BEGIN
RecordRef.OPEN(DATABASE::"Service Line EDMS");
RecordRef.GETTABLE(PostedServLine);
END;
DATABASE::"Serv. Standard Event" :
BEGIN
RecordRef.OPEN(DATABASE::"Serv. Standard Event");
RecordRef.GETTABLE(StandardEvent);
END;
//24.10.2013 EDMS P8 >>
DATABASE::"Serv. Allocation Description" :
BEGIN
RecordRef.OPEN(DATABASE::"Serv. Allocation Description");
RecordRef.GETTABLE(ServLaborAllocationDetailLoc);
END;
//24.10.2013 EDMS P8 <<
END;
FieldValue := FORMAT(FieldRef.VALUE);
FieldOption := FieldRef.OPTIONCAPTION;
EXIT(EndText);
END;
PROCEDURE CreateNewServiceDocument@1101908038(DocumentType@1190000 :
'Quote,Order,Return Order') : Code[20];
VAR
ServHeader@1101908000 : Record 25006145;
BEGIN
CLEAR(ServHeader);
ServHeader.INIT;
ServHeader."Document Type" := DocumentType;
ServHeader.INSERT(TRUE);
COMMIT;
CASE DocumentType OF
DocumentType::Quote:
PAGE.RUNMODAL(PAGE::"Service Quote EDMS", ServHeader);
DocumentType::Order:
PAGE.RUNMODAL(PAGE::"Service Order EDMS", ServHeader);
END;
EXIT(ServHeader."No.");
END;
LaborAllocApp.RESET;
LaborAllocEntry.RESET;
LaborAllocApp.SETRANGE("Document Type", ServLine."Document Type");
LaborAllocApp.SETRANGE("Document No.", ServLine."Document No.");
LaborAllocApp.SETRANGE("Document Line No.", ServLine."Line No.");
IF LaborAllocApp.FINDFIRST THEN BEGIN
IF GUIALLOWED THEN
IF NOT CONFIRM(Text117) THEN
ERROR(Text118);
REPEAT
IF LaborAllocEntry.GET(LaborAllocApp."Allocation Entry No.") THEN
IF LaborAllocEntry.Status = LaborAllocEntry.Status::Finished THEN
ERROR(Text116);
LaborAllocAppTemp := LaborAllocApp;
LaborAllocAppTemp.INSERT;
UNTIL LaborAllocApp.NEXT = 0;
END;
ServiceScheduleSetup.GET;
LaborAllocApp.LOCKTABLE;
LaborAllocEntry.LOCKTABLE;
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Document Type", ServiceLine."Document Type");
LaborAllocApp.SETRANGE("Document No.", ServiceLine."Document No.");
LaborAllocApp.SETRANGE("Document Line No.", ServiceLine."Line No.");
IF NOT LaborAllocApp.FINDFIRST THEN
EXIT
ELSE
REPEAT
IF LaborAllocEntry.GET(LaborAllocApp."Allocation Entry No.") THEN BEGIN
IF (LaborAllocEntry.Status <> LaborAllocEntry.Status::Finished) AND
ServiceScheduleSetup."Post Only When Finished" THEN
ERROR(STRSUBSTNO(Text115, ServiceLine."Line No."));
LaborAllocEntryTemp := LaborAllocEntry;
IF LaborAllocEntryTemp.INSERT THEN;
END;
LaborAllocAppTemp := LaborAllocApp;
LaborAllocAppTemp.INSERT;
UNTIL LaborAllocApp.NEXT = 0;
IF LaborAllocAppTemp.FINDFIRST THEN
REPEAT
LaborAllocApp.GET(LaborAllocAppTemp."Allocation Entry No.",
LaborAllocAppTemp."Document Type",
LaborAllocAppTemp."Document No.",
LaborAllocAppTemp."Document Line No.", LaborAllocAppTemp."Line No.");
LaborAllocApp.DELETE(TRUE);
UNTIL LaborAllocAppTemp.NEXT = 0;
IF LaborAllocEntryTemp.FINDFIRST THEN
REPEAT
IF LaborAllocEntry.GET(LaborAllocEntryTemp."Entry No.") THEN
LaborAllocEntry.DELETE;
UNTIL LaborAllocEntryTemp.NEXT = 0;
IF LaborAllocEntryTemp.FINDFIRST THEN
REPEAT
LaborAllocEntry.TRANSFERFIELDS(LaborAllocEntryTemp);
LaborAllocEntry."Source ID" := NewOrderNo;
LaborAllocEntry.INSERT;
UNTIL LaborAllocEntryTemp.NEXT = 0;
IF LaborAllocAppTemp.FINDFIRST THEN
REPEAT
LaborAllocApp.TRANSFERFIELDS(LaborAllocAppTemp);
LaborAllocApp."Document No." := NewOrderNo;
LaborAllocApp.Posted := TRUE;
LaborAllocApp.INSERT(TRUE);
UNTIL LaborAllocAppTemp.NEXT = 0;
END;
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Document Type", ServiceHdr."Document Type");
LaborAllocApp.SETRANGE("Document No.", ServiceHdr."No.");
LaborAllocApp.SETRANGE("Document Line No.", 0);
IF NOT LaborAllocApp.FINDFIRST THEN
EXIT
ELSE
REPEAT
IF LaborAllocEntry.GET(LaborAllocApp."Allocation Entry No.") THEN BEGIN
IF (LaborAllocEntry.Status <> LaborAllocEntry.Status::Finished) AND
ServiceScheduleSetup."Post Only When Finished" THEN
ERROR(STRSUBSTNO(Text141, ServiceHdr."No."));
LaborAllocEntryTemp := LaborAllocEntry;
IF LaborAllocEntryTemp.INSERT THEN;
END;
LaborAllocAppTemp := LaborAllocApp;
LaborAllocAppTemp.INSERT;
UNTIL LaborAllocApp.NEXT = 0;
IF LaborAllocAppTemp.FINDFIRST THEN
REPEAT
LaborAllocApp.GET(LaborAllocAppTemp."Allocation Entry No.",
LaborAllocAppTemp."Document Type",
LaborAllocAppTemp."Document No.",
LaborAllocAppTemp."Document Line No.",
LaborAllocAppTemp."Line No.");
LaborAllocApp.DELETE(TRUE);
UNTIL LaborAllocAppTemp.NEXT = 0;
IF LaborAllocEntryTemp.FINDFIRST THEN
REPEAT
IF LaborAllocEntry.GET(LaborAllocEntryTemp."Entry No.") THEN
LaborAllocEntry.DELETE;
UNTIL LaborAllocEntryTemp.NEXT = 0;
IF LaborAllocEntryTemp.FINDFIRST THEN
REPEAT
LaborAllocEntry := LaborAllocEntryTemp;
LaborAllocEntry."Source ID" := NewOrderNo;
LaborAllocEntry.INSERT;
UNTIL LaborAllocEntryTemp.NEXT = 0;
IF LaborAllocAppTemp.FINDFIRST THEN
REPEAT
LaborAllocApp := LaborAllocAppTemp;
LaborAllocApp."Document No." := NewOrderNo;
LaborAllocApp.Posted := TRUE;
LaborAllocApp.INSERT(TRUE);
UNTIL LaborAllocAppTemp.NEXT = 0;
END;
PROCEDURE ClearAllocationEntry@1101908045(EntryNo@1101908000 :
Integer;TimeCompensateByMoveOtherAlloc@1000000000 : Boolean);
VAR
LaborAllocEntry@1101908001 : Record 25006271;
DoOneServiceMoving@1101908002 : Boolean;
BEGIN
ServiceScheduleSetup.GET;
IF NOT LaborAllocEntry.GET(EntryNo) THEN
EXIT;
LaborAllocEntry."Quantity (Hours)" := 0;
LaborAllocEntry."End Date-Time" := LaborAllocEntry."Start Date-Time";
LaborAllocEntry."Resource No." := '';
LaborAllocEntry."User ID" := USERID;
LaborAllocEntry.VALIDATE("Applies-to Entry No.", 0); //14.03.2014 Elva
Baltic P8 #S0003 MMG7.00
LaborAllocEntry.Status := LaborAllocEntry.Status::Pending;
LaborAllocEntry."Reason Code" := '';
LaborAllocEntry.MODIFY;
END;
PROCEDURE ControlLaborSequence@1101908047(SourceSubtype@1101908000 :
'Quote,Order';SourceID@1101908001 : Code[20];LineNo@1101908003 :
Integer;StartingDateTime@1101908002 : Decimal) : Boolean;
VAR
LaborAllocEntryLoc@1101908005 : Record 25006271;
LaborAllocAppLoc@1101908004 : Record 25006277;
BEGIN
ServiceScheduleSetup.GET;
IF NOT ServiceScheduleSetup."Control Labor Sequence" THEN
EXIT;
LaborAllocAppLoc.RESET;
LaborAllocAppLoc.SETRANGE("Document Type", SourceSubtype);
LaborAllocAppLoc.SETRANGE("Document No.", SourceID);
LaborAllocAppLoc.SETFILTER("Document Line No.", '<%1', LineNo);
IF LaborAllocAppLoc.FINDFIRST THEN
REPEAT
IF LaborAllocEntryLoc.GET(LaborAllocAppLoc."Allocation Entry No.") THEN
IF (StartingDateTime < LaborAllocEntryLoc."Start Date-Time") AND NOT
(AlreadyAskedAboutSequence) THEN BEGIN
IF CONFIRM(Text122) THEN
EXIT(TRUE)
ELSE
ERROR(Text124);
AlreadyAskedAboutSequence := TRUE;
END;
UNTIL LaborAllocAppLoc.NEXT = 0;
EXIT(TRUE);
END;
PROCEDURE ControlSkills@1101908048(SourceSubtype@1101908006 :
'Quote,Order';SourceID@1101908005 : Code[20];LineNo@1101908004 :
Integer;ResourceNo@1101908003 : Code[20]);
VAR
LaborAllocEntryLoc@1101908002 : Record 25006271;
LaborAllocAppLoc@1101908001 : Record 25006277;
ServiceLineLoc@1101908000 : Record 25006146;
ResourceSkill@1101908007 : Record 25006160;
LaborSkill@1101908008 : Record 25006161;
MissedSkills@1101908009 : Text[1000];
ResourceList@1190000 : Text[500];
BEGIN
ServiceScheduleSetup.GET;
MissedSkills := '';
LaborSkill.RESET;
LaborSkill.SETRANGE("Labor Code", ServiceLineLoc."No.");
IF LaborSkill.COUNT = 0 THEN
EXIT;
ResourceSkill.RESET;
ResourceSkill.SETRANGE("Resource No.", ResourceNo);
IF LaborSkill.FINDFIRST THEN
REPEAT
ResourceSkill.SETRANGE("Skill Code", LaborSkill."Skill Code");
IF NOT ResourceSkill.FINDFIRST THEN BEGIN
IF MissedSkills <> '' THEN
MissedSkills += '; ';
MissedSkills += LaborSkill."Skill Code";
END;
UNTIL LaborSkill.NEXT = 0;
i := 0;
IF ResourceTemp.FINDFIRST THEN
REPEAT
IF ResourceList <> '' THEN
ResourceList += ';';
ResourceList += ResourceTemp."No.";
i += 1;
UNTIL (ResourceTemp.NEXT = 0) OR (i = 5);
EXIT(ResourceList);
END;
LaborAllocAppLoc.RESET;
LaborAllocAppLoc.SETRANGE("Document Type", ServiceLine."Document Type");
LaborAllocAppLoc.SETRANGE("Document No.", ServiceLine."Document No.");
LaborAllocAppLoc.SETRANGE("Document Line No.", ServiceLine."Line No.");
LaborAllocAppLoc.DELETEALL;
IF LaborAllocAppLocTemp.FINDFIRST THEN
REPEAT
LaborAllocAppLoc := LaborAllocAppLocTemp;
LaborAllocAppLoc.INSERT(TRUE);
UNTIL LaborAllocAppLocTemp.NEXT = 0;
END;
PROCEDURE CheckRemainingLinkedAllocation@1101908050(EntryNo@1101908000 :
Integer) RetValue : Decimal;
VAR
LaborAllocEntryLoc@1101908002 : Record 25006271;
LaborAllocAppLoc@1101908001 : Record 25006277;
LaborAllocEntryTemp@1101908004 : TEMPORARY Record 25006271;
BEGIN
//Possibly bug inside function.
//RetValue - returns deleted hours
FindSplitEntries(EntryNo, LaborAllocEntryTemp, 0, 1111);
LaborAllocEntryTemp.RESET;
LaborAllocEntryTemp.SETCURRENTKEY("Resource No.", "End Date-Time");
LaborAllocEntryTemp.SETFILTER(Status, '%1|%2|%3',
LaborAllocEntryTemp.Status::Pending, LaborAllocEntryTemp.Status::"On Hold",
LaborAllocEntryTemp.Status::"In Progress");
PROCEDURE JoinAllocationEntries@1101908052(ResourceNo@1101908001 :
Code[20];StartingDateTime@1101908002 : Decimal);
VAR
LaborAllocEntryLoc@1101908000 : Record 25006271;
LaborAllocEntryLoc2@1101908009 : Record 25006271;
LaborAllocEntryTemp@1101908003 : TEMPORARY Record 25006271;
LaborAllocEntryTemp2@1101908004 : TEMPORARY Record 25006271;
LaborAllocEntryTemp3@1101908006 : TEMPORARY Record 25006271;
JoinLaborAllocEntryTemp@1101908005 : TEMPORARY Record 25006271;
AlreadyJoinLaborAllocEntryTemp@1101908007 : TEMPORARY Record 25006271;
LaborAllocAppLoc@1101908011 : Record 25006277;
JoinTotalHours@1101908008 : Decimal;
EndDateTime@1101908010 : Decimal;
BEGIN
LaborAllocEntryTemp2.RESET;
LaborAllocEntryTemp2.DELETEALL;
AlreadyJoinLaborAllocEntryTemp.RESET;
AlreadyJoinLaborAllocEntryTemp.DELETEALL;
LaborAllocEntryLoc.RESET;
LaborAllocEntryLoc.SETCURRENTKEY("Resource No.", "Start Date-Time");
LaborAllocEntryLoc.SETRANGE("Resource No.", ResourceNo);
LaborAllocEntryLoc.SETFILTER("Start Date-Time", '>=%1', StartingDateTime);
//21.07.2015 EB.P7 #Performance issue >>
IF SingleInstanceMgt.GetAllocationEntryNo <> 0 THEN
LaborAllocEntryLoc.SETRANGE("Entry No.",
SingleInstanceMgt.GetAllocationEntryNo);
//21.07.2015 EB.P7 #Performance issue <<
IF LaborAllocEntryLoc.FINDFIRST THEN
REPEAT
IF NOT LaborAllocEntryTemp2.GET(LaborAllocEntryLoc."Entry No.") THEN
BEGIN
LaborAllocEntryTemp.RESET;
LaborAllocEntryTemp.DELETEALL;
LaborAllocEntryTemp3.RESET;
LaborAllocEntryTemp3.DELETEALL;
FindSplitEntries(LaborAllocEntryLoc."Entry No.", LaborAllocEntryTemp,
0, 1111);
IF LaborAllocEntryTemp.FINDFIRST THEN
REPEAT
IF NOT LaborAllocEntryTemp2.GET(LaborAllocEntryTemp."Entry No.")
THEN BEGIN
LaborAllocEntryTemp2 := LaborAllocEntryTemp;
LaborAllocEntryTemp2.INSERT;
END;
IF NOT LaborAllocEntryTemp3.GET(LaborAllocEntryTemp."Entry No.")
THEN BEGIN
LaborAllocEntryTemp3 := LaborAllocEntryTemp;
LaborAllocEntryTemp3.INSERT;
END;
UNTIL LaborAllocEntryTemp.NEXT = 0;
FindJoinEntries(JoinLaborAllocEntryTemp."End Date-Time",
LaborAllocEntryTemp3, JoinLaborAllocEntryTemp);
EndDateTime := 0;
IF JoinLaborAllocEntryTemp.FINDFIRST THEN
REPEAT
IF NOT
AlreadyJoinLaborAllocEntryTemp.GET(JoinLaborAllocEntryTemp."Entry No.") THEN BEGIN
AlreadyJoinLaborAllocEntryTemp := JoinLaborAllocEntryTemp;
AlreadyJoinLaborAllocEntryTemp.INSERT;
END;
JoinTotalHours += JoinLaborAllocEntryTemp."Quantity (Hours)";
IF JoinLaborAllocEntryTemp."End Date-Time" > EndDateTime THEN
EndDateTime := JoinLaborAllocEntryTemp."End Date-Time";
UNTIL JoinLaborAllocEntryTemp.NEXT = 0;
JoinLaborAllocEntryTemp.RESET;
IF JoinLaborAllocEntryTemp.COUNT > 1 THEN BEGIN
LaborAllocEntryLoc2.GET(LaborAllocEntryTemp."Entry No.");
LaborAllocEntryLoc2."End Date-Time" := EndDateTime;
LaborAllocEntryLoc2."Quantity (Hours)" := (EndDateTime -
LaborAllocEntryLoc2."Start Date-Time") / 3.6;
LaborAllocEntryLoc2.MODIFY;
IF JoinLaborAllocEntryTemp.FINDFIRST THEN
REPEAT
IF JoinLaborAllocEntryTemp."Entry No." <>
LaborAllocEntryTemp."Entry No." THEN BEGIN
IF LaborAllocEntryLoc2.GET(JoinLaborAllocEntryTemp."Entry
No.") THEN;
ChangeApplyTo(LaborAllocEntryLoc2."Entry No.",
LaborAllocEntryLoc2."Applies-to Entry No.");
LaborAllocEntryLoc2.DELETE;
LaborAllocAppLoc.RESET;
LaborAllocAppLoc.SETRANGE("Allocation Entry No.",
JoinLaborAllocEntryTemp."Entry No.");
LaborAllocAppLoc.DELETEALL(TRUE);
END;
UNTIL JoinLaborAllocEntryTemp.NEXT = 0;
END;
END;
UNTIL LaborAllocEntryTemp.NEXT = 0;
END;
UNTIL LaborAllocEntryLoc.NEXT = 0;
END;
IF LaborAllocEntryLoc.FINDFIRST THEN
REPEAT
IF NOT JoinLaborAllocEntry.GET(LaborAllocEntryLoc."Entry No.") THEN BEGIN
JoinLaborAllocEntry.INIT;
JoinLaborAllocEntry := LaborAllocEntryLoc;
JoinLaborAllocEntry.INSERT;
FindJoinEntries(LaborAllocEntryLoc."End Date-Time", LaborAllocEntryLoc,
JoinLaborAllocEntry);
END;
UNTIL LaborAllocEntryLoc.NEXT = 0;
END;
PROCEDURE CheckUserRightsInit@1101901001();
BEGIN
CLEAR(isOperAllowedChecked);
CLEAR(OperationMainCode);
CLEAR(OperAllowed);
CLEAR(LaborAllocationEntryPrevTmp);
LaborAllocationEntryPrevTmp.DELETEALL;
LaborAllocEntryPrevStatus := -1;
END;
PROCEDURE CheckUserRights@1101908054(WhatAllow@1101908000 :
'View,Time,Planning,All') : Boolean;
BEGIN
IF UserSetup.GET(USERID) THEN BEGIN
CASE WhatAllow OF
WhatAllow::View:
IF UserSetup."Allow Use Service Schedule" IN [UserSetup."Allow Use
Service Schedule"::" "] THEN BEGIN
ErrorWithRefresh(Text128);
EXIT(FALSE);
END;
WhatAllow::Time:
IF UserSetup."Allow Use Service Schedule" IN [UserSetup."Allow Use
Service Schedule"::" ",
UserSetup."Allow Use
Service Schedule"::"View Only"] THEN BEGIN
ErrorWithRefresh(Text128);
EXIT(FALSE);
END;
WhatAllow::Planning:
IF UserSetup."Allow Use Service Schedule" IN [UserSetup."Allow Use
Service Schedule"::" ",
UserSetup."Allow Use
Service Schedule"::"View Only",
UserSetup."Allow Use
Service Schedule"::"Time Registration"] THEN BEGIN
IF SingleInstanceMgt.GetTimeJournalFlag THEN
EXIT(TRUE);
ErrorWithRefresh(Text128);
EXIT(FALSE);
END;
WhatAllow::All:
IF UserSetup."Allow Use Service Schedule" IN [UserSetup."Allow Use
Service Schedule"::" ",
UserSetup."Allow Use
Service Schedule"::"View Only",
UserSetup."Allow Use
Service Schedule"::"Time Registration",
UserSetup."Allow Use
Service Schedule"::Planning]
THEN
EXIT(FALSE);
END;
END ELSE BEGIN
ErrorWithRefresh(Text128);
EXIT(FALSE);
END;
EXIT(TRUE);
END;
PROCEDURE CheckUserRightsAdv@1101904034(Operation@1101908000 :
Integer;LaborAllocationEntryPar@1101904000 : Record 25006271) : Boolean;
BEGIN
// it is atvanced version of CheckUserRights
// Operation codes:
// 0 view; 1 - time registration; 2 - Planning; 3 - ; 4 - BREAK; 100 -
allocate lines; 110 - allocate header; 120 - ALLOCATE standart event
// 200 - spliting
// 300 - move; 310 - change end time of finished
// 400 - delete entry
// due to last requirements 20.11.2013 is changed a bit operations: 300 and
310 allowed do with rights same to operation=1
// It is important to understand that function call mostly happenes at
operation right before actual write to db, so
// variable LaborAllocEntryPrevStatus is important in taking of decision
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Allocation Entry No.", "Entry No.");
LaborAllocApp.SETRANGE("Document Line No.", 0);
IF LaborAllocApp.FINDFIRST THEN
ERROR(Text134);
OperAllowed := CheckUserRights(2);
END;
300: BEGIN
OperAllowed := CheckUserRights(2); //20.11.2013 EDMS P8
IF OperAllowed THEN
IF Status IN [Status::"In Progress", Status::Finished] THEN BEGIN
OperAllowed := FALSE;
OperAllowed := CheckUserRights(3);
IF NOT OperAllowed THEN BEGIN
ErrorWithRefresh(Text128); //22.11.2013 EDMS P8
END;
END;
END;
310: BEGIN
IF ("Source Type" <> "Source Type"::"Service Document") OR
(Status <> Status::Finished)
THEN
ErrorWithRefresh(Text138);
OperAllowed := CheckUserRights(3);
END;
400: BEGIN
OperAllowed := CheckUserRights(2);
IF (Status = Status::Finished) OR
(Status = Status::"In Progress")
THEN
IF NOT CheckUserRights(3) THEN
ERROR(STRSUBSTNO(Text114, FORMAT(Status)))
ELSE
IF NOT CONFIRM(STRSUBSTNO(Text130, FORMAT(Status))) THEN
ERROR(STRSUBSTNO(Text114, FORMAT(Status)));
END;
END;
END;
EXIT(OperAllowed);
END;
PROCEDURE FindServAllocAplicationEntries@1101908055(VAR
LaborAllocAppLoc@1101908000 : Record 25006277;DocumentType@1101908001 :
'Quote,Order,Invoice,Credit Memo,Blanket Order,Return
Order';DocumentNo@1101908002 : Code[20]);
BEGIN
LaborAllocAppLoc.SETRANGE("Document Type", DocumentType);
LaborAllocAppLoc.SETRANGE("Document No.", DocumentNo);
END;
PROCEDURE CheckForCorrectServHeaderLine@1101908057(ServiceHdr@1101908000 :
Record 25006145;VAR ServiceLine@1101908001 : Record
25006146;WhatAllocate@1101908004 : 'Header,Line');
VAR
LaborAllocEntryLoc@1101908003 : Record 25006271;
LaborAllocAppLoc@1101908002 : Record 25006277;
DocumentNo@1101908005 : Code[20];
BEGIN
// CASE WhatAllocate OF
// WhatAllocate::Header:
// BEGIN
// LaborAllocEntryLoc.RESET;
// LaborAllocEntryLoc.SETRANGE("Source Subtype", ServiceHdr."Document
Type");
// LaborAllocEntryLoc.SETRANGE("Source ID", ServiceHdr."No.");
// IF LaborAllocEntryLoc.FINDFIRST THEN
// IF GUIALLOWED THEN
// IF NOT CONFIRM(STRSUBSTNO(Text131, ServiceHdr."Document Type",
ServiceHdr."No.")) THEN
// ERROR(Text150);
// END;
// WhatAllocate::Line:
// BEGIN
// IF ServiceLine.FINDFIRST THEN BEGIN
// DocumentNo := ServiceLine."Document No.";
// REPEAT
// IF DocumentNo <> ServiceLine."Document No." THEN
// ERROR(Text133);
// UNTIL ServiceLine.NEXT = 0;
// END;
// LaborAllocEntryLoc.RESET;
// LaborAllocEntryLoc.SETRANGE("Source Subtype", ServiceLine."Document
Type"); //12.12.2014 EB.P8
// LaborAllocEntryLoc.SETRANGE("Source ID", ServiceLine."Document No.");
// IF LaborAllocEntryLoc.FINDFIRST THEN
// IF GUIALLOWED THEN
// IF NOT CONFIRM(STRSUBSTNO(Text131, ServiceLine."Document Type",
ServiceLine."Document No.")) THEN
// ERROR(Text150);
// END;
// END;
END;
PROCEDURE IsResourceWorkingTime@1101908058(ResourceNo@1101908000 :
Code[20];CheckDate@1101908001 : Date) : Boolean;
VAR
ServiceHour@1101908003 : Record 25006129;
ResourceCalendarChange@1101908002 : Record 25006279;
BEGIN
IF ResourceCalendarChange.GET(ResourceNo, CheckDate) THEN BEGIN
IF ResourceCalendarChange."Change Type" = ResourceCalendarChange."Change
Type"::Nonworking THEN
EXIT(FALSE)
ELSE
EXIT(TRUE);
END;
ServiceHour.RESET;
ServiceHour.SETFILTER("Starting Date", '''''|<=%1', CheckDate);
ServiceHour.SETFILTER("Ending Date", '''''|>=%1', CheckDate);
ServiceHour.SETRANGE(Day, DATE2DWY(CheckDate, 1) - 1);
IF NOT ServiceHour.FINDLAST THEN
EXIT(FALSE);
EXIT(TRUE);
END;
PROCEDURE GetResourceWorkplace@1101908059(ResourceNo@1101908001 :
Code[20];CheckDate@1101908000 : Date) : Code[10];
VAR
WorkplaceResource@1101908002 : Record 25006285;
BEGIN
WorkplaceResource.RESET;
WorkplaceResource.SETRANGE("Resource No.", ResourceNo);
WorkplaceResource.SETFILTER("Starting Date", '''''|<=%1', CheckDate);
WorkplaceResource.SETFILTER("Ending Date", '''''|>=%1', CheckDate);
IF WorkplaceResource.FINDLAST THEN
EXIT(WorkplaceResource."Workplace Code")
ELSE
EXIT('');
END;
PROCEDURE GetResourceSkills@1190028(ResourceNo@1101908001 : Code[20];VAR
ResourceSkill@1101908000 : Record 25006160) : Code[10];
VAR
WorkplaceResource@1101908002 : Record 25006285;
BEGIN
ResourceSkill.RESET;
ResourceSkill.SETRANGE("Resource No.", ResourceNo);
END;
Workplace.MARKEDONLY(TRUE);
IF Workplace.FINDFIRST THEN
REPEAT
ResourceCodeBuffer.INIT;
ResourceCodeBuffer.Code := Workplace.Code;
ResourceCodeBuffer.Name := Workplace.Description;
ResourceCodeBuffer."Code 2" := Workplace.Code;
ResourceCodeBuffer."Show in Bold" := TRUE;
ResourceCodeBuffer.Group := TRUE;
ResourceCodeBuffer.INSERT;
UNTIL Workplace.NEXT = 0;
END;
Skill.MARKEDONLY(TRUE);
IF Skill.FINDFIRST THEN
REPEAT
ResourceCodeBuffer.INIT;
ResourceCodeBuffer.Code := Skill.Code;
ResourceCodeBuffer.Name := Skill.Description;
ResourceCodeBuffer."Code 2" := Skill.Code;
ResourceCodeBuffer."Show in Bold" := TRUE;
ResourceCodeBuffer.Group := TRUE;
ResourceCodeBuffer.INSERT;
UNTIL Skill.NEXT = 0;
END;
Shift.MARKEDONLY(TRUE);
IF Shift.FINDFIRST THEN
REPEAT
ResourceCodeBuffer.INIT;
ResourceCodeBuffer.Code := Shift.Code;
ResourceCodeBuffer.Name := Shift.Description;
ResourceCodeBuffer."Code 2" := Shift.Code;
ResourceCodeBuffer."Show in Bold" := TRUE;
ResourceCodeBuffer.Group := TRUE;
ResourceCodeBuffer.INSERT;
UNTIL Shift.NEXT = 0;
END;
PROCEDURE CheckServiceLineResource@1190024(DocType@1101904004 :
Integer;DocNo@1101904003 : Code[20];LineType@1101904002 : Integer;LineNo@1101904001
: Integer;ReturnType@1190001 : 'Error,Boolean';ResourceNo@1190002 : Code[20]) :
Boolean;
VAR
TextLoc@1101904000 : TextConst 'ENU=here are params %1';
BEGIN
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Document Type", DocType);
LaborAllocApp.SETRANGE("Document No.", DocNo);
LaborAllocApp.SETRANGE("Document Line No.", LineNo);
IF LaborAllocApp.FINDFIRST THEN BEGIN
//2012.03.19 EDMS P8 >>
LaborAllocApp.SETRANGE("Resource No.", ResourceNo);
IF NOT LaborAllocApp.FINDFIRST THEN BEGIN
IF ReturnType = ReturnType::Error THEN
ERROR(Text136)
// ERROR(TextLoc, ServiceLine.GETFILTERS)
ELSE
EXIT(FALSE);
END ELSE
EXIT(FALSE);
END ELSE BEGIN
EXIT(CheckDocAllocResource(DocType, DocNo, LineType, LineNo, ReturnType,
ResourceNo)); // P8
END;
EXIT(TRUE) ;
END;
CLEAR(ChangeAllocationForm);
ChangeAllocationForm.GetServLaborAllocation(LaborAllocEntry);
ChangeAllocationForm.LOOKUPMODE(TRUE); //03.04.2013 P8
COMMIT; //28.06.2013 EDMS P8
ChangeAllocationForm.RUNMODAL;
END;
PROCEDURE GetCapacity@1190027(ResourceNo@1190000 :
Code[20];StartingDateTime@1190001 : Decimal;EndingDateTime@1190002 : Decimal) :
Decimal;
VAR
ServiceHour@1190003 : Record 25006129;
ResCalendarChange@1190004 : Record 25006279;
Date@1190005 : Record 2000000007;
Resource@1190009 : Record 156;
CurrDate@1190006 : Date;
CurrStartTime@1190008 : Time;
CurrEndTime@1190010 : Time;
CurrEndTime2@1190011 : Time;
Capacity@1190007 : Decimal;
BEGIN
IF NOT Resource.GET(ResourceNo) THEN
EXIT(0);
Capacity := 0;
CurrDate := DateTimeMgt.Datetime2Date(StartingDateTime);
CurrStartTime := DateTimeMgt.Datetime2Time(StartingDateTime);
REPEAT
CurrEndTime := DateTimeMgt.Datetime2Time(EndingDateTime);
IF ResCalendarChange.GET(ResourceNo, CurrDate) THEN BEGIN
IF CurrStartTime < ResCalendarChange."Starting Time" THEN
CurrStartTime := ResCalendarChange."Starting Time";
IF (CurrEndTime > ResCalendarChange."Ending Time") OR (CurrDate <
DateTimeMgt.Datetime2Date(EndingDateTime)) THEN
CurrEndTime := ResCalendarChange."Ending Time";
IF CurrEndTime > CurrStartTime THEN
Capacity := Capacity + (CurrEndTime - CurrStartTime)/(1000*60*60);
END ELSE BEGIN
Date.RESET;
Date.SETRANGE("Period Start", CurrDate);
IF Date.FINDFIRST THEN BEGIN
ServiceHour.RESET;
ServiceHour.SETRANGE("Service Work Group Code", Resource."Service Work
Group Code");
ServiceHour.SETFILTER("Starting Date", '<=%1|%2', CurrDate, 0D);
ServiceHour.SETFILTER("Ending Date", '>=%1|%2', CurrDate, 0D);
ServiceHour.SETRANGE(Day, Date."Period No." - 1);
IF ServiceHour.FINDFIRST THEN BEGIN
CurrEndTime2 := CurrEndTime;
REPEAT
CurrEndTime := CurrEndTime2;
IF CurrStartTime < ServiceHour."Starting Time" THEN
CurrStartTime := ServiceHour."Starting Time";
IF (CurrEndTime > ServiceHour."Ending Time") OR (CurrDate <
DateTimeMgt.Datetime2Date(EndingDateTime)) THEN
CurrEndTime := ServiceHour."Ending Time";
IF CurrEndTime - CurrStartTime > 0 THEN
Capacity := Capacity + (CurrEndTime -
CurrStartTime)/(1000*60*60);
UNTIL ServiceHour.NEXT = 0;
END;
END;
END;
CurrDate := CurrDate + 1;
CurrStartTime := 0T;
UNTIL CurrDate > DateTimeMgt.Datetime2Date(EndingDateTime);
EXIT(Capacity)
END;
EXIT(NotAvailable);
END;
WorkTimeEntry.RESET;
WorkTimeEntry.SETCURRENTKEY("Resource No.",Closed);
WorkTimeEntry.SETRANGE("Resource No.",LaborAllocEntry."Resource No.");
WorkTimeEntry.SETRANGE(Closed,FALSE);
IF NOT WorkTimeEntry.FINDLAST THEN
ERROR(STRSUBSTNO(Text107, LaborAllocEntry."Resource No."));
Resource.GET(LaborAllocEntry."Resource No.");
IF NOT Resource."Allow Simultaneous Work" THEN BEGIN //17.10.2013 EDMS P8
LaborAllocEntryLoc.RESET;
LaborAllocEntryLoc.SETCURRENTKEY("Source Type", Status, "Resource No.");
LaborAllocEntryLoc.SETRANGE(Status, LaborAllocEntryLoc.Status::"In
Progress");
LaborAllocEntryLoc.SETRANGE("Resource No.", LaborAllocEntry."Resource
No.");
IF LaborAllocEntryLoc.FINDFIRST THEN
ERROR(Text135);
END;
PROCEDURE DoNotChangeServStatus@1190042();
BEGIN
DontChangeServiceStatus := TRUE;
END;
IF ServiceHeader.GET(LaborAllocEntry."Source Subtype",LaborAllocEntry."Source
ID") THEN BEGIN
CASE ServiceHeader."Document Type" OF
ServiceHeader."Document Type"::Quote: PAGE.RUNMODAL(PAGE::"Service Quote
EDMS", ServiceHeader);
ServiceHeader."Document Type"::Order: PAGE.RUNMODAL(PAGE::"Service Order
EDMS", ServiceHeader);
END;
END ELSE BEGIN
IF PostedServOrder.GET(LaborAllocEntry."Source ID") THEN
PAGE.RUNMODAL(PAGE::"Posted Service Order EDMS", PostedServOrder);
END;
END;
PROCEDURE AllocationChanged@1101904001(EntryNo@1101904000 :
Integer;NewResourceNo@1101904001 : Code[20];VAR NewStartDT@1101904002 : Decimal;VAR
NewEndDT@1101904003 : Decimal) RetValue : Boolean;
VAR
LaborAllocEntryL@1101904004 : Record 25006271;
AdjustedTime@1101901000 : Time;
DateTmeTmp@1101901001 : Decimal;
RoundMs@1101901002 : Integer;
OrigNewStartDT@1101901004 : Decimal;
OrigNewEndDT@1101901003 : Decimal;
BEGIN
WITH LaborAllocEntryL DO BEGIN
GET(EntryNo);
OrigNewStartDT := NewStartDT;
OrigNewEndDT := NewEndDT;
ServiceScheduleSetup.GET;
IF ServiceScheduleSetup."Allocation Time Step (Minutes)" > 0 THEN
RoundMs := ServiceScheduleSetup."Allocation Time Step (Minutes)"
ELSE
RoundMs := 36000; // IF NO SETUP THEN min by system is 36 sec.
IF RoundMs > 0 THEN BEGIN
// lets do time adjustment
//check for busy time in Base Calendar and in Resource Calendar Change >>
IF ResCalendarChange.GET(ResourceNo, TargetDate) THEN BEGIN
CASE ResCalendarChange."Change Type"::"Work Time Change" OF
ResCalendarChange."Change Type"::Nonworking: BEGIN
QtyToAllocate := CalcHourDifference(DateTimeMgt.Datetime(TargetDate,
000000T),
DateTimeMgt.Datetime(TargetDate,
235959.999T));
InsertAllocationEntry(AllocEntry, ApplicationEntry, ResourceNo,
DateTimeMgt.Datetime(TargetDate, 000000T), QtyToAllocate,
0, 0, Text001, 0,
DoChangeServLineResource,AllocEntry.Travel);
END;
ResCalendarChange."Change Type"::"Work Time Change": BEGIN
ResWorkTimeChange := TRUE;
IF ResCalendarChange."Starting Time" > 0T THEN BEGIN
QtyToAllocate := CalcHourDifference(DateTimeMgt.Datetime(TargetDate,
000000T),
DateTimeMgt.Datetime(TargetDate,
ResCalendarChange."Starting Time"));
InsertAllocationEntry(AllocEntry, ApplicationEntry, ResourceNo,
DateTimeMgt.Datetime(TargetDate, 000000T), QtyToAllocate,
0, 0, Text001, 0,
DoChangeServLineResource,AllocEntry.Travel);
END;
PROCEDURE DateTimeRound@1101904008(DateTime@1101904000 :
Decimal;RoundMs@1101904001 : Integer) : Decimal;
VAR
AdjustedTime@1101904002 : Time;
BEGIN
IF RoundMs > 0 THEN BEGIN
AdjustedTime := 000001T - 1000 + RoundMs;
EXIT(ROUND(DateTime, DateTimeMgt.Datetime(0D, AdjustedTime)))
END ELSE
EXIT(DateTime);
END;
PROCEDURE DocAllocAdjustDocLinesResource@1101904005(DocumentType@1101904004 :
'Quote,Order,Invoice,Credit Memo,Blanket Order,Return
Order';DocumentNo@1101904002 : Code[20];ResourceNo@1101904003 : Code[20]);
VAR
ServiceLineLocal@1101904000 : Record 25006146;
Resources@1101904005 : Text[250];
BEGIN
// P8
IF GetSourceType(LaborAllocEntry, LaborAllocApp) <>
LaborAllocAppType::"Service Document" THEN
EXIT;
ServiceLineLocal.RESET;
ServiceLineLocal.SETRANGE("Document Type", DocumentType);
ServiceLineLocal.SETRANGE("Document No.", DocumentNo);
ServiceLineLocal.SETRANGE(Type, ServiceLineLocal.Type::Labor);
FillServiceLine(ServiceLineLocal);
IF ServiceLineLocal.FINDFIRST THEN BEGIN
Resources := GetRelatedResources(DocumentType, DocumentNo,
ServiceLineLocal.Type::Labor, ServiceLineLocal."Line No.", 0);
REPEAT
SetRelatedResources(DocumentType, DocumentNo,
ServiceLineLocal.Type::Labor, ServiceLineLocal."Line No.",
Resources, 11);
UNTIL ServiceLineLocal.NEXT = 0;
END;
END;
PROCEDURE CheckDocAllocResource@1101904004(DocType@1101904003 :
Integer;DocNo@1101904002 : Code[20];LineType@1101904001 : Integer;LineNo@1101904000
: Integer;ReturnType@1190001 : 'Error,Boolean';ResourceNo@1190002 : Code[20]) :
Boolean;
BEGIN
// P8
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Document Type", DocType);
LaborAllocApp.SETRANGE("Document No.", DocNo);
LaborAllocApp.SETRANGE("Document Line No.", 0);
IF LaborAllocApp.FINDFIRST THEN BEGIN
//2012.03.19 EDMS P8 >>
LaborAllocApp.SETRANGE("Resource No.", ResourceNo);
IF NOT LaborAllocApp.FINDFIRST THEN BEGIN
IF ReturnType = ReturnType::Error THEN
ERROR(Text136)
ELSE
EXIT(FALSE);
END ELSE
EXIT(FALSE);
END;
EXIT(TRUE) ;
END;
PROCEDURE GetDocAllocResource@1101904006(DocumentType@1101904001 :
'Quote,Order,Invoice,Credit Memo,Blanket Order,Return
Order';DocumentNo@1101904000 : Code[20]) ResourceNo : Code[20];
BEGIN
// old version, look at GetDocAllocResources
LaborAllocApp.RESET;
LaborAllocApp.SETRANGE("Document Type", DocumentType);
LaborAllocApp.SETRANGE("Document No.", DocumentNo);
LaborAllocApp.SETRANGE("Document Line No.", 0);
IF LaborAllocApp.FINDFIRST THEN
IF (LaborAllocApp."Resource No." <> '') THEN
ResourceNo := LaborAllocApp."Resource No.";
EXIT(ResourceNo);
END;
PROCEDURE GetDocAllocResources@1101904020(DocumentType@1101904001 :
'Quote,Order,Invoice,Credit Memo,Blanket Order,Return
Order';DocumentNo@1101904000 : Code[20]) ResourceNos : Text[250];
VAR
ServLaborApplicationTmp@1101904002 : TEMPORARY Record 25006277;
BEGIN
ResourceNos := '';
WITH LaborAllocApp DO BEGIN
RESET;
SETRANGE("Document Type", DocumentType);
SETRANGE("Document No.", DocumentNo);
SETRANGE("Document Line No.", 0);
IF FINDFIRST THEN BEGIN
REPEAT
ServLaborApplicationTmp.SETRANGE("Resource No.", "Resource No.");
IF NOT ServLaborApplicationTmp.FINDFIRST THEN BEGIN
ResourceNos += "Resource No."+',';
ServLaborApplicationTmp := LaborAllocApp;
ServLaborApplicationTmp.INSERT;
END;
UNTIL NEXT = 0;
ResourceNos := COPYSTR(ResourceNos, 1, STRLEN(ResourceNos)-1);
END;
END;
EXIT(ResourceNos);
END;
END;
IF NOT doAvoidDestLineQtyChange THEN BEGIN
IF ShareQtyDest <> 100 THEN BEGIN
VALIDATE("Standard Time", "Standard Time" * ShareQtyDest/100);
ServLineDestPar.SetTimeQty(QtySourceBeforeChange * ShareQtyDest/100,
TRUE, TRUE);
END;
MODIFY;
END;
END;
PROCEDURE GetQtyShareOfLineInAlloc@1101904013(DocType@1101904001 :
Integer;DocNo@1101904010 : Code[20];LineNo@1101904011 :
Integer;EntryNo@1101904008 : Integer) ShareOfLine : Decimal;
VAR
ServAllocApp@1101904009 : Record 25006277;
ServiceLine@1101904000 : Record 25006146;
ServLaborAllocationEntry@1101904006 : Record 25006271;
QtyTotalOfApp@1101904005 : Decimal;
MainAllocQty@1101904004 : Decimal;
MainLineQty@1101904003 : Decimal;
BEGIN
WITH ServAllocApp DO BEGIN
QtyTotalOfApp := 0;
ShareOfLine := 1;
RESET;
SETRANGE("Allocation Entry No.", EntryNo);
IF FINDFIRST THEN BEGIN
IF ServLaborAllocationEntry.GET(EntryNo) THEN
MainAllocQty := ServLaborAllocationEntry."Quantity (Hours)"
ELSE
MainAllocQty := 0;
ServiceLine.GET(DocType, DocNo, LineNo);
MainLineQty := ServiceLine.GetTimeQty;
IF COUNT > 1 THEN BEGIN
REPEAT
IF ServiceLine.GET(DocType, DocNo, "Document Line No.") THEN
QtyTotalOfApp += ServiceLine.GetTimeQty;
UNTIL NEXT = 0;
ShareOfLine := QtyTotalOfApp/MainLineQty;
END;
END;
END;
EXIT(ShareOfLine*100);
END;
PROCEDURE CreateNewAllocEntry@1101904015(StartingDateTime@1190000 :
Decimal;ResourceNo@1190005 : Code[20];Hours@1190004 : Decimal;SourceType@1101904003
: Integer;SourceID@1190006 : Code[20];LineNo@1190007 : Integer;ReasonCode@1190008 :
Code[10];PlanningPolicy@1190009 : Integer;FinishedHours@1101904000 :
Decimal;RemainingHours@1101904001 : Decimal;Status@1101904002 : Integer) : Integer;
VAR
NewServLaborAllocEntry@1190001 : Record 25006271;
NewAllocAppEntry@1190002 : Record 25006277;
EntryNo@1190003 : Integer;
BEGIN
//returns new allocation entry no
NewServLaborAllocEntry.RESET;
NewServLaborAllocEntry.FINDLAST;
EntryNo := NewServLaborAllocEntry."Entry No." + 1;
NewServLaborAllocEntry.INIT;
NewServLaborAllocEntry."Entry No." := EntryNo;
NewServLaborAllocEntry."Source Type" := NewServLaborAllocEntry."Source
Type"::"Service Document";
NewServLaborAllocEntry."Source Subtype" := SourceType;
NewServLaborAllocEntry."Source ID" := SourceID;
NewServLaborAllocEntry."Start Date-Time" := ROUND(StartingDateTime, 0.00001);
NewServLaborAllocEntry."Quantity (Hours)" := Hours;
NewServLaborAllocEntry."End Date-Time" := ROUND(StartingDateTime +
NewServLaborAllocEntry."Quantity (Hours)"*3.6, 0.00001);
NewServLaborAllocEntry."Resource No." := ResourceNo;
NewServLaborAllocEntry."User ID" := USERID;
NewServLaborAllocEntry.Status := Status;
NewServLaborAllocEntry."Reason Code" := ReasonCode;
NewServLaborAllocEntry."Planning Policy" := PlanningPolicy;
NewServLaborAllocEntry.INSERT;
PROCEDURE CreateAppEntry@1101904016(EntryNo@1101904002 :
Integer;DocType@1190000 : Integer;DocNo@1101904003 : Code[20];LineNo@1101904004 :
Integer;ResourceNo@1190005 : Code[20];FinishedHours@1101904000 :
Decimal;RemainingHours@1101904001 : Decimal;TimeLine@1101904005 : Boolean);
VAR
NewAllocAppEntry@1190002 : Record 25006277;
BEGIN
NewAllocAppEntry.INIT;
NewAllocAppEntry."Allocation Entry No." := EntryNo;
NewAllocAppEntry."Document Type" := DocType;
NewAllocAppEntry."Document No." := DocNo;
NewAllocAppEntry."Document Line No." := LineNo;
NewAllocAppEntry."Resource No." := ResourceNo;
NewAllocAppEntry."Time Line" := TimeLine;
IF TimeLine THEN BEGIN
NewAllocAppEntry."Finished Quantity (Hours)" := FinishedHours;
NewAllocAppEntry."Remaining Quantity (Hours)" := RemainingHours;
END ELSE BEGIN
NewAllocAppEntry."Finished Quantity (Hours)" := 0;
NewAllocAppEntry."Remaining Quantity (Hours)" := 0;
END;
NewAllocAppEntry.INSERT(TRUE);
END;
PROCEDURE CreateAppEntryByEntry@1101904022(VAR
ServLaborAllocationEntryPar@1101904002 : Record 25006271;VAR
ServLaborAllocApplicationPar@1190000 : Record 25006277;LineNo@1101904003 :
Integer;FinishedHours@1101904000 : Decimal;RemainingHours@1101904001 :
Decimal;TimeLine@1101904005 : Boolean);
BEGIN
WITH ServLaborAllocApplicationPar DO BEGIN
INIT;
"Allocation Entry No." := ServLaborAllocationEntryPar."Entry No.";
"Document Type" := ServLaborAllocationEntryPar."Source Subtype";
"Document No." := ServLaborAllocationEntryPar."Source ID";
"Document Line No." := LineNo;
"Resource No." := ServLaborAllocationEntryPar."Resource No.";
"Time Line" := TimeLine;
IF TimeLine THEN BEGIN
"Finished Quantity (Hours)" := FinishedHours;
"Remaining Quantity (Hours)" := RemainingHours;
END ELSE BEGIN
"Finished Quantity (Hours)" := 0;
"Remaining Quantity (Hours)" := 0;
END;
INSERT(TRUE);
END;
END;
PROCEDURE LookupResourceToAllocEntry@1101904011(AllocEntryNo@1190004 :
Code[20]);
VAR
ResourceList@1190000 : Page 77;
ServLaborAllocationEntry@1190001 : Record 25006271;
Resource@1190006 : Record 156;
NewLineNo@1190005 : Integer;
BEGIN
IF NOT CheckUserRightsAdv(2, LaborAllocEntry)THEN EXIT;
CLEAR(ResourceList);
ResourceList.LOOKUPMODE(TRUE);
PROCEDURE AddResourceToAllocEntry@1101904014(VAR
ServLaborAllocationEntry@1101904000 : Record 25006271;VAR
ServLaborAllocApplication@1101904004 : Record 25006277;ResourceNo@1101904001 :
Code[20];ApplyToEntryNo@1101904006 : Integer;VAR
NewServLaborAllocEntry@1101904008 : Record 25006271;VAR
NewServLaborAllocApplication@1101904002 : Record 25006277) : Integer;
VAR
TextNotLineFound@1101904003 : TextConst 'ENU=For the location is not found
service line.';
EntryNo@1101904005 : Integer;
LaborAllocEntryL@1101904007 : Record 25006271;
BEGIN
// actually it is not adding to allocation entry, but creating new entry with
same pars and different resource
ServLaborAllocApplication.SETRANGE("Resource No.");
ServLaborAllocApplication.SETRANGE("Allocation Entry No.",
ServLaborAllocationEntry."Entry No.");
IF NOT ServLaborAllocApplication.FINDFIRST THEN
ERROR(TextNotLineFound);
LaborAllocEntryL.RESET;
LaborAllocEntryL.FINDLAST;
EntryNo := LaborAllocEntryL."Entry No." + 1;
NewServLaborAllocEntry.INIT;
NewServLaborAllocEntry."Entry No." := EntryNo;
NewServLaborAllocEntry."Source Type" := NewServLaborAllocEntry."Source
Type"::"Service Document";
NewServLaborAllocEntry."Source Subtype" := ServLaborAllocationEntry."Source
Subtype";
NewServLaborAllocEntry."Source ID" := ServLaborAllocationEntry."Source ID";
NewServLaborAllocEntry."Start Date-Time" :=
ROUND(ServLaborAllocationEntry."Start Date-Time", 0.00001);
NewServLaborAllocEntry."Quantity (Hours)" :=
ServLaborAllocationEntry."Quantity (Hours)";
NewServLaborAllocEntry."End Date-Time" :=
ROUND(ServLaborAllocationEntry."Start Date-Time" +
NewServLaborAllocEntry."Quantity (Hours)" * 3.6, 0.00001);
NewServLaborAllocEntry."Resource No." := ResourceNo;
NewServLaborAllocEntry."User ID" := USERID;
NewServLaborAllocEntry.Status := ServLaborAllocationEntry.Status;
NewServLaborAllocEntry."Reason Code" := ServLaborAllocationEntry."Reason
Code";
NewServLaborAllocEntry."Planning Policy" :=
ServLaborAllocationEntry."Planning Policy";
NewServLaborAllocEntry."Parent Alloc. Entry No." :=
ServLaborAllocationEntry."Entry No.";
NewServLaborAllocEntry."Parent Link Synchronize" := TRUE;
NewServLaborAllocEntry.INSERT;
CreateAppEntryByEntry(NewServLaborAllocEntry, NewServLaborAllocApplication,
ServLaborAllocApplication."Document Line No.", 0,
ServLaborAllocationEntry."Quantity (Hours)", FALSE);
EXIT(EntryNo);
END;
PROCEDURE GetMainAllocEntrNo@1101904024(EntryNo@1101904000 :
Integer;RunModeFlags@1101904002 : Integer) RetEntryNo : Integer;
VAR
LaborAllocEntryL@1101904001 : Record 25006271;
StatusArray@1101904003 : ARRAY [10] OF Integer;
BEGIN
// RunModeFlags = 1011, what statuses are taken in account REAden from right
to left (On Hold,Finished,In Progress,Pending)
AdjustFlagsToArray(RunModeFlags, StatusArray);
RetEntryNo := EntryNo;
IF LaborAllocEntry.GET(EntryNo) THEN BEGIN
REPEAT
LaborAllocEntry.GET(EntryNo);
IF IsIntInArrayTen(LaborAllocEntry.Status, StatusArray) THEN
RetEntryNo := LaborAllocEntry."Entry No.";
EntryNo := LaborAllocEntry."Applies-to Entry No.";
UNTIL LaborAllocEntry."Applies-to Entry No." = 0;
END;
EXIT(RetEntryNo);
END;
PROCEDURE FindAllocEntriesOfServLine@1101904041(ServiceLinePar@1101904003 :
Record 25006146;VAR LaborAllocEntryTmp@1101904002 : TEMPORARY Record
25006271;RunModeFlags@1101904000 : Text[30]);
VAR
LaborAllocEntryL@1101904001 : Record 25006271;
LaborAllocAppL@1101904004 : Record 25006277;
BEGIN
LaborAllocAppL.RESET;
END;
PROCEDURE SynchroniseRelatedEntry@1101904023(SourceLaborAllocEntryNo@1101904000
: Integer;DestLaborAllocEntryNo@1101904001 : Integer) SynchronisedCount : Integer;
VAR
SourceLaborAllocEntryTmp@1101904002 : TEMPORARY Record 25006271;
DestLaborAllocEntryTmp@1101904003 : TEMPORARY Record 25006271;
LaborAllocEntryL@1101904004 : Record 25006271;
EntryNo@1101904005 : Integer;
DestStatusBefore@1101904006 : Integer;
BEGIN
FindSplitEntries(SourceLaborAllocEntryNo, SourceLaborAllocEntryTmp, 0, 1111);
FindSplitEntries(DestLaborAllocEntryNo, DestLaborAllocEntryTmp, 0, 1011);
DestLaborAllocEntryTmp.FINDFIRST;
LaborAllocEntry.RESET;
IF SourceLaborAllocEntryTmp.COUNT > DestLaborAllocEntryTmp.COUNT THEN BEGIN
LaborAllocEntry.RESET;
LaborAllocEntry.FINDLAST;
EntryNo := LaborAllocEntry."Entry No.";
DestLaborAllocEntryTmp.FINDLAST;
REPEAT
InsertAllocationEntry(LaborAllocEntry, LaborAllocApp,
DestLaborAllocEntryTmp."Resource No.",
DestLaborAllocEntryTmp."Start Date-Time",
DestLaborAllocEntryTmp."Quantity (Hours)",
DestLaborAllocEntryTmp."Source Type",
DestLaborAllocEntryTmp."Source Subtype",
DestLaborAllocEntryTmp."Source ID",
DestLaborAllocEntryNo, TRUE,LaborAllocEntry.Travel);
DestLaborAllocEntryTmp := LaborAllocEntry;
DestLaborAllocEntryTmp.INSERT;
UNTIL SourceLaborAllocEntryTmp.COUNT = DestLaborAllocEntryTmp.COUNT;
END ELSE BEGIN
IF SourceLaborAllocEntryTmp.COUNT < DestLaborAllocEntryTmp.COUNT THEN BEGIN
REPEAT
DestLaborAllocEntryTmp.FINDLAST;
DeleteAllocationEntry(LaborAllocEntry, LaborAllocApp,
DestLaborAllocEntryTmp."Entry No.", 11111);
DestLaborAllocEntryTmp.DELETE;
UNTIL SourceLaborAllocEntryTmp.COUNT = DestLaborAllocEntryTmp.COUNT;
END;
END;
// now is going to synchr. times
SourceLaborAllocEntryTmp.FINDFIRST;
DestLaborAllocEntryTmp.FINDFIRST;
EntryNo := 0;
REPEAT
LaborAllocEntry.GET(DestLaborAllocEntryTmp."Entry No.");
DestStatusBefore := LaborAllocEntry.Status;
IF DestLaborAllocEntryTmp."Applies-to Entry No." = 0 THEN
DestLaborAllocEntryTmp."Applies-to Entry No." :=
SourceLaborAllocEntryTmp."Applies-to Entry No.";
ModifyAllocationEntry(LaborAllocEntry, LaborAllocApp,
DestLaborAllocEntryTmp."Entry No.",
DestLaborAllocEntryTmp."Resource No.",
SourceLaborAllocEntryTmp."Start Date-Time",
SourceLaborAllocEntryTmp."Quantity (Hours)",
FALSE, SourceLaborAllocEntryTmp.Status,
DestLaborAllocEntryTmp."Applies-to Entry No.",LaborAllocEntry.Travel);
IF DestStatusBefore <> SourceLaborAllocEntryTmp.Status THEN BEGIN
AllocationStatus := SourceLaborAllocEntryTmp.Status;
ReasonCodeGlobal := SourceLaborAllocEntryTmp."Reason Code";
ChangeStatus(LaborAllocEntry);
ChangeServiceLineStatus(LaborAllocEntry."Entry No.", FALSE);
END;
EntryNo := LaborAllocEntry."Entry No.";
DestLaborAllocEntryTmp.NEXT;
UNTIL SourceLaborAllocEntryTmp.NEXT = 0;
EXIT(SynchronisedCount);
END;
END;
SourceType::"Service Document": BEGIN
IF ServiceLineSrcPar.FINDFIRST AND (ServiceLineSrcPar."Line No." > 0)
THEN BEGIN //Service Line Allocation
IF ServiceLineSrcPar.COUNT = 1 THEN
LineNo := ServiceLineSrcPar."Line No.";
QtyToAllocate := 0;
REPEAT
ServiceLinePar := ServiceLineSrcPar;
ServiceLinePar.INSERT;
IF Mode = Mode::"New Allocation" THEN
QtyToAllocate += ServiceLinePar.GetTimeQty;
UNTIL ServiceLineSrcPar.NEXT = 0;
END ELSE BEGIN //Service Header Allocation
IF Mode = Mode::"New Allocation" THEN BEGIN
ServiceLineLoc.RESET;
ServiceLineLoc.SETRANGE("Document Type", SourceSubType);
ServiceLineLoc.SETRANGE("Document No.", SourceID);
ServiceLineLoc.SETRANGE(Type, ServiceLineLoc.Type::Labor);
IF ServiceLineLoc.FINDFIRST THEN BEGIN
QtyToAllocate := 0;
REPEAT
QtyToAllocate += ServiceLineLoc.GetTimeQty;
UNTIL ServiceLineLoc.NEXT = 0;
END;
END;
PROCEDURE RoundQtyHours@1101901003(QtyToRound@1101901000 :
Decimal;RunMode@1101901001 : Integer) : Decimal;
BEGIN
EXIT(ROUND(QtyToRound, 0.1));
END;
ServiceSetup.GET;
Resource.GET(ResourceNo);
CASE Resource."On Task Start" OF
Resource."On Task Start"::"Hold Other Tasks":
BEGIN
LaborAllocEntry.RESET;
LaborAllocEntry.SETRANGE("Resource No.", ResourceNo);
LaborAllocEntry.SETRANGE(Status, LaborAllocEntry.Status::"In
Progress");
LaborAllocEntry.SETFILTER(LaborAllocEntry."Entry No.",'<>
%1',EntryNo);
LaborAllocEntry.SETFILTER(LaborAllocEntry."Applies-to Entry No.",'<>
%1',EntryNo);
LaborAllocEntry.SETFILTER("Source ID",'<>%1',ServiceSetup."Default
Idle Event");
IF LaborAllocEntry.FINDFIRST THEN BEGIN
REPEAT
AllocationStatus := AllocationStatus::"On Hold";
MainAllocEntryNo := GetMainAllocEntrNo(LaborAllocEntry."Entry
No.", 1011);
IF MainLaborAllocationEntry.GET(MainAllocEntryNo) AND
(MainLaborAllocationEntry.Status =
MainLaborAllocationEntry.Status::"In Progress") THEN BEGIN
StatusToSet := StatusToSet::"On Hold";
SingleInstanceManagment.SetCurrAllocation(MainLaborAllocationEntry."Entry No.");
StartFinishAllocation.SetParam(ResourceNo,
DateTimeMgt.Datetime(OnDate, OnTime),
MainLaborAllocationEntry."Quantity (Hours)",
MainLaborAllocationEntry."Source Type",
MainLaborAllocationEntry."Source Subtype",
MainLaborAllocationEntry."Source ID",
StatusToSet,
0);
StartFinishAllocation.StartEndWork;
END;
//WriteAllocationEntryEnd(LaborAllocEntry."Entry No.",
StartingDateTime, FALSE, '',LaborAllocEntry.Travel);
ResourceTimeRegMgt.AddTimeRegEntries('Onhold',MainLaborAllocationEntry,MainLaborAll
ocationEntry."Resource No.",OnDate,OnTime);
UNTIL LaborAllocEntry.NEXT = 0
END;
END;
Resource."On Task Start"::"Complete Other Tasks":
BEGIN
LaborAllocEntry.RESET;
LaborAllocEntry.SETRANGE("Resource No.", ResourceNo);
LaborAllocEntry.SETFILTER(Status,'%1',LaborAllocEntry.Status::"In
Progress");
LaborAllocEntry.SETFILTER(LaborAllocEntry."Entry No.",'<>
%1',EntryNo);
LaborAllocEntry.SETFILTER(LaborAllocEntry."Applies-to Entry No.",'<>
%1',EntryNo);
LaborAllocEntry.SETFILTER("Source ID",'<>%1',ServiceSetup."Default
Idle Event");
IF LaborAllocEntry.FINDFIRST THEN BEGIN
REPEAT
AllocationStatus := AllocationStatus::Finished;
MainAllocEntryNo := GetMainAllocEntrNo(LaborAllocEntry."Entry
No.", 1011);
IF MainLaborAllocationEntry.GET(MainAllocEntryNo) AND
(MainLaborAllocationEntry.Status =
MainLaborAllocationEntry.Status::"In Progress") THEN BEGIN
StatusToSet := StatusToSet::"Finish All";
SingleInstanceManagment.SetCurrAllocation(MainLaborAllocationEntry."Entry No.");
StartFinishAllocation.SetParam(ResourceNo,
DateTimeMgt.Datetime(OnDate, OnTime),
MainLaborAllocationEntry."Quantity (Hours)",
MainLaborAllocationEntry."Source Type",
MainLaborAllocationEntry."Source Subtype",
MainLaborAllocationEntry."Source ID",
StatusToSet,
0);
StartFinishAllocation.StartEndWork;
END;
//WriteAllocationEntryEnd(LaborAllocEntry."Entry No.",
StartingDateTime, FALSE, '',LaborAllocEntry.Travel);
ResourceTimeRegMgt.AddTimeRegEntries('Complete',LaborAllocEntry,LaborAllocEntry."Re
source No.",OnDate,OnTime);
UNTIL LaborAllocEntry.NEXT = 0
END;
END;
END;
END;
PROCEDURE GetRelatedResources@1101904026(DocType@1101904001 :
Integer;DocNo@1101904006 : Code[20];LineType@1101904007 : Integer;LineNo@1101904008
: Integer;RunMode@1101904000 : Integer) RetValue : Text[250];
VAR
ServLaborApplication@1101904002 : Record 25006277;
ServLaborApplicationTmp@1101904003 : TEMPORARY Record 25006277;
ServiceLine@1101904005 : Record 25006146;
ServLaborApplicationLoc@1101901003 : Record 25006277;
isItDocAllocation@1101904004 : Boolean;
StatusArray@1101901000 : ARRAY [10] OF Integer;
isTempTableUse@1101901001 : Boolean;
BEGIN
//RunMode first digit from right means should it be used temp resource table
RetValue := '';
IF LineType = ServiceLine.Type::Labor THEN BEGIN
WITH ServLaborApplicationTmp DO BEGIN
RESET;
DELETEALL;
END;
WITH ServLaborApplication DO BEGIN
RESET;
SETRANGE("Document Type", DocType);
SETRANGE("Document No.", DocNo);
IF LineNo = 0 THEN BEGIN
// in case that requested for document:
SETRANGE("Document Line No.");
END ELSE BEGIN
SETRANGE("Document Line No.", 0); // at first try to find document
allocation
IF NOT FINDFIRST THEN
SETRANGE("Document Line No.", LineNo);
END;
IF FINDFIRST THEN BEGIN
REPEAT
ServLaborApplicationTmp.SETRANGE("Resource No.", "Resource No.");
IF NOT ServLaborApplicationTmp.FINDFIRST THEN BEGIN
RetValue += "Resource No."+',';
ServLaborApplicationTmp := ServLaborApplication;
ServLaborApplicationTmp.INSERT;
END;
UNTIL NEXT = 0;
RetValue := COPYSTR(RetValue, 1, STRLEN(RetValue)-1);
END;
END;
END;
EXIT(RetValue);
END;
PROCEDURE SetRelatedResources@1101904031(DocType@1101904018 :
Integer;DocNo@1101904017 : Code[20];LineType@1101904016 : Integer;LineNo@1101904015
: Integer;RecourcesTextSource@1101904004 : Text[250];RunMode@1101904000 : Integer)
ResourcesCount : Integer;
VAR
ServLaborApplication@1101904002 : Record 25006277;
Posit@1101904005 : Integer;
ServiceSetup@1101904008 : Record 25006120;
ResourceToAdd@1101904010 : Text[30];
Resource@1101904011 : Record 156;
RecourcesText@1101904003 : Text[250];
RecourcesTextToModify@1101904012 : Text[250];
AllocEntryNo@1101904006 : Integer;
isItDocAllocation@1101904007 : Boolean;
divResult@1101904009 : Integer;
isItAllowedMessage@1101904013 : Boolean;
ServiceLine@1101904001 : Record 25006146;
BEGIN
//RunMode = 0 - normal; 1 - no messages; second digit (tens) - is it document
allocation
ServiceSetup.GET;
isItAllowedMessage := ((RunMode MOD 10) = 0);
divResult := (RunMode DIV 10);
isItDocAllocation := ((divResult > 0) AND ((divResult MOD 10) > 0));
IF ((LineNo = 0) AND NOT isItDocAllocation) THEN
ERROR(Text148);
RecourcesText := RecourcesTextSource;
ResourcesCount := 0;
IF LineType = ServiceLine.Type::Labor THEN BEGIN
WITH ServLaborApplication DO BEGIN
SETRANGE("Document Type", DocType);
SETRANGE("Document No.", DocNo);
SETRANGE("Document Line No.", LineNo);
IF NOT FINDFIRST THEN BEGIN
SETRANGE("Document Line No.", 0);
// actually for nowdays such case is unpossible, but in future...
IF FINDFIRST THEN
IF isItAllowedMessage THEN BEGIN
IF NOT CONFIRM(Text147,FALSE) THEN
EXIT;
END ELSE
EXIT;
END;
SETRANGE("Document Line No.", LineNo);
REPEAT
Posit := STRPOS(RecourcesText, ',');
IF Posit > 0 THEN BEGIN
ResourceToAdd := COPYSTR(RecourcesText, 1, Posit - 1);
RecourcesText := COPYSTR(RecourcesText, Posit + 1,
STRLEN(RecourcesText)-Posit);
END ELSE BEGIN
ResourceToAdd := RecourcesText;
RecourcesText := '';
END;
IF Resource.GET(ResourceToAdd) THEN BEGIN
SETRANGE("Resource No.", ResourceToAdd);
IF NOT FINDLAST THEN BEGIN
Resource.TESTFIELD(Blocked, FALSE);
INIT;
"Allocation Entry No." := 0;
"Document Type" := DocType;
"Document No." := DocNo;
"Document Line No." := LineNo;
"Resource No." := ResourceToAdd;
INSERT(TRUE);
END;
END;
UNTIL RecourcesText = '';
SETRANGE("Resource No.");
IF isItDocAllocation THEN
SETRANGE("Document Line No.", 0);
IF FINDFIRST THEN
REPEAT
Posit := STRPOS(RecourcesTextSource, "Resource No.");
IF NOT (Posit > 0) THEN BEGIN
DELETE(TRUE);
FINDFIRST;
END;
UNTIL NEXT = 0;
IF FINDFIRST THEN BEGIN
Posit := STRPOS(RecourcesTextSource, "Resource No.");
IF NOT (Posit > 0) THEN
DELETE(TRUE);
END;
IF FINDFIRST THEN
REPEAT
RecourcesTextToModify += "Resource No." + ',';
UNTIL NEXT = 0;
IF STRLEN(RecourcesTextToModify) > 0 THEN
RecourcesTextToModify := COPYSTR(RecourcesTextToModify, 1,
STRLEN(RecourcesTextToModify)-1);
END;
END;
EXIT(ServLaborApplication.COUNT);
END;
PROCEDURE RelatedResourcesList@1101904030(DocType@1101904005 :
Integer;DocNo@1101904004 : Code[20];LineType@1101904003 : Integer;LineNo@1101904002
: Integer;VAR RelatedResources@1101904000 : Text[250]);
VAR
ServLaborAllocApplication@1101904001 : Record 25006277;
BEGIN
ServLaborAllocApplication.RESET;
ServLaborAllocApplication.SETRANGE("Document Type", DocType);
ServLaborAllocApplication.SETRANGE("Document No.", DocNo);
ServLaborAllocApplication.SETRANGE("Document Line No.", LineNo);
IF LineNo < 0 THEN
ServLaborAllocApplication.SETRANGE("Document Line No.");
PAGE.RUNMODAL(PAGE::"Service Line Resources", ServLaborAllocApplication);
RelatedResources := GetRelatedResources(DocType, DocNo, LineType, LineNo, 0);
END;
PROCEDURE ResourcesList@1101904029(DocType@1101904006 :
Integer;DocNo@1101904005 : Code[20];LineType@1101904004 : Integer;LineNo@1101904003
: Integer;VAR RelatedResources@1101904000 : Text[250]);
VAR
ServLaborApplication@1101904001 : Record 25006277;
Resource@1101904002 : Record 156;
ServiceSetup@1101904007 : Record 25006120;
BEGIN
//??? checkstatusopen
// not used for now, it is supposed to be used for lookup (case then SS
unactive and only one resource is set)
ServiceSetup.GET;
IF ServiceSetup."Service Schedule Active" THEN
ERROR(Text146);
PROCEDURE ResourcesCopyLineToLine@1101904028(DocType@1101904010 :
Integer;DocNo@1101904009 : Code[20];LineType@1101904008 : Integer;LineNo@1101904007
: Integer;DocTypeDestin@1101904001 : Integer;DocNoDestin@1101904002 :
Code[20];LineNoDestin@1101904003 : Integer);
VAR
ServiceLineDest@1101904004 : Record 25006146;
ResourcesText@1101904006 : Text[250];
BEGIN
//Allocation Entry No.,Document Type,Document No.,Line No.
ServiceSetup.GET;
IF NOT ServiceSetup."Service Schedule Active" THEN BEGIN
ResourcesText := GetRelatedResources(DocType, DocNo, LineType, LineNo, 0);
IF ServiceLineDest.GET(DocTypeDestin, DocNoDestin, LineNoDestin) THEN
SetRelatedResources(DocType, DocNo, LineType, LineNo, ResourcesText, 0);
END;
//means that schedule entries we are not going to copy
END;
PROCEDURE FillRelatedApplicOfEntry@1101904032(VAR
ServLaborAllocApplicationPar@1101904000 : Record 25006277;EntryNoPar@1101904001 :
Integer;VAR LineNoPar@1101904002 : Integer;DocType@1101904006 :
Integer;DocNo@1101904007 : Code[20];ResourceNoPar@1101904008 :
Code[20];NextNewAllocEntryNo@1101904009 : Integer);
VAR
LaborAllocEntryL@1101904004 : Record 25006271;
LaborAllocApplicationL@1101904005 : Record 25006277;
ServLaborAllocationEntryTmp@1101904003 : TEMPORARY Record 25006271;
BEGIN
IF LaborAllocEntryL.GET(EntryNoPar) THEN BEGIN
LaborAllocApplicationL.SETRANGE("Document Type", LaborAllocEntryL."Source
Subtype");
LaborAllocApplicationL.SETRANGE("Document No.", LaborAllocEntryL."Source
ID");
LaborAllocApplicationL.SETRANGE("Allocation Entry No.",
LaborAllocEntryL."Entry No.");
IF LaborAllocApplicationL.FINDFIRST THEN
LineNoPar := LaborAllocApplicationL."Document Line No.";
EXIT(RetValue);
END;
PROCEDURE CopyServLaborAllocApplFromDetServLedg@25006000(FromDocType@25006006 :
'Quote,Order,Return Order,Invoice,Credit Memo,Blanket Order';FromDocNo@25006005 :
Code[20];FromLineNo@25006004 : Integer;ToServLine@25006002 : Record 25006146);
VAR
NewServLaborAllocAppl@25006000 : Record 25006277;
ServLedgEntry@25006001 : Record 25006167;
DetServLedgEntry@25006003 : Record 25006188;
BEGIN
WITH ServLedgEntry DO BEGIN
RESET;
SETRANGE("Document Type", FromDocType);
SETRANGE("Document No.", FromDocNo);
SETRANGE("Document Line No.", FromLineNo);
IF FINDSET THEN
REPEAT
DetServLedgEntry.RESET;
DetServLedgEntry.SETRANGE("Service Ledger Entry No.","Entry No.");
IF DetServLedgEntry.FINDSET THEN
REPEAT
IF Resource.GET(DetServLedgEntry."Resource No.") THEN BEGIN
Resource.TESTFIELD(Blocked, FALSE);
NewServLaborAllocAppl.INIT;
NewServLaborAllocAppl."Allocation Entry No." := 0;
NewServLaborAllocAppl."Document Type" := ToServLine."Document Type";
NewServLaborAllocAppl."Document No." := ToServLine."Document No.";
NewServLaborAllocAppl."Document Line No." := ToServLine."Line No.";
NewServLaborAllocAppl."Line No." += 10000;
NewServLaborAllocAppl."Resource No." := DetServLedgEntry."Resource
No.";
NewServLaborAllocAppl."Finished Quantity (Hours)" :=
ABS(DetServLedgEntry."Finished Quantity (Hours)");
NewServLaborAllocAppl."Time Line" := TRUE;
NewServLaborAllocAppl."Unit Cost" := DetServLedgEntry."Unit Cost";
NewServLaborAllocAppl."Finished Cost Amount" :=
ABS(DetServLedgEntry."Cost Amount");
NewServLaborAllocAppl."Cost Amount" := ABS(DetServLedgEntry."Cost
Amount");
NewServLaborAllocAppl.Posted := FALSE;
NewServLaborAllocAppl.INSERT(TRUE);
END;
UNTIL DetServLedgEntry.NEXT=0;
UNTIL NEXT = 0;
END;
END;
BEGIN
{
05.10.2018 EB.P7 Bug in email
Modified functions:
AllocateStandardEvent
AllocateServiceLines
AllocateServiceOrder
AllocationSetParam
11.06.2015 EB.P7 #Schedule3.0
GetAllocRecDescr Modified.
12.12.2014 EB.P8
Small fix.
10.12.2013 EDMS P8
* fix when lost "Applies-to Entry No."
22.11.2013 EDMS P8
20.11.2013 EDMS P8
* small changes in user rights
* add functions ErrorWithRefresh
24.10.2013 EDMS P8
* Implement use of T25006268. New UpdateAllocDetailsText
17.10.2013 EDMS P8
* now able to start job with change resource
* now able to start FEW jobs if Resource."Allow Several Jobs AtOnce"
15.08.2013 EDMS P8
* fix for case: ON HOLD it did finish current allocation with correct end
time but did not createhold allocation part...
* CHANGE IN FindSplitEntries
12.08.2013 EDMS P8
* fix for case: try to Break allocation in process without chosen
T25006272.Code, now it will bring error
* fix for case: finished splitten allocation should react on moving the
same as it is in other status, like 'Pending'
20.07.2013 EDMS P8
* fix for case: create new allocation that is going to be splitten in
several parts it made unrelated allocations
* fix for case: if once push on finished allocation that is continuous on
unavailable time as well it made split
* fix for case: resize allocation in case of split it did split and in new
allocation other status than first
* fix for case: at start of split allocation it did increase total time.
* fix for case: at finish of split allocation it did left other allocation
in progress, but should delete it.
* fix for case: at Hold Allocation on serv doc allocat. it brought error ''
(do not create correct application line for next new allocat.).
* fix for case: at Hold Allocation on SPLITTEN allocation it made one hold
allacation and last alloc. part left 'In Process'
09.07.2013 EDMS P8
* fix to make new allocation line - it was created for wholo header
instead...
28.06.2013 EDMS P8
* fix error message "Not found Alloc Entry,,,"
* add COMgeVar.RUNMODAL