Pman.Dialog.CorePersonContact.js
[Pman.Core] / Pman.Dialog.CorePersonContact.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Dialog.CorePersonContact = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             closable : false,
34             collapsible : false,
35             height : 350,
36             resizable : false,
37             title : "Edit / Create Contact Details",
38             width : 500,
39             items : [
40                 {
41                     xtype: 'ContentPanel',
42                     xns: Roo,
43                     region : 'center',
44                     items : [
45                         {
46                             xtype: 'Form',
47                             xns: Roo.form,
48                             listeners : {
49                                 actioncomplete : function(_self,action)
50                                 {
51                                     if (action.type == 'setdata') {
52                                        //_this.dialog.el.mask("Loading");
53                                        //this.load({ method: 'GET', params: { '_id' : _this.data.id }});
54                                        return;
55                                     }
56                                     if (action.type == 'load') {
57                                         _this.dialog.el.unmask();
58                                         return;
59                                     }
60                                     if (action.type =='submit') {
61                                     
62                                         _this.dialog.el.unmask();
63                                         _this.dialog.hide();
64                                     
65                                          if (_this.callback) {
66                                             _this.callback.call(_this, _this.form.getValues());
67                                          }
68                                          _this.form.reset();
69                                          return;
70                                     }
71                                 },
72                                 rendered : function (form)
73                                 {
74                                     _this.form= form;
75                                 }
76                             },
77                             method : 'POST',
78                             style : 'margin:10px;',
79                             url : baseURL + '/Roo/Person.php',
80                             items : [
81                                 {
82                                     xtype: 'ComboBox',
83                                     xns: Roo.form,
84                                     allowBlank : 'false',
85                                     displayField : 'code',
86                                     editable : 'false',
87                                     emptyText : "Select Companies",
88                                     fieldLabel : 'Company',
89                                     forceSelection : true,
90                                     hiddenName : 'company_id',
91                                     listWidth : 400,
92                                     loadingText : "Searching...",
93                                     minChars : 2,
94                                     name : 'company_id_code',
95                                     pageSize : 20,
96                                     qtip : "Select Companies",
97                                     queryParam : 'query[code]',
98                                     selectOnFocus : true,
99                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{code}</b> </div>',
100                                     triggerAction : 'all',
101                                     typeAhead : true,
102                                     valueField : 'id',
103                                     width : 300,
104                                     listeners : {
105                                         add : function (combo)
106                                         {
107                                         
108                                         }
109                                     },
110                                     store : {
111                                         xtype: 'Store',
112                                         xns: Roo.data,
113                                         remoteSort : true,
114                                         sortInfo : { direction : 'ASC', field: 'id' },
115                                         listeners : {
116                                             beforeload : function (_self, o){
117                                                 o.params = o.params || {};
118                                                 // set more here
119                                             }
120                                         },
121                                         proxy : {
122                                             xtype: 'HttpProxy',
123                                             xns: Roo.data,
124                                             method : 'GET',
125                                             url : baseURL + '/Roo/Companies.php'
126                                         },
127                                         reader : {
128                                             xtype: 'JsonReader',
129                                             xns: Roo.data,
130                                             id : 'id',
131                                             root : 'data',
132                                             totalProperty : 'total',
133                                             fields : [{"name":"id","type":"int"},{"name":"code","type":"string"}]
134                                         }
135                                     }
136                                 },
137                                 {
138                                     xtype: 'ComboBox',
139                                     xns: Roo.form,
140                                     allowBlank : 'false',
141                                     editable : 'false',
142                                     emptyText : "Select Office",
143                                     forceSelection : true,
144                                     listWidth : 400,
145                                     loadingText : "Searching...",
146                                     minChars : 2,
147                                     pageSize : 20,
148                                     qtip : "Select Office",
149                                     selectOnFocus : true,
150                                     triggerAction : 'all',
151                                     typeAhead : true,
152                                     width : 300,
153                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
154                                     queryParam : 'query[name]',
155                                     fieldLabel : 'Office',
156                                     valueField : 'id',
157                                     displayField : 'name',
158                                     hiddenName : 'office_id',
159                                     name : 'office_id_name',
160                                     store : {
161                                         xtype: 'Store',
162                                         xns: Roo.data,
163                                         remoteSort : true,
164                                         sortInfo : { direction : 'ASC', field: 'id' },
165                                         listeners : {
166                                             beforeload : function (_self, o){
167                                                 o.params = o.params || {};
168                                                 // set more here
169                                             }
170                                         },
171                                         proxy : {
172                                             xtype: 'HttpProxy',
173                                             xns: Roo.data,
174                                             method : 'GET',
175                                             url : baseURL + '/Roo/Office.php'
176                                         },
177                                         reader : {
178                                             xtype: 'JsonReader',
179                                             xns: Roo.data,
180                                             id : 'id',
181                                             root : 'data',
182                                             totalProperty : 'total',
183                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
184                                         }
185                                     }
186                                 },
187                                 {
188                                     xtype: 'TextField',
189                                     xns: Roo.form,
190                                     fieldLabel : 'Name',
191                                     name : 'name',
192                                     width : 300
193                                 },
194                                 {
195                                     xtype: 'TextField',
196                                     xns: Roo.form,
197                                     fieldLabel : 'Role',
198                                     name : 'role',
199                                     width : 200
200                                 },
201                                 {
202                                     xtype: 'TextField',
203                                     xns: Roo.form,
204                                     fieldLabel : 'Phone',
205                                     name : 'phone',
206                                     width : 200
207                                 },
208                                 {
209                                     xtype: 'TextField',
210                                     xns: Roo.form,
211                                     fieldLabel : 'Fax',
212                                     name : 'fax',
213                                     width : 200
214                                 },
215                                 {
216                                     xtype: 'TextField',
217                                     xns: Roo.form,
218                                     fieldLabel : 'Email',
219                                     name : 'email',
220                                     width : 200
221                                 },
222                                 {
223                                     xtype: 'Hidden',
224                                     xns: Roo.form,
225                                     name : 'id'
226                                 }
227                             ]
228                         }
229                     ]
230                 }
231             ],
232             center : {
233                 xtype: 'LayoutRegion',
234                 xns: Roo
235             },
236             buttons : [
237                 {
238                     xtype: 'Button',
239                     xns: Roo,
240                     listeners : {
241                         click : function (_self, e)
242                         {
243                             _this.dialog.hide();
244                         }
245                     },
246                     text : "Cancel"
247                 },
248                 {
249                     xtype: 'Button',
250                     xns: Roo,
251                     listeners : {
252                         click : function (_self, e)
253                         {
254                             // do some checks?
255                              
256                             
257                             _this.dialog.el.mask("Saving");
258                             _this.form.doAction("submit");
259                         
260                         }
261                     },
262                     text : "Save"
263                 }
264             ]
265         });
266     }
267 };