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