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                                     listeners : {
85                                         add : function (combo)
86                                         {
87                                         
88                                             Pman.Dialog.Companies.show( {  id: 0 },  function(data) {
89                                                     _this.form.setValues({
90                                                             company_id_name : data.name,
91                                                             company_id : data
92                                                     })
93                                             }); 
94                                         }
95                                     },
96                                     allowBlank : 'false',
97                                     displayField : 'code',
98                                     editable : 'false',
99                                     emptyText : "Select Companies",
100                                     fieldLabel : 'Company',
101                                     forceSelection : true,
102                                     hiddenName : 'company_id',
103                                     listWidth : 400,
104                                     loadingText : "Searching...",
105                                     minChars : 2,
106                                     name : 'company_id_code',
107                                     pageSize : 20,
108                                     qtip : "Select Companies",
109                                     queryParam : 'query[code]',
110                                     selectOnFocus : true,
111                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{code}</b> </div>',
112                                     triggerAction : 'all',
113                                     typeAhead : true,
114                                     valueField : 'id',
115                                     width : 300,
116                                     store : {
117                                         xtype: 'Store',
118                                         xns: Roo.data,
119                                         remoteSort : true,
120                                         sortInfo : { direction : 'ASC', field: 'id' },
121                                         listeners : {
122                                             beforeload : function (_self, o){
123                                                 o.params = o.params || {};
124                                                 // set more here
125                                             }
126                                         },
127                                         proxy : {
128                                             xtype: 'HttpProxy',
129                                             xns: Roo.data,
130                                             method : 'GET',
131                                             url : baseURL + '/Roo/Companies.php'
132                                         },
133                                         reader : {
134                                             xtype: 'JsonReader',
135                                             xns: Roo.data,
136                                             id : 'id',
137                                             root : 'data',
138                                             totalProperty : 'total',
139                                             fields : [{"name":"id","type":"int"},{"name":"code","type":"string"}]
140                                         }
141                                     }
142                                 },
143                                 {
144                                     xtype: 'ComboBox',
145                                     xns: Roo.form,
146                                     allowBlank : 'false',
147                                     editable : 'false',
148                                     emptyText : "Select Office",
149                                     forceSelection : true,
150                                     listWidth : 400,
151                                     loadingText : "Searching...",
152                                     minChars : 2,
153                                     pageSize : 20,
154                                     qtip : "Select Office",
155                                     selectOnFocus : true,
156                                     triggerAction : 'all',
157                                     typeAhead : true,
158                                     width : 300,
159                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
160                                     queryParam : 'query[name]',
161                                     fieldLabel : 'Office',
162                                     valueField : 'id',
163                                     displayField : 'name',
164                                     hiddenName : 'office_id',
165                                     name : 'office_id_name',
166                                     store : {
167                                         xtype: 'Store',
168                                         xns: Roo.data,
169                                         remoteSort : true,
170                                         sortInfo : { direction : 'ASC', field: 'id' },
171                                         listeners : {
172                                             beforeload : function (_self, o){
173                                                 o.params = o.params || {};
174                                                 // set more here
175                                             }
176                                         },
177                                         proxy : {
178                                             xtype: 'HttpProxy',
179                                             xns: Roo.data,
180                                             method : 'GET',
181                                             url : baseURL + '/Roo/Office.php'
182                                         },
183                                         reader : {
184                                             xtype: 'JsonReader',
185                                             xns: Roo.data,
186                                             id : 'id',
187                                             root : 'data',
188                                             totalProperty : 'total',
189                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
190                                         }
191                                     }
192                                 },
193                                 {
194                                     xtype: 'TextField',
195                                     xns: Roo.form,
196                                     fieldLabel : 'Name',
197                                     name : 'name',
198                                     width : 300
199                                 },
200                                 {
201                                     xtype: 'TextField',
202                                     xns: Roo.form,
203                                     fieldLabel : 'Role',
204                                     name : 'role',
205                                     width : 200
206                                 },
207                                 {
208                                     xtype: 'TextField',
209                                     xns: Roo.form,
210                                     fieldLabel : 'Phone',
211                                     name : 'phone',
212                                     width : 200
213                                 },
214                                 {
215                                     xtype: 'TextField',
216                                     xns: Roo.form,
217                                     fieldLabel : 'Fax',
218                                     name : 'fax',
219                                     width : 200
220                                 },
221                                 {
222                                     xtype: 'TextField',
223                                     xns: Roo.form,
224                                     fieldLabel : 'Email',
225                                     name : 'email',
226                                     width : 200
227                                 },
228                                 {
229                                     xtype: 'Hidden',
230                                     xns: Roo.form,
231                                     name : 'id'
232                                 }
233                             ]
234                         }
235                     ]
236                 }
237             ],
238             center : {
239                 xtype: 'LayoutRegion',
240                 xns: Roo
241             },
242             buttons : [
243                 {
244                     xtype: 'Button',
245                     xns: Roo,
246                     listeners : {
247                         click : function (_self, e)
248                         {
249                             _this.dialog.hide();
250                         }
251                     },
252                     text : "Cancel"
253                 },
254                 {
255                     xtype: 'Button',
256                     xns: Roo,
257                     listeners : {
258                         click : function (_self, e)
259                         {
260                             // do some checks?
261                              
262                             
263                             _this.dialog.el.mask("Saving");
264                             _this.form.doAction("submit");
265                         
266                         }
267                     },
268                     text : "Save"
269                 }
270             ]
271         });
272     }
273 };