OnBeforeSave ; Parameters: IsNew ;Do ..CleanUpMem() Quit CleanUpMem #define IsTemplateProduct ..Product.Template #define BfSave 2 ;d ..Product.TTrace("%OnBeforeSave ("_$J($G(^wvTest)+1,4)_") "_..Code_" TPL="_(+..Product.Template)_" DI oref="_%this) If '$$$IsTemplateProduct Do . ;s ^wvTest=$G(^wvTest)+1 . ;m ^wvTest(^wvTest,..Product.%Id())=^Prod.GAData.ProductD(..Product.%Id()) . ;d ..Product.TTrace(" Clear Data Item") . Do ..Autos.Clear() . Do ..ClearDataParams($$$BfSave) Quit ValidatePR() ; Parameters: (geen) New okPR If ..MetaItem.%ClassName(0)?1"ItemPR".E Do . Set okPR=..MetaItem.ValidatePR(%this) Else Set okPR=1 Quit okPR ClearDataParams ; Parameters: ClearMode #define Recalc 1 #define BfSave 2 New ModeClr ;d WL^vhDBG("clrDP: "_..Code_" Lbl:"_..Label_" "_%this) Quit:($G(ClearMode)="") Set ModeClr=$CASE(ClearMode, $$$Recalc:$LB("C","M"), $$$BfSave:$LB("C"), :"") If $L(ModeClr) Do . New PKey,MParam . Set PKey="" . For Set MParam=..MetaItem.Parameters.GetNext(.PKey) Quit:(PKey="") Do .. Quit:(..IsFixed(PKey)) .. Do:(MParam)&&($LF(ModeClr,MParam.Mode)>0) ..Parameters.RemoveAt(PKey) ; Do:(MParam)&&(ModeClr[MParam.Mode) .. ;Do:(MParam)&&($LF(ModeClr,MParam.Mode)>0) WL^vhDBG("clrDP: PKey="_PKey_" mode="_MParam.Mode) Else Do . Do ..Parameters.Clear() Quit IsActief() ; Parameters: ForceRecalc #define Actief "Actief" Quit:('$G(ForceRecalc)||(..IsFixed($$$Actief)))&&(..Parameters.IsDefined($$$Actief)) $$iacTransform(..Parameters.GetAt($$$Actief)) New tmpAct Set tmpAct=$$iacTransform(..Eval($$$Actief,,.ForceRecalc)) Do ..Parameters.SetAt(tmpAct,$$$Actief) Quit tmpAct iacTransform(tmpAct) Quit $S(tmpAct="":1, 1:tmpAct>0) #include %VHMacro CalcAll ; Parameters: (geen) #define UpdTypePL "PL" New arItems Set arItems(1)=%this If '..IsActief(1) Do Quit . Do ..Product.UpdateLookUpClean($$$UpdTypePL,.arItems) ; Else New MItem,MParam,lbSort,lbSort2,PKey,i Set MItem=..MetaItem Set (lbSort,lbSort2)="" Set PKey="" For Set MParam=MItem.Parameters.GetNext(.PKey) Quit:(PKey="") Do:(MParam.Mode'?1(1"E",1"L")) . If MParam.KolomNr>0 Set $LI(lbSort,MParam.KolomNr)=PKey . Else Set lbSort2=lbSort2_$LB(PKey) Set lbSort=lbSort_lbSort2 For i=1:1:$LL(lbSort) Do:($L($LG(lbSort,i))) ..Eval($LI(lbSort,i),,1) ;d WL^vhDBG("CalcAll: "_..Code_" Lbl:"_..Label_" "_%this) Do ..Product.UpdateLookUp($$$UpdTypePL,.arItems) If (..Autos.IsDefined("AfterCalc")) Do ..EvalTemplAuto("AfterCalc") ; Xecute kan een globale variabele definieren. Quit Get() ; Parameters: Key,ItemLabel #define Actief "Actief" New DItem If $L($G(ItemLabel)) Do Quit $S($IsObject(DItem):DItem.Get(Key), 1:"") . Set DItem=$G(..Product.LookUp("IL",ItemLabel)) ; Else Quit:(Key=$$$Actief) ..IsActief() Quit:(..Parameters.IsDefined(Key)) ..Parameters.GetAt(Key) ;d:(..Label?1(1"PRSTANG",1"LZ")) ..Product.TTrace("==> Get voor Key "_Key_" : autos="_..Autos.GetAt(Key)) New MParam Set MParam=..MetaItem.Parameters.GetAt(Key) Quit:('MParam) "" If MParam.Mode?1(1"L",1"E") Quit ..Autos.GetAt(Key) Else If MParam.Mode?1(1"M",1"C") Quit ..Eval(Key) Quit "" Eval() ; Parameters: Key,ItemLabel,Forced,SkipActief #define Actief "Actief" #define DItemActief (DItem.IsActief(.Forced)) New DItem If $L($G(ItemLabel)) Do Quit $S($IsObject(DItem)&&((Key=$$$Actief)||($G(SkipActief))||$$$DItemActief):DItem.Eval(Key,,.Forced), 1:"") . Set DItem=$G(..Product.LookUp("IL",ItemLabel)) ; Else New MParam,RetVal Set MParam=..MetaItem.Parameters.GetAt(Key) Quit:('MParam) "" Quit:(MParam.Mode="E") ..EvalFormule(Key) Quit:('$G(Forced)||(..IsFixed(Key)))&&(..Parameters.IsDefined(Key)) ..Parameters.GetAt(Key) ;d ..Product.TTrace("EVAL "_..Code_" Lbl:"_..Label_" Key:"_Key_" ") ;d:(..Label?1(1"PRSTANG",1"LZ")) ..Product.TTrace("Eval voor Key "_Key) Set RetVal=..EvalAutos(Key) Do:(MParam.Mode?1(1"M",1"C")) ..Parameters.SetAt(RetVal,Key) Quit RetVal EvalTemplAuto() ; Parameters: Key New TPAuto,RetVal Set TPAuto=..Autos.GetAt(Key) If $L(TPAuto) Do Quit $G(RetVal) ; TemplateAuto uitvoeren en RetVal teruggeven . If $L(TPAuto,"`")=1 Set RetVal=TPAuto . Else Do .. New Self,Meta .. Set Self=%this .. Set Meta=%this.MetaItem .. Do evaExecRes($P(TPAuto,"`",1),$P(TPAuto,"`",2)) Quit "" EvalMetaAuto() ; Parameters: Key New MParam,RetVal Set MParam=..MetaItem.Parameters.GetAt(Key) Quit:('MParam)||(MParam.Auto="") "" ;d:(Key'?1"ProgLabel".E) ..Product.TTrace("EvalM "_..Code_" Lbl:"_..Label_" Key:"_Key_" ") New Self,Meta Set Self=%this Set Meta=%this.MetaItem Do evaExecRes($P(MParam.Auto,"`",1),$P(MParam.Auto,"`",2)) Quit RetVal EvalAutos() ; Parameters: Key New TPAuto,RetVal Set TPAuto=..Autos.GetAt(Key) If $L(TPAuto) Do Quit $G(RetVal) ; TemplateAuto uitvoeren en RetVal teruggeven . If $L(TPAuto,"`")=1 Set RetVal=TPAuto . Else Do .. New Self,Meta .. Set Self=%this .. Set Meta=%this.MetaItem .. Do evaExecRes($P(TPAuto,"`",1),$P(TPAuto,"`",2)) ; Else: MetaAuto uitvoeren Quit ..EvalMetaAuto(Key) evaExecRes(VExecType,VExec) Do EXEC^vhRES(VExecType,VExec,"RetVal",,"evaTRAP^"_$ZN) ; RetVal wordt teruggekregen ;d:(VExec["Self.Val(""LG"")") WLFMT^vhDBG(" > Self.Val(""LG"")="_Self.Val("LG")_", Self.Val(""DS"")="_Self.Val("DS"),"I") Quit evaTRAP New msg Set msg="EXECUTE FOUT: "_sTyp_"`"_sExecTxt_"`"_$G(sParList) Do WLFMT^vhDBG(msg,"A") Do WLFMT^vhDBG("Bij Key :"_Key_" van DItem:"_..Code_" Label:"_..Label_" Meta:"_..MetaItem.Code,"A") Do evaDebugDItem Do:($D(MApplication)) MApplication.MessageBox(msg) ; Foutmelding voor Makova Set RetVal="" ; 0.001 Quit 1 ; Doorgeven errormelding evaDebugDItem New tmpLB,PKey,MParam Set tmpLB="" Set PKey="" For Set MParam=..MetaItem.Parameters.GetNext(.PKey) Quit:(PKey="") Do:(MParam.KolomNr>0) . Set $LI(tmpLB,MParam.KolomNr)=$LB(PKey,..Parameters.GetAt(PKey)) Do WL^vhDBG($$LCVT^vhLib(tmpLB)) Quit EvalFormule() ; Parameters: Key ; Voor de evaluatie van DItems waarvan MParam.Mode="E" ; Defaulting via Template-Data of Template-Autos Quit:(..Parameters.IsDefined(Key)) $$evaExecExpr(..Parameters.GetAt(Key)) Quit $$evaExecExpr(..Autos.GetAt(Key)) evaExecExpr(sExpr) New RetVal New Self,Meta Set Self=%this Set Meta=%this.MetaItem Do evaExecRes("@",$$evaTranslateExpr(sExpr)) ;d WLFMT^vhDBG("EvalFormule: bij Key :"_Key_" van DItem:"_..Code_" Label:"_..Label_" RetVal:"_RetVal,"W") Quit $G(RetVal) evaTranslateExpr(sExpr) Quit sExpr CopyParamsFromMeta ; Parameters: (geen) Quit:('..MetaItem) New PKey,MItem,MParam Set MItem=..MetaItem Set PKey="" For Set MParam=MItem.Parameters.GetNext(.PKey) Quit:(PKey="") Do . Do ..Parameters.SetAt($$cpfmGetValue,PKey) Quit cpfmGetValue() Quit "" ; PKey_""_..Code CalcCode() ; Parameters: (geen) Quit:('..Product) "" Quit:('..MetaItem) "" New mc,PrevCode,tmpLU Set mc=..MetaItem.Code Set PrevCode=$O(..Product.LookUp("ISort","Code",mc_"999"),-1) Quit mc_$S($E(PrevCode,1,$L(mc))=mc:$$LeftPad^vhLib($P(PrevCode,mc,2)+1,3), 1:"001") CalcVolgNr() ; Parameters: (geen) Quit:('..Product) "" Quit:(..SubGroepCode="") "" Quit $O(..Product.LookUp("ISort","VNr",..SubGroepCode,""),-1)+1 CopyObject() ; Parameters: CopyMode #define InList(%v) $LF(lbCopyPropt,%v)>0 New NewItem,lbCopyPropt Do cpoGetProptList Set NewItem=##class(Prod.GAData.Item).%New() Set:($$$InList("C")) NewItem.Code=..Code Do:($$$InList("M")) NewItem.MetaItemSetObjectId(..MetaItemGetObjectId()) Do:($$$InList("P")) NewItem.ProductSetObjectId(..ProductGetObjectId()) Set:($$$InList("S")) NewItem.SubGroepCode=..SubGroepCode Set:($$$InList("D")) NewItem.Display=..Display Set:($$$InList("L")) NewItem.Label=..Label Set:($$$InList("V")) NewItem.VolgNr=..VolgNr If $$$InList("PA") Do ; array property Parameters . New PKey,PrmVal . Set PKey="" . For Set PrmVal=..Parameters.GetNext(.PKey) Quit:(PKey="") Do NewItem.Parameters.SetAt(PrmVal,PKey) If $$$InList("A") Do ; array property Autos . New PKey,AutoVal . Set PKey="" . For Set AutoVal=..Autos.GetNext(.PKey) Quit:(PKey="") Do NewItem.Autos.SetAt(AutoVal,PKey) If $$$InList("KT") Do cpoCopyEMKostArray(..KostTijd,NewItem.KostTijd) If $$$InList("KM") Do cpoCopyEMKostArray(..KostMat, NewItem.KostMat) Quit NewItem cpoCopyEMKostArray(ArrayKostOrig,ArrayKostNew) New PKey,emKost,NewKost Set PKey="" For Set emKost=ArrayKostOrig.GetNext(.PKey) Quit:(PKey="") Do . Set NewKost=emKost.CopyObject("FullCopy") . Do ArrayKostNew.SetAt(NewKost,PKey) . Do NewKost.%Close() cpoGetProptList ; CopyProptList bevat alle properties (per propt. één Char.), die moeten gekopieerd worden: ; volledige lijst is: "C;D;L;M;P;S;V;PA;KT;KM;A" New CopyProptList,i If CopyMode="FullCopy" Do ; Copy alle properties . Set CopyProptList="C;D;L;M;P;S;V;PA;KT;KM;A" Else If CopyMode="NotProd" Do ; Parent (Product) niet kopiëren . Set CopyProptList="C;D;L;M;S;V;PA;KT;KM;A" Else If CopyMode="NotProd&Kost" Do ; Parent (Product) en Kost-arrays (KostTijd+KostMat) niet kopiëren . Set CopyProptList="C;D;L;M;S;V;PA;A" Else If CopyMode="Empty" Do ; Geen properties invullen . Set CopyProptList="" Else Do ; CopyMode is onbekend. . Set CopyProptList="" Set lbCopyPropt="" For i=1:1:$L(CopyProptList,";") Set lbCopyPropt=lbCopyPropt_$LB($P(CopyProptList,";",i)) Quit