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