Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Pman.Dialog.XtupleContact.bjs
1 {
2     "id": "roo-file-2",
3     "name": "Pman.Dialog.XtupleContact",
4     "parent": "Pman",
5     "title": "",
6     "path": "/home/edward/gitlive/web.xtuple/Pman/Xtuple/Pman.Dialog.XtupleContact.bjs",
7     "items": [
8         {
9             ".builderCfg": "{\"cols\":[{\"table\":\"cntct\",\"column\":\"cntct_id\",\"columnshort\":\"cntct_id\",\"ctype\":\"int4\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\",\"display\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_addr_id\",\"columnshort\":\"cntct_addr_id\",\"ctype\":\"int4\",\"desc\":\"\",\"maps_to\":\"addr_id\",\"deps\":[{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_active\",\"columnshort\":\"addr_active\",\"ctype\":\"bool\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_line1\",\"columnshort\":\"addr_line1\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_line2\",\"columnshort\":\"addr_line2\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_line3\",\"columnshort\":\"addr_line3\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_city\",\"columnshort\":\"addr_city\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_state\",\"columnshort\":\"addr_state\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_postalcode\",\"columnshort\":\"addr_postalcode\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_country\",\"columnshort\":\"addr_country\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_notes\",\"columnshort\":\"addr_notes\",\"ctype\":\"text\",\"desc\":\"\"},{\"table\":\"addr\",\"column\":\"cntct_addr_id_addr_number\",\"columnshort\":\"addr_number\",\"ctype\":\"text\",\"desc\":\"\"}],\"use\":1,\"use_ex\":\"\",\"title\":\"\",\"display\":\"cntct_addr_id_addr_line1\"},{\"table\":\"cntct\",\"column\":\"cntct_first_name\",\"columnshort\":\"cntct_first_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_last_name\",\"columnshort\":\"cntct_last_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_honorific\",\"columnshort\":\"cntct_honorific\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_initials\",\"columnshort\":\"cntct_initials\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_active\",\"columnshort\":\"cntct_active\",\"ctype\":\"bool\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_phone\",\"columnshort\":\"cntct_phone\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_phone2\",\"columnshort\":\"cntct_phone2\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_fax\",\"columnshort\":\"cntct_fax\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_email\",\"columnshort\":\"cntct_email\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_webaddr\",\"columnshort\":\"cntct_webaddr\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_notes\",\"columnshort\":\"cntct_notes\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_title\",\"columnshort\":\"cntct_title\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_number\",\"columnshort\":\"cntct_number\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_middle\",\"columnshort\":\"cntct_middle\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_suffix\",\"columnshort\":\"cntct_suffix\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"},{\"table\":\"cntct\",\"column\":\"cntct_name\",\"columnshort\":\"cntct_name\",\"ctype\":\"text\",\"desc\":\"\",\"use\":1,\"use_ex\":\"\",\"title\":\"\"}],\"cols_ex\":[\"cntct_addr_id_addr_line1\"],\"table\":\"cntct\",\"xtype\":\"LayoutDialog\",\"|xns\":\"Roo\"}",
10             "closable": false,
11             "collapsible": false,
12             "height": 450,
13             "modal": true,
14             "resizable": false,
15             "title": "Contact Details",
16             "width": 800,
17             "xtype": "LayoutDialog",
18             "|xns": "Roo",
19             "items": [
20                 {
21                     "|xns": "Roo",
22                     "xtype": "LayoutRegion",
23                     "*prop": "center"
24                 },
25                 {
26                     "region": "center",
27                     "xtype": "ContentPanel",
28                     "|xns": "Roo",
29                     "items": [
30                         {
31                             "listeners": {
32                                 "|actioncomplete": "function(_self,action)\n{\n    if (action.type == 'setdata') {\n        if (_this.data.cntct_id) {\n            this.load({ method: 'GET', params: { '_id' : _this.data.cntct_id }});\n            return;\n        } \n        // we need to fetch crmct id..\n        new Pman.Request({\n            method : 'GET',\n            url : baseURL + '/Roo/crmacct',\n            params : {\n                crmacct_cust_id : _this.data.customer_id\n            },\n            success : function(r) {\n//                Roo.log(r);\n                try {\n                    _this.form.findField('cntct_crmacct_id').setValue(r.data[0].crmacct_id);\n                } catch(e) {\n                    Roo.MessageBox.alert(\"Error\", \"Sorry, we failed got get some data from the server, please cancel and try again\");\n                }\n            }\n        });\n\n    }\n    if (action.type == 'load') {\n        _this.form.findField('cntct_name').sync();\n          _this.form.findField('addr_view').sync();\n    \n        return;\n    }\n    if (action.type =='submit') {\n    \n        _this.dialog.hide();\n         _this.form.setValues(action.result.data);\n         if (_this.callback) {\n            _this.callback.call(_this, _this.form.getValues());\n         }\n         _this.form.reset();\n         return;\n    }\n}\n",
33                                 "|rendered": "function (form)\n{\n    _this.form= form;\n}\n"
34                             },
35                             "method": "POST",
36                             "style": "margin:10px;",
37                             "xtype": "Form",
38                             "|url": "baseURL + '/Roo/cntct.php'",
39                             "|xns": "Roo.form",
40                             "items": [
41                                 {
42                                     "legend": "Details",
43                                     "style": "width:750px",
44                                     "xtype": "FieldSet",
45                                     "|xns": "Roo.form",
46                                     "items": [
47                                         {
48                                             "labelAlign": "right",
49                                             "labelWidth": 70,
50                                             "width": 800,
51                                             "xtype": "Row",
52                                             "|xns": "Roo.form",
53                                             "items": [
54                                                 {
55                                                     "listeners": {
56                                                         "blur": "function (_self)\n{\n _this.form.findField('cntct_name').sync();\n}"
57                                                     },
58                                                     "allowBlank": true,
59                                                     "displayField": "hnfc_code",
60                                                     "editable": false,
61                                                     "emptyText": "Title",
62                                                     "fieldLabel": "Name",
63                                                     "hiddenName": "cntct_honorific",
64                                                     "listWidth": 400,
65                                                     "loadingText": "Searching...",
66                                                     "minChars": 2,
67                                                     "name": "cntct_honorific",
68                                                     "qtip": "Select title",
69                                                     "queryParam": "query[addr_line1]",
70                                                     "selectOnFocus": true,
71                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{hnfc_code}</b> </div>",
72                                                     "triggerAction": "all",
73                                                     "typeAhead": true,
74                                                     "valueField": "hnfc_code",
75                                                     "width": 60,
76                                                     "xtype": "ComboBox",
77                                                     "|xns": "Roo.form",
78                                                     "items": [
79                                                         {
80                                                             "*prop": "store",
81                                                             "|xns": "Roo.data",
82                                                             "|sortInfo": "{ direction : 'ASC', field: 'addr_line1' }",
83                                                             "xtype": "Store",
84                                                             "remoteSort": true,
85                                                             "listeners": {
86                                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
87                                                             },
88                                                             "items": [
89                                                                 {
90                                                                     "*prop": "proxy",
91                                                                     "method": "GET",
92                                                                     "xtype": "HttpProxy",
93                                                                     "|url": "baseURL + '/Roo/hnfc.php'",
94                                                                     "|xns": "Roo.data"
95                                                                 },
96                                                                 {
97                                                                     "*prop": "reader",
98                                                                     "id": "hnfc_id",
99                                                                     "root": "data",
100                                                                     "totalProperty": "total",
101                                                                     "xtype": "JsonReader",
102                                                                     "|fields": "[{'name':'hnfc_id','type':'int'},'hnfc_code']",
103                                                                     "|xns": "Roo.data"
104                                                                 }
105                                                             ]
106                                                         }
107                                                     ]
108                                                 },
109                                                 {
110                                                     "hideLabels": true,
111                                                     "labelAlign": "top",
112                                                     "width": 700,
113                                                     "xtype": "Row",
114                                                     "|xns": "Roo.form",
115                                                     "items": [
116                                                         {
117                                                             "listeners": {
118                                                                 "keyup": "function (_self, e)\n{\n       _this.form.findField('cntct_name').sync();\n}"
119                                                             },
120                                                             "fieldLabel": "first_name",
121                                                             "name": "cntct_first_name",
122                                                             "qtip": "First name",
123                                                             "width": 200,
124                                                             "xtype": "TextField",
125                                                             "|xns": "Roo.form"
126                                                         },
127                                                         {
128                                                             "listeners": {
129                                                                 "keyup": "function (_self, e)\n{\n       _this.form.findField('cntct_name').sync();\n}"
130                                                             },
131                                                             "fieldLabel": "initials",
132                                                             "name": "cntct_initials",
133                                                             "qtip": "Initials",
134                                                             "width": 40,
135                                                             "xtype": "TextField",
136                                                             "|xns": "Roo.form"
137                                                         },
138                                                         {
139                                                             "listeners": {
140                                                                 "keyup": "function (_self, e)\n{\n       _this.form.findField('cntct_name').sync();\n}"
141                                                             },
142                                                             "fieldLabel": "last_name",
143                                                             "name": "cntct_last_name",
144                                                             "qtip": "Last name",
145                                                             "width": 200,
146                                                             "xtype": "TextField",
147                                                             "|xns": "Roo.form"
148                                                         }
149                                                     ]
150                                                 }
151                                             ]
152                                         },
153                                         {
154                                             "labelAlign": "right",
155                                             "labelWidth": 70,
156                                             "width": 900,
157                                             "xtype": "Column",
158                                             "|xns": "Roo.form",
159                                             "items": [
160                                                 {
161                                                     "labelAlign": "right",
162                                                     "labelWidth": 70,
163                                                     "width": 900,
164                                                     "xtype": "Row",
165                                                     "|xns": "Roo.form",
166                                                     "items": [
167                                                         {
168                                                             "qtip": "Job Title",
169                                                             "fieldLabel": "Job Title",
170                                                             "name": "cntct_title",
171                                                             "width": 335,
172                                                             "xtype": "TextField",
173                                                             "|xns": "Roo.form"
174                                                         },
175                                                         {
176                                                             "fieldLabel": "Unique#",
177                                                             "name": "cntct_number",
178                                                             "width": 100,
179                                                             "xtype": "TextField",
180                                                             "|xns": "Roo.form"
181                                                         }
182                                                     ]
183                                                 }
184                                             ]
185                                         }
186                                     ]
187                                 },
188                                 {
189                                     "labelAlign": "right",
190                                     "labelWidth": 70,
191                                     "legend": "Contact",
192                                     "style": "width:300px",
193                                     "xtype": "FieldSet",
194                                     "|xns": "Roo.form",
195                                     "items": [
196                                         {
197                                             "fieldLabel": "Phone",
198                                             "name": "cntct_phone",
199                                             "width": 200,
200                                             "xtype": "TextField",
201                                             "|xns": "Roo.form"
202                                         },
203                                         {
204                                             "fieldLabel": "Mobile",
205                                             "name": "cntct_phone2",
206                                             "width": 200,
207                                             "xtype": "TextField",
208                                             "|xns": "Roo.form"
209                                         },
210                                         {
211                                             "fieldLabel": "Fax",
212                                             "name": "cntct_fax",
213                                             "width": 200,
214                                             "xtype": "TextField",
215                                             "|xns": "Roo.form"
216                                         }
217                                     ]
218                                 },
219                                 {
220                                     "legend": "Online",
221                                     "style": "width:400px; margin-left:10px",
222                                     "xtype": "FieldSet",
223                                     "|xns": "Roo.form",
224                                     "items": [
225                                         {
226                                             "fieldLabel": "Email",
227                                             "name": "cntct_email",
228                                             "vtype": "email",
229                                             "width": 250,
230                                             "xtype": "TextField",
231                                             "|xns": "Roo.form"
232                                         },
233                                         {
234                                             "fieldLabel": "Website",
235                                             "name": "cntct_webaddr",
236                                             "vtype": "url",
237                                             "width": 250,
238                                             "xtype": "TextField",
239                                             "|xns": "Roo.form"
240                                         }
241                                     ]
242                                 },
243                                 {
244                                     "hideLabels": true,
245                                     "legend": "Notes",
246                                     "style": "width:300px; clear: both;",
247                                     "xtype": "FieldSet",
248                                     "|xns": "Roo.form",
249                                     "items": [
250                                         {
251                                             "fieldLabel": "notes",
252                                             "height": 100,
253                                             "name": "cntct_notes",
254                                             "width": 290,
255                                             "xtype": "TextArea",
256                                             "|xns": "Roo.form"
257                                         }
258                                     ]
259                                 },
260                                 {
261                                     "hideLabels": true,
262                                     "legend": "Address",
263                                     "style": "width:400px; margin-left:10px",
264                                     "xtype": "FieldSet",
265                                     "|xns": "Roo.form",
266                                     "items": [
267                                         {
268                                             "listeners": {
269                                                 "add": "function (combo)\n{\n   Pman.Dialog.XtupleAddress.show({\n        addr_id : '',\n        customer_id : _this.form.findField('customer_id').getValue()\n   \n   }, function(d) {\n               Roo.log(d);\n        if (!d) {\n            return;\n        }\n        var s = {};\n        for (var k in d) {\n            s['cntct_addr_id_' + k] = d[k];\n        }\n\n        s.cntct_addr_id = d.addr_id;\n        Roo.log(s);                \n        _this.form.setValues(s);\n        // if d contains a value.. use it..\n        _this.form.findField('addr_view').sync();\n   \n   \n   });\n}",
270                                                 "edit": "function (combo, record)\n{\n  Pman.Dialog.XtupleAddress.show({\n        addr_id : this.getValue(),\n        customer_id : _this.form.findField('customer_id').getValue()\n   \n   }, function(d) {\n   \n       // Roo.log(d);\n        if (!d) {\n            return;\n        }\n        var s = {};\n        for (var k in d) {\n            s['cntct_addr_id_' + k] = d[k];\n        }\n        s.cntct_addr_id = d.addr_id;\n        Roo.log(s);\n        _this.form.setValues(s);\n            _this.form.findField('addr_view').sync();\n        // if d contains a value.. use it..\n   \n   });\n}",
271                                                 "select": "function (combo, record, index)\n{\n    var s = {};\n    for (var k in record.data) {\n        s['cntct_addr_id_' + k] = record.data[k];\n    }\n\n    _this.form.setValues(s);\n    _this.form.findField('addr_view').sync();\n}"
272                                             },
273                                             "allowBlank": false,
274                                             "alwaysQuery": true,
275                                             "displayField": "addr_line1",
276                                             "editable": false,
277                                             "emptyText": "Select address",
278                                             "fieldLabel": "addr",
279                                             "forceSelection": true,
280                                             "hiddenName": "cntct_addr_id",
281                                             "listWidth": 400,
282                                             "loadingText": "Searching...",
283                                             "minChars": 2,
284                                             "name": "cntct_addr_id_addr_line1",
285                                             "pageSize": 20,
286                                             "qtip": "Select addr",
287                                             "queryParam": "query[addr_line1]",
288                                             "selectOnFocus": true,
289                                             "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>#{addr_id} - {addr_line1}</b> </div>",
290                                             "triggerAction": "all",
291                                             "typeAhead": true,
292                                             "valueField": "addr_id",
293                                             "width": 380,
294                                             "xtype": "ComboBox",
295                                             "|xns": "Roo.form",
296                                             "items": [
297                                                 {
298                                                     "listeners": {
299                                                         "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    o.params._customer_id = _this.form.findField('customer_id').getValue();\n    // set more here\n}\n"
300                                                     },
301                                                     "*prop": "store",
302                                                     "remoteSort": true,
303                                                     "xtype": "Store",
304                                                     "|sortInfo": "{ direction : 'ASC', field: 'addr_line1' }",
305                                                     "|xns": "Roo.data",
306                                                     "items": [
307                                                         {
308                                                             "*prop": "proxy",
309                                                             "xtype": "HttpProxy",
310                                                             "method": "GET",
311                                                             "|xns": "Roo.data",
312                                                             "|url": "baseURL + '/Roo/addr.php'"
313                                                         },
314                                                         {
315                                                             "*prop": "reader",
316                                                             "id": "addr_id",
317                                                             "root": "data",
318                                                             "totalProperty": "total",
319                                                             "xtype": "JsonReader",
320                                                             "|fields": "[{'name':'addr_id','type':'int'},'addr_line1']",
321                                                             "|xns": "Roo.data"
322                                                         }
323                                                     ]
324                                                 }
325                                             ]
326                                         },
327                                         {
328                                             "fieldLabel": "notes",
329                                             "height": 80,
330                                             "name": "addr_view",
331                                             "width": 380,
332                                             "xtype": "TextArea",
333                                             "|sync": "function() {\n    var vals= _this.form.getFieldValues();\n    var lines = [];\n    if (vals.cntct_addr_id * 1 < 1) {\n        this.setValue(\"No address set, this will cause an error\");\n        return;\n    }\n    for (var i in vals) {\n        if (i.match(/^cntct_addr_id_addr/) && vals[i].length) {\n            lines.push(vals[i]);\n        }\n    }\n    this.setValue(lines.join(\"\\n\"));\n}\n",
334                                             "|xns": "Roo.form"
335                                         }
336                                     ]
337                                 },
338                                 {
339                                     "name": "cntct_name",
340                                     "xtype": "Hidden",
341                                     "|readName": "function() {\n    var ar = [ 'honorific', 'first_name', 'initials', 'last_name' ];\n    var out = [];\n    Roo.each(ar, function (n) {\n        var v = _this.form.findField('cntct_' + n).getValue();\n        if (v.trim().length) {\n            out.push(v.trim());\n        }\n    });\n    return out.join(' ');\n}\n",
342                                     "|sync": "function() {\n    var dname = this.readName();\n    if (!dname.length && this.getValue().length) {\n        _this.form.findField('cntct_first_name').setValue(this.getValue());\n \n          \n    } else {\n    \n        this.setValue(dname);\n    }\n    _this.dialog.setTitle(\"Contact Details - \" + this.getValue());\n    if (_this.form.findField('cntct_id').getValue() * 1 < 1) {\n        var cn = 'C' +    _this.form.findField('customer_id').getValue()  + '-';\n        _this.form.findField('cntct_number').setValue(cn + this.getValue());\n    }\n    \n    \n}\n",
343                                     "|xns": "Roo.form"
344                                 },
345                                 {
346                                     "name": "cntct_addr_id_addr_line2",
347                                     "xtype": "Hidden",
348                                     "|xns": "Roo.form"
349                                 },
350                                 {
351                                     "name": "cntct_addr_id_addr_line3",
352                                     "xtype": "Hidden",
353                                     "|xns": "Roo.form"
354                                 },
355                                 {
356                                     "name": "cntct_addr_id_addr_city",
357                                     "xtype": "Hidden",
358                                     "|xns": "Roo.form"
359                                 },
360                                 {
361                                     "name": "cntct_addr_id_addr_state",
362                                     "xtype": "Hidden",
363                                     "|xns": "Roo.form"
364                                 },
365                                 {
366                                     "name": "cntct_addr_id_addr_country",
367                                     "xtype": "Hidden",
368                                     "|xns": "Roo.form"
369                                 },
370                                 {
371                                     "name": "customer_id",
372                                     "xtype": "Hidden",
373                                     "|xns": "Roo.form"
374                                 },
375                                 {
376                                     "name": "cntct_crmacct_id",
377                                     "xtype": "Hidden",
378                                     "|xns": "Roo.form"
379                                 },
380                                 {
381                                     "xtype": "Hidden",
382                                     "|xns": "Roo.form",
383                                     "name": "cntct_id"
384                                 }
385                             ]
386                         }
387                     ]
388                 },
389                 {
390                     "listeners": {
391                         "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
392                     },
393                     "*prop": "buttons[]",
394                     "text": "Cancel",
395                     "xtype": "Button",
396                     "|xns": "Roo"
397                 },
398                 {
399                     "listeners": {
400                         "click": "function (_self, e)\n{\n    // do some checks?\n     var id=    _this.form.findField('cntct_crmacct_id').getValue();\n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Sorry, Something failed, please cancel and try re-creatating\");\n        return;\n    }\n     \n \n    _this.form.doAction('submit');\n\n}"
401                     },
402                     "*prop": "buttons[]",
403                     "text": "Save",
404                     "xtype": "Button",
405                     "|xns": "Roo"
406                 }
407             ]
408         }
409     ],
410     "permname": "",
411     "modOrder": "001"
412 }