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