Adding additional stickers when printing profile stickers with additional information
This script is rather complicated in application compared to other scripts. Task: it is necessary, based on certain conditions, to add additional stickers to the cycle of stickers on the profile to display additional information (for example, additional stickers on the parts of the sash where the handle is installed to display detailed information on the hardware on this sash). This task is accomplished by the presence of two events in the print module OnPrintOtchetCyclePrepare and OnPrintOtchetElemVisiblePrepare (the third event OnPrintOtchetBeforeBuild is not used in this script). The OnPrintOtchetCyclePrepare event is executed after any cycle is prepared. Thanks to this event we can specify in advance the ID of the print form and the ID of the loop element we will influence (here is the line if not((PrintModule.CurPrintOtchetId=109)and(PrintModule.CurPrintObjectId=1)) then exit;). The point of our influence is to add some additional stickers to the standard set of stickers in the loop and assign some label to them in the Tag field, which will allow us to further process the conditions of displaying inscriptions in the standard and additional stickers based on this information. The second part of the task is solved by the OnPrintOtchetElemVisiblePrepare event, which is executed at the moment of determining the necessity of displaying this or that element. Knowing in advance that we have added several additional stickers with a certain Tag field in the loop, and knowing in advance the identifier of the printing form and the identifiers of the elements whose visibility we need to influence, we can leave the standard inscriptions in the standard stickers, and hide the standard inscriptions in the newly added stickers and display only the additional inscriptions (the additional inscriptions should be added to the printing form in advance with the help of the printing form editor, the script will simply influence their visibility).
procedure OnPrintOtchetBeforeBuild; begin //Showmessage('Event BB!!! '+inttostr(PrintModule.CurPrintOtchetId)+', '+inttostr(PrintModule.CurPrintObjectId)); end; procedure OnPrintOtchetCyclePrepare; var i:integer; rpr1,rpr2:TCycleRPRItem; reil:TId32L; rdiout:TRaskrDetalItem; begin //Showmessage('Event CP!!! '+inttostr(PrintModule.CurPrintOtchetId)+', '+inttostr(PrintModule.CurPrintObjectId)); if not((PrintModule.CurPrintOtchetId=109)and(PrintModule.CurPrintObjectId=1)) then exit; i:=0; while i<=PrintData.RPRDet.Items.Count-1 do begin rpr1:=PrintData.RPRDet.Items.GetByNum(i); if (rpr1.detnum>=0)and(rpr1.Tag=) then begin reil:=rpr1.rei.GetElm(rpr1.detnum); rdiout:=gd.RaskrProf.InDetales.GetById(reil.Id); if rdiout.Ruchka then begin rpr2:=TCycleRPRItem.Create; rpr2.Assign(rpr1); rpr2.Tag:='Ruch1'; PrintData.RPRDet.Items.InsertBeforeNum(rpr2,aimYes,i+1); rpr2:=TCycleRPRItem.Create; rpr2.Assign(rpr1); rpr2.Tag:='Ruch2'; PrintData.RPRDet.Items.InsertBeforeNum(rpr2,aimYes,i+1); rpr2:=TCycleRPRItem.Create; rpr2.Assign(rpr1); rpr2.Tag:='Ruch3'; PrintData.RPRDet.Items.InsertBeforeNum(rpr2,aimYes,i+1); end; end; inc(i); end; end; procedure OnPrintOtchetElemVisiblePrepare; var rpr1:TCycleRPRItem; poi:TPrintObjectItem; popi:TPrintObjectPositionItem; begin //Showmessage('Event EVP!!! '+inttostr(PrintModule.CurPrintOtchetId)+', '+inttostr(PrintModule.CurPrintObjectId)); if not((PrintModule.CurPrintOtchetId=109)and(PrintModule.CurPrintObjectId=7)) then exit; rpr1:=PrintData.RPRDet.Items.GetByNum(PrintData.RPRDet.ItemPos); if (rpr1.detnum>=0)and(rpr1.Tag='Ruch2') then begin poi:=PrintModule.CurPrintObject; if poi is TPrintObjectPositionItem then begin popi:=TPrintObjectPositionItem(poi); popi.Visible:=false; end; //PrintModule.CurPrintObject.Visible:=false; end; end;