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