Pman.Tab.AdminProjectManager.js
[Pman.Admin] / Pman.Tab.AdminProjectManager.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5
6
7 // register the module first
8 Pman.on('beforeload', function()
9 {
10     Pman.register({
11         modKey : '002-Pman.Tab.AdminProjectManager',
12         module : Pman.Tab.AdminProjectManager,
13         region : 'center',
14         parent : Pman.Tab.Admin,
15         name : "Pman.Tab.AdminProjectManager",
16         disabled : false, 
17         permname: 'Core.Projects_All' 
18     });
19 });
20
21 Pman.Tab.AdminProjectManager = new Roo.util.Observable({
22
23     panel : false,
24     disabled : false,
25     parentLayout:  false,
26
27     add : function(parentLayout, region)
28     {
29
30         var _this = this;
31         this.parentLayout = parentLayout;
32
33         this.panel = parentLayout.addxtype({
34             xtype: 'NestedLayoutPanel',
35             xns: Roo,
36             region : 'center',
37             title : "Projects",
38             layout : {
39                 xtype: 'BorderLayout',
40                 xns: Roo,
41                 items : [
42                     {
43                         xtype: 'GridPanel',
44                         xns: Roo,
45                         listeners : {
46                             activate : function() {
47                                 _this.panel = this;
48                                 _this.dialog = Pman.Dialog.CoreProject;
49                                 if (_this.grid) {
50                                     _this.grid.footer.onClick('first');
51                                 }
52                             }
53                         },
54                         background : true,
55                         fitContainer : true,
56                         fitToframe : true,
57                         region : 'center',
58                         tableName : 'Projects',
59                         title : "Projects",
60                         grid : {
61                             xtype: 'Grid',
62                             xns: Roo.grid,
63                             listeners : {
64                                 render : function() 
65                                 {
66                                     _this.grid = this; 
67                                     //_this.dialog = Pman.Dialog.FILL_IN
68                                     if (_this.panel.active) {
69                                        this.footer.onClick('first');
70                                     }
71                                 },
72                                 rowdblclick : function (_self, rowIndex, e)
73                                 {
74                                     if (!_this.dialog) return;
75                                     _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
76                                         _this.grid.footer.onClick('first');
77                                     }); 
78                                 }
79                             },
80                             filter : 'P,U',
81                             autoExpandColumn : 'name',
82                             loadMask : true,
83                             getTypes : function() {
84                                 return [
85                                     [  'U' , "Project (Unconfirmed)" ],
86                                     [  'P' , "Project" ],
87                                     [  'C' , "Project (Closed)" ],
88                                     [  'N' , "Non-Project" ],
89                                     [  'X' , "Non-Project (Closed)" ]
90                             
91                                 ];
92                             },
93                             typeToString : function(v)
94                             {
95                                 var ar = this.getTypes();
96                                 var ret = '';
97                                 Roo.each(ar, function(a) {
98                                     if (a[0] == v) {
99                                         ret = a[1];
100                                         return false;
101                                     }
102                                 });
103                                 return ret;
104                             },
105                             dataSource : {
106                                 xtype: 'Store',
107                                 xns: Roo.data,
108                                 listeners : {
109                                     beforeload : function (_self, options)
110                                     {
111                                         if (!_this.searchBox) {
112                                             return false;
113                                         }  
114                                         o.params = o.params ? o.params : {};
115                                         o.params['query[project_search]'] = _this.searchBox.getValue();
116                                         o.params['query[project_filter]'] = _this.filter;
117                                     }
118                                 },
119                                 remoteSort : true,
120                                 sortInfo : { field : 'code', direction: 'ASC' },
121                                 proxy : {
122                                     xtype: 'HttpProxy',
123                                     xns: Roo.data,
124                                     method : 'GET',
125                                     url : baseURL + '/Roo/Projects.php'
126                                 },
127                                 reader : {
128                                     xtype: 'JsonReader',
129                                     xns: Roo.data,
130                                     totalProperty : 'total',
131                                     root : 'data',
132                                     id : 'id',
133                                     fields : [
134                                         {
135                                             'name': 'id',
136                                             'type': 'int'
137                                         },
138                                         {
139                                             'name': 'name',
140                                             'type': 'string'
141                                         },
142                                         {
143                                             'name': 'remarks',
144                                             'type': 'string'
145                                         },
146                                         {
147                                             'name': 'owner_id',
148                                             'type': 'int'
149                                         },
150                                         {
151                                             'name': 'code',
152                                             'type': 'string'
153                                         },
154                                         {
155                                             'name': 'active',
156                                             'type': 'int'
157                                         },
158                                         {
159                                             'name': 'type',
160                                             'type': 'string'
161                                         },
162                                         {
163                                             'name': 'client_id',
164                                             'type': 'int'
165                                         },
166                                         {
167                                             'name': 'team_id',
168                                             'type': 'int'
169                                         },
170                                         {
171                                             'name': 'file_location',
172                                             'type': 'string'
173                                         },
174                                         {
175                                             'name': 'open_date',
176                                             'type': 'date',
177                                             'dateFormat': 'Y-m-d'
178                                         },
179                                         {
180                                             'name': 'open_by',
181                                             'type': 'int'
182                                         },
183                                         {
184                                             'name': 'close_date',
185                                             'type': 'date',
186                                             'dateFormat': 'Y-m-d'
187                                         },
188                                         {
189                                             'name': 'countries',
190                                             'type': 'string'
191                                         },
192                                         {
193                                             'name': 'languages',
194                                             'type': 'string'
195                                         },
196                                         {
197                                             'name': 'agency_id',
198                                             'type': 'int'
199                                         },
200                                         {
201                                             'name': 'client_id_code',
202                                             'type': 'string'
203                                         },
204                                         {
205                                             'name': 'client_id_name',
206                                             'type': 'string'
207                                         },
208                                         {
209                                             'name': 'client_id_remarks',
210                                             'type': 'string'
211                                         },
212                                         {
213                                             'name': 'client_id_owner_id',
214                                             'type': 'int'
215                                         },
216                                         {
217                                             'name': 'client_id_address',
218                                             'type': 'string'
219                                         },
220                                         {
221                                             'name': 'client_id_tel',
222                                             'type': 'string'
223                                         },
224                                         {
225                                             'name': 'client_id_fax',
226                                             'type': 'string'
227                                         },
228                                         {
229                                             'name': 'client_id_email',
230                                             'type': 'string'
231                                         },
232                                         {
233                                             'name': 'client_id_id',
234                                             'type': 'int'
235                                         },
236                                         {
237                                             'name': 'client_id_isOwner',
238                                             'type': 'int'
239                                         },
240                                         {
241                                             'name': 'client_id_logo_id',
242                                             'type': 'int'
243                                         },
244                                         {
245                                             'name': 'client_id_background_color',
246                                             'type': 'string'
247                                         },
248                                         {
249                                             'name': 'client_id_comptype',
250                                             'type': 'string'
251                                         },
252                                         {
253                                             'name': 'client_id_url',
254                                             'type': 'string'
255                                         },
256                                         {
257                                             'name': 'client_id_main_office_id',
258                                             'type': 'int'
259                                         },
260                                         {
261                                             'name': 'client_id_created_by',
262                                             'type': 'int'
263                                         },
264                                         {
265                                             'name': 'client_id_created_dt',
266                                             'type': 'date'
267                                         },
268                                         {
269                                             'name': 'client_id_updated_by',
270                                             'type': 'int'
271                                         },
272                                         {
273                                             'name': 'client_id_updated_dt',
274                                             'type': 'date'
275                                         },
276                                         {
277                                             'name': 'client_id_passwd',
278                                             'type': 'string'
279                                         },
280                                         {
281                                             'name': 'agency_id_code',
282                                             'type': 'string'
283                                         },
284                                         {
285                                             'name': 'agency_id_name',
286                                             'type': 'string'
287                                         },
288                                         {
289                                             'name': 'agency_id_remarks',
290                                             'type': 'string'
291                                         },
292                                         {
293                                             'name': 'agency_id_owner_id',
294                                             'type': 'int'
295                                         },
296                                         {
297                                             'name': 'agency_id_address',
298                                             'type': 'string'
299                                         },
300                                         {
301                                             'name': 'agency_id_tel',
302                                             'type': 'string'
303                                         },
304                                         {
305                                             'name': 'agency_id_fax',
306                                             'type': 'string'
307                                         },
308                                         {
309                                             'name': 'agency_id_email',
310                                             'type': 'string'
311                                         },
312                                         {
313                                             'name': 'agency_id_id',
314                                             'type': 'int'
315                                         },
316                                         {
317                                             'name': 'agency_id_isOwner',
318                                             'type': 'int'
319                                         },
320                                         {
321                                             'name': 'agency_id_logo_id',
322                                             'type': 'int'
323                                         },
324                                         {
325                                             'name': 'agency_id_background_color',
326                                             'type': 'string'
327                                         },
328                                         {
329                                             'name': 'agency_id_comptype',
330                                             'type': 'string'
331                                         },
332                                         {
333                                             'name': 'agency_id_url',
334                                             'type': 'string'
335                                         },
336                                         {
337                                             'name': 'agency_id_main_office_id',
338                                             'type': 'int'
339                                         },
340                                         {
341                                             'name': 'agency_id_created_by',
342                                             'type': 'int'
343                                         },
344                                         {
345                                             'name': 'agency_id_created_dt',
346                                             'type': 'date'
347                                         },
348                                         {
349                                             'name': 'agency_id_updated_by',
350                                             'type': 'int'
351                                         },
352                                         {
353                                             'name': 'agency_id_updated_dt',
354                                             'type': 'date'
355                                         },
356                                         {
357                                             'name': 'agency_id_passwd',
358                                             'type': 'string'
359                                         },
360                                         {
361                                             'name': 'team_id_id',
362                                             'type': 'int'
363                                         },
364                                         {
365                                             'name': 'team_id_name',
366                                             'type': 'string'
367                                         },
368                                         {
369                                             'name': 'team_id_type',
370                                             'type': 'int'
371                                         },
372                                         {
373                                             'name': 'team_id_leader',
374                                             'type': 'int'
375                                         },
376                                         {
377                                             'name': 'open_by_id',
378                                             'type': 'int'
379                                         },
380                                         {
381                                             'name': 'open_by_office_id',
382                                             'type': 'int'
383                                         },
384                                         {
385                                             'name': 'open_by_name',
386                                             'type': 'string'
387                                         },
388                                         {
389                                             'name': 'open_by_phone',
390                                             'type': 'string'
391                                         },
392                                         {
393                                             'name': 'open_by_fax',
394                                             'type': 'string'
395                                         },
396                                         {
397                                             'name': 'open_by_email',
398                                             'type': 'string'
399                                         },
400                                         {
401                                             'name': 'open_by_company_id',
402                                             'type': 'int'
403                                         },
404                                         {
405                                             'name': 'open_by_role',
406                                             'type': 'string'
407                                         },
408                                         {
409                                             'name': 'open_by_active',
410                                             'type': 'int'
411                                         },
412                                         {
413                                             'name': 'open_by_remarks',
414                                             'type': 'string'
415                                         },
416                                         {
417                                             'name': 'open_by_passwd',
418                                             'type': 'string'
419                                         },
420                                         {
421                                             'name': 'open_by_owner_id',
422                                             'type': 'int'
423                                         },
424                                         {
425                                             'name': 'open_by_lang',
426                                             'type': 'string'
427                                         },
428                                         {
429                                             'name': 'open_by_no_reset_sent',
430                                             'type': 'int'
431                                         },
432                                         {
433                                             'name': 'open_by_action_type',
434                                             'type': 'string'
435                                         },
436                                         {
437                                             'name': 'open_by_project_id',
438                                             'type': 'int'
439                                         },
440                                         {
441                                             'name': 'owner_id_id',
442                                             'type': 'int'
443                                         },
444                                         {
445                                             'name': 'owner_id_office_id',
446                                             'type': 'int'
447                                         },
448                                         {
449                                             'name': 'owner_id_name',
450                                             'type': 'string'
451                                         },
452                                         {
453                                             'name': 'owner_id_phone',
454                                             'type': 'string'
455                                         },
456                                         {
457                                             'name': 'owner_id_fax',
458                                             'type': 'string'
459                                         },
460                                         {
461                                             'name': 'owner_id_email',
462                                             'type': 'string'
463                                         },
464                                         {
465                                             'name': 'owner_id_company_id',
466                                             'type': 'int'
467                                         },
468                                         {
469                                             'name': 'owner_id_role',
470                                             'type': 'string'
471                                         },
472                                         {
473                                             'name': 'owner_id_active',
474                                             'type': 'int'
475                                         },
476                                         {
477                                             'name': 'owner_id_remarks',
478                                             'type': 'string'
479                                         },
480                                         {
481                                             'name': 'owner_id_passwd',
482                                             'type': 'string'
483                                         },
484                                         {
485                                             'name': 'owner_id_owner_id',
486                                             'type': 'int'
487                                         },
488                                         {
489                                             'name': 'owner_id_lang',
490                                             'type': 'string'
491                                         },
492                                         {
493                                             'name': 'owner_id_no_reset_sent',
494                                             'type': 'int'
495                                         },
496                                         {
497                                             'name': 'owner_id_action_type',
498                                             'type': 'string'
499                                         },
500                                         {
501                                             'name': 'owner_id_project_id',
502                                             'type': 'int'
503                                         }
504                                     ]
505                                 }
506                             },
507                             footer : {
508                                 xtype: 'PagingToolbar',
509                                 xns: Roo,
510                                 displayInfo : true,
511                                 displayMsg : 'Displaying Projects {0} - {1} of {2}',
512                                 emptyMsg : 'No Projects found',
513                                 pageSize : 25
514                             },
515                             toolbar : {
516                                 xtype: 'Toolbar',
517                                 xns: Roo,
518                                 items : [
519                                     {
520                                         xtype: 'Button',
521                                         xns: Roo.Toolbar,
522                                         listeners : {
523                                             click : function()
524                                             {
525                                                 if (!_this.dialog) return;
526                                                 _this.dialog.show( { id : 0 } , function() {
527                                                     _this.grid.footer.onClick('first');
528                                                }); 
529                                             }
530                                         },
531                                         cls : 'x-btn-text-icon',
532                                         text : "Add",
533                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
534                                     },
535                                     {
536                                         xtype: 'Button',
537                                         xns: Roo.Toolbar,
538                                         text : "Edit",
539                                         cls : 'x-btn-text-icon',
540                                         icon : Roo.rootURL + 'images/default/tree/leaf.gif',
541                                         listeners : {
542                                             click : function()
543                                             {
544                                                 var s = _this.grid.getSelectionModel().getSelections();
545                                                 if (!s.length || (s.length > 1))  {
546                                                     Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
547                                                     return;
548                                                 }
549                                                 if (!_this.dialog) return;
550                                                 _this.dialog.show(s[0].data, function() {
551                                                     _this.grid.footer.onClick('first');
552                                                 }); 
553                                                 
554                                             }
555                                         }
556                                     },
557                                     {
558                                         xtype: 'Separator',
559                                         xns: Roo.Toolbar
560                                     },
561                                     {
562                                         xtype: 'TextField',
563                                         xns: Roo.form,
564                                         listeners : {
565                                             render : function (_self)
566                                             {
567                                                 _this.searchBox = _self;
568                                             }
569                                         }
570                                     }
571                                 ]
572                             },
573                             colModel : [
574                                 {
575                                     xtype: 'ColumnModel',
576                                     xns: Roo.grid,
577                                     dataIndex : 'type',
578                                     header : 'Type',
579                                     width : 200,
580                                     renderer : function(v) { return _this.grid.typeToString(v);}
581                                 },
582                                 {
583                                     xtype: 'ColumnModel',
584                                     xns: Roo.grid,
585                                     header : 'Code',
586                                     width : 200,
587                                     dataIndex : 'code',
588                                     renderer : function(v) { return String.format('{0}', v); }
589                                 },
590                                 {
591                                     xtype: 'ColumnModel',
592                                     xns: Roo.grid,
593                                     header : 'Name',
594                                     width : 200,
595                                     dataIndex : 'name',
596                                     renderer : function(v) { return String.format('{0}', v); }
597                                 },
598                                 {
599                                     xtype: 'ColumnModel',
600                                     xns: Roo.grid,
601                                     header : 'Client',
602                                     width : 75,
603                                     dataIndex : 'client_id',
604                                     renderer : function(v) { return String.format('{0}', v); }
605                                 }
606                             ]
607                         }
608                     }
609                 ],
610                 center : {
611                     xtype: 'LayoutRegion',
612                     xns: Roo
613                 },
614                 east : {
615                     xtype: 'LayoutRegion',
616                     xns: Roo,
617                     width : 300
618                 }
619             }
620         });
621         this.layout = this.panel.layout;
622
623     }
624 });