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