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