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