Pman.Dialog.CoreProject.js
[Pman.Core] / Pman.Dialog.CoreProject.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.CoreProject = {
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 : 450,
36             resizable : false,
37             title : "Edit / Create Projects",
38             width : 470,
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/Projects.php',
80                             items : [
81                                 {
82                                     xtype: 'TextField',
83                                     xns: Roo.form,
84                                     fieldLabel : 'Code',
85                                     name : 'code',
86                                     width : 150
87                                 },
88                                 {
89                                     xtype: 'TextField',
90                                     xns: Roo.form,
91                                     fieldLabel : 'Project Name',
92                                     name : 'name',
93                                     qtip : "Enter Project Name",
94                                     width : 300
95                                 },
96                                 {
97                                     xtype: 'ComboBox',
98                                     xns: Roo.form,
99                                     allowBlank : false,
100                                     displayField : 'desc',
101                                     editable : false,
102                                     emptyText : "Select Project Type",
103                                     fieldLabel : 'Project Type',
104                                     forceSelection : true,
105                                     listWidth : 400,
106                                     loadingText : "Searching...",
107                                     minChars : 2,
108                                     name : 'type',
109                                     pageSize : 20,
110                                     qtip : "Select Project Type",
111                                     queryParam : 'query[name]',
112                                     selectOnFocus : true,
113                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{desc}</b> </div>',
114                                     triggerAction : 'all',
115                                     typeAhead : true,
116                                     valueField : 'code',
117                                     width : 200,
118                                     store : {
119                                         xtype: 'SimpleStore',
120                                         xns: Roo.data,
121                                         data : [ [  'U' , "Project (Unconfirmed)" ],
122                                         [  'P' , "Project" ],
123                                         [  'C' , "Project (Closed)" ],
124                                         [  'N' , "Non-Project" ],
125                                         [  'X' , "Non-Project (Closed)" ]
126                                         ],
127                                         fields : [ 'code', 'desc' ]
128                                     }
129                                 },
130                                 {
131                                     xtype: 'ComboBox',
132                                     xns: Roo.form,
133                                     listeners : {
134                                         add : function (combo)
135                                         {
136                                          Pman.Dialog.Companies.show( {  id: 0 },  function(data) {
137                                                     _this.form.setValues({ 
138                                                         client_id : data.id,
139                                                         client_id_name : data.name
140                                                     });
141                                                 }); 
142                                         }
143                                     },
144                                     allowBlank : 'false',
145                                     displayField : 'code',
146                                     editable : 'false',
147                                     emptyText : "Select Company",
148                                     fieldLabel : 'Client',
149                                     forceSelection : true,
150                                     hiddenName : 'client_id',
151                                     listWidth : 400,
152                                     loadingText : "Searching...",
153                                     minChars : 2,
154                                     name : 'client_id_name',
155                                     pageSize : 20,
156                                     qtip : "Select Companies",
157                                     queryParam : 'query[code]',
158                                     selectOnFocus : true,
159                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
160                                     triggerAction : 'all',
161                                     typeAhead : true,
162                                     valueField : 'id',
163                                     width : 300,
164                                     store : {
165                                         xtype: 'Store',
166                                         xns: Roo.data,
167                                         listeners : {
168                                             beforeload : function (_self, o){
169                                                 o.params = o.params || {};
170                                                
171                                                 o.params.type = 1;
172                                                 o.params['query[group_pulldown]'] = 1;
173                                             }
174                                         },
175                                         remoteSort : true,
176                                         sortInfo : { direction : 'ASC', field: 'name' },
177                                         proxy : {
178                                             xtype: 'HttpProxy',
179                                             xns: Roo.data,
180                                             method : 'GET',
181                                             url : baseURL + '/Roo/Companies.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":"code","type":"string"}]
190                                         }
191                                     }
192                                 },
193                                 {
194                                     xtype: 'ComboBox',
195                                     xns: Roo.form,
196                                     allowBlank : 'false',
197                                     displayField : 'name',
198                                     editable : 'false',
199                                     emptyText : "Select Team",
200                                     fieldLabel : 'Team',
201                                     forceSelection : true,
202                                     hiddenName : 'team_id',
203                                     listWidth : 400,
204                                     loadingText : "Searching...",
205                                     minChars : 2,
206                                     name : 'team_id_name',
207                                     pageSize : 20,
208                                     qtip : "Select Team",
209                                     queryParam : 'query[name]',
210                                     selectOnFocus : true,
211                                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
212                                     triggerAction : 'all',
213                                     typeAhead : true,
214                                     valueField : 'id',
215                                     width : 300,
216                                     store : {
217                                         xtype: 'Store',
218                                         xns: Roo.data,
219                                         remoteSort : true,
220                                         sortInfo : { direction : 'ASC', field: 'id' },
221                                         listeners : {
222                                             beforeload : function (_self, o){
223                                                 o.params = o.params || {};
224                                                 // set more here
225                                             }
226                                         },
227                                         proxy : {
228                                             xtype: 'HttpProxy',
229                                             xns: Roo.data,
230                                             method : 'GET',
231                                             url : baseURL + '/Roo/Groups.php'
232                                         },
233                                         reader : {
234                                             xtype: 'JsonReader',
235                                             xns: Roo.data,
236                                             id : 'id',
237                                             root : 'data',
238                                             totalProperty : 'total',
239                                             fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
240                                         }
241                                     }
242                                 },
243                                 {
244                                     xtype: 'TextField',
245                                     xns: Roo.form,
246                                     fieldLabel : 'File location',
247                                     name : 'file_location',
248                                     width : 300
249                                 },
250                                 {
251                                     xtype: 'TextArea',
252                                     xns: Roo.form,
253                                     fieldLabel : 'Remarks',
254                                     height : 100,
255                                     name : 'remarks',
256                                     width : 300
257                                 },
258                                 {
259                                     xtype: 'FieldSet',
260                                     xns: Roo.form,
261                                     legend : "Opened",
262                                     items : [
263                                         {
264                                             xtype: 'DateField',
265                                             xns: Roo.form,
266                                             altFormats : 'Y-m-d|d/m/Y',
267                                             fieldLabel : 'Open date',
268                                             format : 'd/m/Y',
269                                             name : 'open_date',
270                                             width : 100
271                                         },
272                                         {
273                                             xtype: 'ComboBox',
274                                             xns: Roo.form,
275                                             allowBlank : 'false',
276                                             editable : 'false',
277                                             emptyText : "Select Person",
278                                             forceSelection : true,
279                                             listWidth : 400,
280                                             loadingText : "Searching...",
281                                             minChars : 2,
282                                             pageSize : 20,
283                                             qtip : "Select Person",
284                                             selectOnFocus : true,
285                                             triggerAction : 'all',
286                                             typeAhead : true,
287                                             width : 300,
288                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
289                                             queryParam : 'query[name]',
290                                             fieldLabel : 'Open by',
291                                             valueField : 'id',
292                                             displayField : 'name',
293                                             hiddenName : 'open_by',
294                                             name : 'open_by_name',
295                                             store : {
296                                                 xtype: 'Store',
297                                                 xns: Roo.data,
298                                                 remoteSort : true,
299                                                 sortInfo : { direction : 'ASC', field: 'id' },
300                                                 listeners : {
301                                                     beforeload : function (_self, o){
302                                                         o.params = o.params || {};
303                                                         // set more here
304                                                     }
305                                                 },
306                                                 proxy : {
307                                                     xtype: 'HttpProxy',
308                                                     xns: Roo.data,
309                                                     method : 'GET',
310                                                     url : baseURL + '/Roo/Person.php'
311                                                 },
312                                                 reader : {
313                                                     xtype: 'JsonReader',
314                                                     xns: Roo.data,
315                                                     id : 'id',
316                                                     root : 'data',
317                                                     totalProperty : 'total',
318                                                     fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
319                                                 }
320                                             }
321                                         }
322                                     ]
323                                 },
324                                 {
325                                     xtype: 'Hidden',
326                                     xns: Roo.form,
327                                     name : 'id'
328                                 }
329                             ]
330                         }
331                     ]
332                 }
333             ],
334             center : {
335                 xtype: 'LayoutRegion',
336                 xns: Roo
337             },
338             buttons : [
339                 {
340                     xtype: 'Button',
341                     xns: Roo,
342                     listeners : {
343                         click : function (_self, e)
344                         {
345                             _this.dialog.hide();
346                         }
347                     },
348                     text : "Cancel"
349                 },
350                 {
351                     xtype: 'Button',
352                     xns: Roo,
353                     listeners : {
354                         click : function (_self, e)
355                         {
356                             // do some checks?
357                              
358                             
359                             _this.dialog.el.mask("Saving");
360                             _this.form.doAction("submit");
361                         
362                         }
363                     },
364                     text : "Save"
365                 }
366             ]
367         });
368     }
369 };