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