source: EWD/r/KBANEWD1.m@ 1240

Last change on this file since 1240 was 1216, checked in by Sam Habiel, 13 years ago

Added VALKBANEWD1 as a wrapper around VALDIE

File size: 3.5 KB
Line 
1KBANEWD1 ; KBAN/SMH - Custom Tag Processor ; 8/14/11 9:08pm
2 ;;
3SS(nodeOID,attrValues,docOID,technology) ; <fm:session /> to get VISTA Session Variables
4 N attr
5 S attr("method")="SS2^KBANEWD1"
6 S attr("param1")="#ewd_sessid"
7 S attr("type")="procedure"
8 N xOID s xOID=$$addElementToDOM^%zewdDOM("ewd:execute",nodeOID,"",.attr)
9 D removeIntermediateNode^%zewdDOM(nodeOID)
10 quit
11SS2(sessid)
12 d mergeArrayFromSession^%zewdAPI(.DUZ,"DUZ",sessid)
13 d mergeArrayFromSession^%zewdAPI(.IO,"IO",sessid)
14 s U=$$getSessionValue^%zewdAPI("U",sessid)
15 quit
16EDIT(nodeOID,attrValues,docOID,technology) ; Fileman Field Edit tag
17 ; Get Attributes supplied to us: dd, fields, iens
18 ;
19 N attrs
20 D getAttributeValues^%zewdCustomTags(nodeOID,.attrs)
21 N DD S DD=$g(attrs("dd")) ; Data Dictionary
22 N FIELDS S FIELDS=$g(attrs("fields")) ; Fields to Edit
23 N IENS S IENS=$g(attrs("iens")) ; IENs to Edit
24 ;
25 ; Does our Form Tag Exist?
26 N fOID S fOID=$$getElementById^%zewdDOM("fmEdit",docOID)
27 ; -----
28 ; If it doesn't exist, create it
29 IF fOID="" DO
30 . ; Create the Form Tag
31 . ; Attributes
32 . N attr
33 . S attr("name")="fmEdit"
34 . S attr("id")="fmEdit"
35 . S attr("action")="ewd"
36 . S attr("method")="post"
37 . ;
38 . ; Add form
39 . S fOID=$$addElementToDOM^%zewdDOM("form",nodeOID,"",.attr,"")
40 ; -----
41 ; Destination Input Name
42 N dst S dst="DD"_$TR(DD,".","_")_"F"_$TR(FIELDS,".","_")
43 ;
44 ; Build <ewd:execute> to set the value of the default; child of form in fOID
45 K attr
46 S attr("method")="XTARGET^KBANEWD1"
47 S attr("param1")="#ewd_sessid"
48 S attr("param2")=dst
49 S attr("param3")=DD
50 S attr("param4")=$$stripSpaces^%zewdAPI(phpVars($P(IENS,"&php;",2))) ; becomes #DUZ
51 S attr("param5")=FIELDS
52 S attr("type")="procedure"
53 N xOID s xOID=$$addElementToDOM^%zewdDOM("ewd:execute",fOID,"",.attr)
54 ;
55 ; Add label
56 N text S text=$$GET1^DID(DD,FIELDS,"","LABEL") ; this should be i18n in MSC FM
57 S text=text_": "
58 K attr S attr("for")=dst
59 N lOID s lOID=$$addElementToDOM^%zewdDOM("label",fOID,"",.attr,text)
60 ; ------------
61 ;
62 ; Add Input Tag
63 ; Attributes
64 K attr
65 S attr("type")="text" ; Should be dynamic based on FM DataType
66 S attr("name")=dst
67 S attr("value")="*"
68 ;
69 ; Add input Tag under form tag
70 N iOID S iOID=$$addElementToDOM^%zewdDOM("input",fOID,"",.attr,"")
71 ;
72 ; Remove custom tag
73 D removeIntermediateNode^%zewdDOM(nodeOID)
74 ;break
75 QUIT
76 ;
77 ; ---
78 ;
79XTARGET(sessid,fieldName,DD,IENS,FIELDS) ; Proc - Xecute Target - Adds Default Value to Sess
80 N VAL S VAL=$$GET1^DIQ(DD,IENS,FIELDS)
81 D setSessionValue^%zewdAPI(fieldName,VAL,sessid)
82 QUIT
83 ;
84 ; ---
85 ;
86VAL(sessid)
87 D setSessionValue^%zewdAPI("tmp.error","Null Validation",sessid)
88 D setSessionValue^%zewdAPI("tmp.name","testdiv",sessid) ; testdiv hardcoded for now.
89 N KBANDD S KBANDD=+$TR($P(requestArray("name"),"DD",2),"_",".") ; todo: check for 0 value
90 N KBANF S KBANF=+$TR($P(requestArray("name"),"F",2),"_",".") ; todo: check for 0 value
91 N KBANIENS S KBANIENS=requestArray("iens")
92 I $E(KBANIENS,$L(KBANIENS))'="," S KBANIENS=KBANIENS_","
93 N KBANV S KBANV=requestArray("value") ; todo: unescape urlencoding.
94 N KBANRESULT ; Result
95 N KBANMSG
96 D VAL^DIE(KBANDD,KBANIENS,KBANF,"E",KBANV,.KBANRESULT,"","KBANMSG")
97 I $D(KBANMSG) K ^ZZSAM M ^ZZSAM=KBANMSG
98 ; KBANMSG(DIERR,1,TEXT,1) can be longer than one line (last subscript)... loop...
99 ; HTML formatting for error message???
100 I KBANRESULT="^" D setSessionValue^%zewdAPI("tmp.error",KBANMSG("DIERR",1,"TEXT",1),sessid)
101 E D
102 . D setSessionValue^%zewdAPI("tmp.result","Success in Validating: "_$$SYMENC^MXMLUTL($$SYMENC^MXMLUTL(KBANRESULT(0))),sessid)
103 . D setSessionValue^%zewdAPI("tmp.error","",sessid)
104 QUIT ""
Note: See TracBrowser for help on using the repository browser.