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