1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.XtupleContact = {
10 show : function(data, cb)
18 this.dialog.show(this.data._el);
21 this.form.setValues(data);
22 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
30 this.dialog = Roo.factory({
31 xtype: 'LayoutDialog',
38 title : "Contact Details",
42 xtype: 'ContentPanel',
50 actioncomplete : function(_self,action)
52 if (action.type == 'setdata') {
53 if (_this.data.cntct_id) {
54 this.load({ method: 'GET', params: { '_id' : _this.data.cntct_id }});
57 // we need to fetch crmct id..
60 url : baseURL + '/Roo/crmacct',
62 crmacct_cust_id : _this.data.customer_id
64 success : function(r) {
67 _this.form.findField('cntct_crmacct_id').setValue(r.data[0].crmacct_id);
69 Roo.MessageBox.alert("Error", "Sorry, we failed got get some data from the server, please cancel and try again");
75 if (action.type == 'load') {
76 _this.form.findField('cntct_name').sync();
77 _this.form.findField('addr_view').sync();
81 if (action.type =='submit') {
84 _this.form.setValues(action.result.data);
86 _this.callback.call(_this, _this.form.getValues());
92 rendered : function (form)
98 style : 'margin:10px;',
99 url : baseURL + '/Roo/cntct.php',
105 style : 'width:750px',
110 labelAlign : 'right',
118 blur : function (_self)
120 _this.form.findField('cntct_name').sync();
124 displayField : 'hnfc_code',
128 hiddenName : 'cntct_honorific',
130 loadingText : "Searching...",
132 name : 'cntct_honorific',
133 qtip : "Select title",
134 queryParam : 'query[addr_line1]',
135 selectOnFocus : true,
136 tpl : '<div class="x-grid-cell-text x-btn button"><b>{hnfc_code}</b> </div>',
137 triggerAction : 'all',
139 valueField : 'hnfc_code',
144 sortInfo : { direction : 'ASC', field: 'addr_line1' },
147 beforeload : function (_self, o){
148 o.params = o.params || {};
156 url : baseURL + '/Roo/hnfc.php'
163 totalProperty : 'total',
164 fields : [{'name':'hnfc_id','type':'int'},'hnfc_code']
179 keyup : function (_self, e)
181 _this.form.findField('cntct_name').sync();
184 fieldLabel : 'first_name',
185 name : 'cntct_first_name',
193 keyup : function (_self, e)
195 _this.form.findField('cntct_name').sync();
198 fieldLabel : 'initials',
199 name : 'cntct_initials',
207 keyup : function (_self, e)
209 _this.form.findField('cntct_name').sync();
212 fieldLabel : 'last_name',
213 name : 'cntct_last_name',
224 labelAlign : 'right',
231 labelAlign : 'right',
239 fieldLabel : 'Job Title',
240 name : 'cntct_title',
246 fieldLabel : 'Unique#',
247 name : 'cntct_number',
259 labelAlign : 'right',
262 style : 'width:300px',
267 fieldLabel : 'Phone',
268 name : 'cntct_phone',
274 fieldLabel : 'Mobile',
275 name : 'cntct_phone2',
291 style : 'width:400px; margin-left:10px',
296 fieldLabel : 'Email',
297 name : 'cntct_email',
304 fieldLabel : 'Website',
305 name : 'cntct_webaddr',
316 style : 'width:300px; clear: both;',
321 fieldLabel : 'notes',
323 name : 'cntct_notes',
333 style : 'width:400px; margin-left:10px',
339 add : function (combo)
341 Pman.Dialog.XtupleAddress.show({
343 customer_id : _this.form.findField('customer_id').getValue()
352 s['cntct_addr_id_' + k] = d[k];
355 s.cntct_addr_id = d.addr_id;
357 _this.form.setValues(s);
358 // if d contains a value.. use it..
359 _this.form.findField('addr_view').sync();
364 edit : function (combo, record)
366 Pman.Dialog.XtupleAddress.show({
367 addr_id : this.getValue(),
368 customer_id : _this.form.findField('customer_id').getValue()
378 s['cntct_addr_id_' + k] = d[k];
380 s.cntct_addr_id = d.addr_id;
382 _this.form.setValues(s);
383 _this.form.findField('addr_view').sync();
384 // if d contains a value.. use it..
388 select : function (combo, record, index)
391 for (var k in record.data) {
392 s['cntct_addr_id_' + k] = record.data[k];
395 _this.form.setValues(s);
396 _this.form.findField('addr_view').sync();
401 displayField : 'addr_line1',
403 emptyText : "Select address",
405 forceSelection : true,
406 hiddenName : 'cntct_addr_id',
408 loadingText : "Searching...",
410 name : 'cntct_addr_id_addr_line1',
412 qtip : "Select addr",
413 queryParam : 'query[addr_line1]',
414 selectOnFocus : true,
415 tpl : '<div class="x-grid-cell-text x-btn button"><b>#{addr_id} - {addr_line1}</b> </div>',
416 triggerAction : 'all',
418 valueField : 'addr_id',
424 beforeload : function (_self, o){
425 o.params = o.params || {};
426 o.params._customer_id = _this.form.findField('customer_id').getValue();
431 sortInfo : { direction : 'ASC', field: 'addr_line1' },
436 url : baseURL + '/Roo/addr.php'
443 totalProperty : 'total',
444 fields : [{'name':'addr_id','type':'int'},'addr_line1']
451 fieldLabel : 'notes',
456 var vals= _this.form.getFieldValues();
458 if (vals.cntct_addr_id * 1 < 1) {
459 this.setValue("No address set, this will cause an error");
462 for (var i in vals) {
463 if (i.match(/^cntct_addr_id_addr/) && vals[i].length) {
467 this.setValue(lines.join("\n"));
476 readName : function() {
477 var ar = [ 'honorific', 'first_name', 'initials', 'last_name' ];
479 Roo.each(ar, function (n) {
480 var v = _this.form.findField('cntct_' + n).getValue();
481 if (v.trim().length) {
485 return out.join(' ');
488 var dname = this.readName();
489 if (!dname.length && this.getValue().length) {
490 _this.form.findField('cntct_first_name').setValue(this.getValue());
495 this.setValue(dname);
497 _this.dialog.setTitle("Contact Details - " + this.getValue());
498 if (_this.form.findField('cntct_id').getValue() * 1 < 1) {
499 var cn = 'C' + _this.form.findField('customer_id').getValue() + '-';
500 _this.form.findField('cntct_number').setValue(cn + this.getValue());
509 name : 'cntct_addr_id_addr_line2'
514 name : 'cntct_addr_id_addr_line3'
519 name : 'cntct_addr_id_addr_city'
524 name : 'cntct_addr_id_addr_state'
529 name : 'cntct_addr_id_addr_country'
539 name : 'cntct_crmacct_id'
552 xtype: 'LayoutRegion',
560 click : function (_self, e)
571 click : function (_self, e)
574 var id= _this.form.findField('cntct_crmacct_id').getValue();
576 Roo.MessageBox.alert("Error", "Sorry, Something failed, please cancel and try re-creatating");
581 _this.form.doAction('submit');