Pman.Tab.AdminContacts.js
[Pman.Admin] / Pman.Tab.AdminContacts.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 : '001-Pman.Tab.AdminContacts',
12         module : Pman.Tab.AdminContacts,
13         region : 'center',
14         parent : Pman.Tab.AdminContacsManager,
15         name : "Pman.Tab.AdminContacts",
16         disabled : false, 
17         permname: 'Core.Person' 
18     });
19 });
20
21 Pman.Tab.AdminContacts = 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: 'GridPanel',
35             xns: Roo,
36             listeners : {
37                 activate : function() {
38                     _this.panel = this;
39                     if (_this.grid) {
40                         _this.grid.footer.onClick('first');
41                     }
42                 }
43             },
44             background : true,
45             fitContainer : true,
46             fitToframe : true,
47             region : 'center',
48             tableName : 'Person',
49             title : "Person",
50             grid : {
51                 xtype: 'Grid',
52                 xns: Roo.grid,
53                 autoExpandColumn : 'name',
54                 loadMask : true,
55                 listeners : {
56                     render : function() 
57                     {
58                         _this.grid = this; 
59                         //_this.dialog = Pman.Dialog.FILL_IN
60                         if (_this.panel.active) {
61                            this.footer.onClick('first');
62                         }
63                     },
64                     rowdblclick : function (_self, rowIndex, e)
65                     {
66                         if (!_this.dialog) return;
67                         _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {
68                             _this.grid.footer.onClick('first');
69                         }); 
70                     }
71                 },
72                 dataSource : {
73                     xtype: 'Store',
74                     xns: Roo.data,
75                     listeners : {
76                         beforeload : function (_self, o)
77                         {
78                           
79                             o.params['!company_id_comptype'] = 'OWNER';
80                             o.params['query[search]'] = _this.searchBox.getValue();
81                             if (Pman.Tab.ContactsGroup.grid) {
82                                 var tms = Pman.Tab.ContactsGroup.grid.getLeftSelections();
83                             
84                                 if (tms.length) {
85                                     o.params['query[in_group]'] = tms[0].data.id;
86                                     o.params['query[type]'] = 2; // group type..
87                                 }
88                             }
89                             //o.params['query[name]'] = _this.searchBox.getValue();
90                           
91                             
92                         }
93                     },
94                     remoteSort : true,
95                     sortInfo : { field : 'name', direction: 'ASC' },
96                     proxy : {
97                         xtype: 'HttpProxy',
98                         xns: Roo.data,
99                         method : 'GET',
100                         url : baseURL + '/Roo/Person.php'
101                     },
102                     reader : {
103                         xtype: 'JsonReader',
104                         xns: Roo.data,
105                         totalProperty : 'total',
106                         root : 'data',
107                         id : 'id',
108                         fields : [
109                             {
110                                 'name': 'id',
111                                 'type': 'int'
112                             },
113                             {
114                                 'name': 'office_id',
115                                 'type': 'int'
116                             },
117                             {
118                                 'name': 'name',
119                                 'type': 'string'
120                             },
121                             {
122                                 'name': 'phone',
123                                 'type': 'string'
124                             },
125                             {
126                                 'name': 'fax',
127                                 'type': 'string'
128                             },
129                             {
130                                 'name': 'email',
131                                 'type': 'string'
132                             },
133                             {
134                                 'name': 'company_id',
135                                 'type': 'int'
136                             },
137                             {
138                                 'name': 'role',
139                                 'type': 'string'
140                             },
141                             {
142                                 'name': 'active',
143                                 'type': 'int'
144                             },
145                             {
146                                 'name': 'remarks',
147                                 'type': 'string'
148                             },
149                             {
150                                 'name': 'passwd',
151                                 'type': 'string'
152                             },
153                             {
154                                 'name': 'owner_id',
155                                 'type': 'int'
156                             },
157                             {
158                                 'name': 'lang',
159                                 'type': 'string'
160                             },
161                             {
162                                 'name': 'no_reset_sent',
163                                 'type': 'int'
164                             },
165                             {
166                                 'name': 'action_type',
167                                 'type': 'string'
168                             },
169                             {
170                                 'name': 'project_id',
171                                 'type': 'int'
172                             },
173                             {
174                                 'name': 'office_id_id',
175                                 'type': 'int'
176                             },
177                             {
178                                 'name': 'office_id_company_id',
179                                 'type': 'int'
180                             },
181                             {
182                                 'name': 'office_id_name',
183                                 'type': 'string'
184                             },
185                             {
186                                 'name': 'office_id_address',
187                                 'type': 'string'
188                             },
189                             {
190                                 'name': 'office_id_phone',
191                                 'type': 'string'
192                             },
193                             {
194                                 'name': 'office_id_fax',
195                                 'type': 'string'
196                             },
197                             {
198                                 'name': 'office_id_email',
199                                 'type': 'string'
200                             },
201                             {
202                                 'name': 'office_id_role',
203                                 'type': 'string'
204                             },
205                             {
206                                 'name': 'company_id_code',
207                                 'type': 'string'
208                             },
209                             {
210                                 'name': 'company_id_name',
211                                 'type': 'string'
212                             },
213                             {
214                                 'name': 'company_id_remarks',
215                                 'type': 'string'
216                             },
217                             {
218                                 'name': 'company_id_owner_id',
219                                 'type': 'int'
220                             },
221                             {
222                                 'name': 'company_id_address',
223                                 'type': 'string'
224                             },
225                             {
226                                 'name': 'company_id_tel',
227                                 'type': 'string'
228                             },
229                             {
230                                 'name': 'company_id_fax',
231                                 'type': 'string'
232                             },
233                             {
234                                 'name': 'company_id_email',
235                                 'type': 'string'
236                             },
237                             {
238                                 'name': 'company_id_id',
239                                 'type': 'int'
240                             },
241                             {
242                                 'name': 'company_id_isOwner',
243                                 'type': 'int'
244                             },
245                             {
246                                 'name': 'company_id_logo_id',
247                                 'type': 'int'
248                             },
249                             {
250                                 'name': 'company_id_background_color',
251                                 'type': 'string'
252                             },
253                             {
254                                 'name': 'company_id_comptype',
255                                 'type': 'string'
256                             },
257                             {
258                                 'name': 'company_id_url',
259                                 'type': 'string'
260                             },
261                             {
262                                 'name': 'company_id_main_office_id',
263                                 'type': 'int'
264                             },
265                             {
266                                 'name': 'company_id_created_by',
267                                 'type': 'int'
268                             },
269                             {
270                                 'name': 'company_id_created_dt',
271                                 'type': 'date'
272                             },
273                             {
274                                 'name': 'company_id_updated_by',
275                                 'type': 'int'
276                             },
277                             {
278                                 'name': 'company_id_updated_dt',
279                                 'type': 'date'
280                             },
281                             {
282                                 'name': 'company_id_passwd',
283                                 'type': 'string'
284                             },
285                             {
286                                 'name': 'project_id_id',
287                                 'type': 'int'
288                             },
289                             {
290                                 'name': 'project_id_name',
291                                 'type': 'string'
292                             },
293                             {
294                                 'name': 'project_id_remarks',
295                                 'type': 'string'
296                             },
297                             {
298                                 'name': 'project_id_owner_id',
299                                 'type': 'int'
300                             },
301                             {
302                                 'name': 'project_id_code',
303                                 'type': 'string'
304                             },
305                             {
306                                 'name': 'project_id_active',
307                                 'type': 'int'
308                             },
309                             {
310                                 'name': 'project_id_type',
311                                 'type': 'string'
312                             },
313                             {
314                                 'name': 'project_id_client_id',
315                                 'type': 'int'
316                             },
317                             {
318                                 'name': 'project_id_team_id',
319                                 'type': 'int'
320                             },
321                             {
322                                 'name': 'project_id_file_location',
323                                 'type': 'string'
324                             },
325                             {
326                                 'name': 'project_id_open_date',
327                                 'type': 'date'
328                             },
329                             {
330                                 'name': 'project_id_open_by',
331                                 'type': 'int'
332                             },
333                             {
334                                 'name': 'project_id_close_date',
335                                 'type': 'date'
336                             },
337                             {
338                                 'name': 'project_id_countries',
339                                 'type': 'string'
340                             },
341                             {
342                                 'name': 'project_id_languages',
343                                 'type': 'string'
344                             },
345                             {
346                                 'name': 'project_id_agency_id',
347                                 'type': 'int'
348                             },
349                             {
350                                 'name': 'owner_id_id',
351                                 'type': 'int'
352                             },
353                             {
354                                 'name': 'owner_id_office_id',
355                                 'type': 'int'
356                             },
357                             {
358                                 'name': 'owner_id_name',
359                                 'type': 'string'
360                             },
361                             {
362                                 'name': 'owner_id_phone',
363                                 'type': 'string'
364                             },
365                             {
366                                 'name': 'owner_id_fax',
367                                 'type': 'string'
368                             },
369                             {
370                                 'name': 'owner_id_email',
371                                 'type': 'string'
372                             },
373                             {
374                                 'name': 'owner_id_company_id',
375                                 'type': 'int'
376                             },
377                             {
378                                 'name': 'owner_id_role',
379                                 'type': 'string'
380                             },
381                             {
382                                 'name': 'owner_id_active',
383                                 'type': 'int'
384                             },
385                             {
386                                 'name': 'owner_id_remarks',
387                                 'type': 'string'
388                             },
389                             {
390                                 'name': 'owner_id_passwd',
391                                 'type': 'string'
392                             },
393                             {
394                                 'name': 'owner_id_owner_id',
395                                 'type': 'int'
396                             },
397                             {
398                                 'name': 'owner_id_lang',
399                                 'type': 'string'
400                             },
401                             {
402                                 'name': 'owner_id_no_reset_sent',
403                                 'type': 'int'
404                             },
405                             {
406                                 'name': 'owner_id_action_type',
407                                 'type': 'string'
408                             },
409                             {
410                                 'name': 'owner_id_project_id',
411                                 'type': 'int'
412                             }
413                         ]
414                     }
415                 },
416                 footer : {
417                     xtype: 'PagingToolbar',
418                     xns: Roo,
419                     pageSize : 25,
420                     displayInfo : true,
421                     displayMsg : 'Displaying Person{0} - {1} of {2}',
422                     emptyMsg : 'No Person found',
423                     items : [
424                         {
425                             xtype: 'Button',
426                             xns: Roo.Toolbar,
427                             enableToggle : true,
428                             text : "Show Removed"
429                         }
430                     ]
431                 },
432                 toolbar : {
433                     xtype: 'Toolbar',
434                     xns: Roo,
435                     items : [
436                         {
437                             xtype: 'Button',
438                             xns: Roo.Toolbar,
439                             listeners : {
440                                 click : function()
441                                 {
442                                     
443                                     Pman.Dialog.PersonEdit.dialog.show( { id : 0 } , function() {
444                                         _this.grid.footer.onClick('first');
445                                    }); 
446                                 }
447                             },
448                             cls : 'x-btn-text-icon',
449                             text : "Add",
450                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
451                         },
452                         {
453                             xtype: 'Button',
454                             xns: Roo.Toolbar,
455                             listeners : {
456                                 click : function()
457                                 {
458                                     
459                                     Pman.Dialog.PersonBulkAdd.dialog.show( { id : 0 } , function() {
460                                         _this.grid.footer.onClick('first');
461                                    }); 
462                                 }
463                             },
464                             cls : 'x-btn-text-icon',
465                             text : "Bulk Add",
466                             icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
467                         },
468                         {
469                             xtype: 'Button',
470                             xns: Roo.Toolbar,
471                             listeners : {
472                                 click : function()
473                                 {
474                                     var s = _this.grid.getSelectionModel().getSelections();
475                                     if (!s.length || (s.length > 1))  {
476                                         Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
477                                         return;
478                                     }
479                                   
480                                     Pman.Dialog.PersonEdit.dialog.show(s[0].data, function() {
481                                         _this.grid.footer.onClick('first');
482                                     }); 
483                                     
484                                 }
485                             },
486                             cls : 'x-btn-text-icon',
487                             text : "Edit",
488                             icon : Roo.rootURL + 'images/default/tree/leaf.gif'
489                         },
490                         {
491                             xtype: 'TextField',
492                             xns: Roo.form
493                         },
494                         {
495                             xtype: 'Fill',
496                             xns: Roo.Toolbar
497                         },
498                         {
499                             xtype: 'Button',
500                             xns: Roo.Toolbar,
501                             listeners : {
502                                 click : function()
503                                 {
504                                     // Pman.genericDelete(_this, 'Person'); 
505                                 }
506                             },
507                             cls : 'x-btn-text-icon',
508                             text : "Remove",
509                             icon : rootURL + '/Pman/templates/images/trash.gif'
510                         }
511                     ]
512                 },
513                 colModel : [
514                     {
515                         xtype: 'ColumnModel',
516                         xns: Roo.grid,
517                         dataIndex : 'project_id_code',
518                         header : 'Project',
519                         width : 75,
520                         renderer : function(v) { return String.format('{0}', v); }
521                     },
522                     {
523                         xtype: 'ColumnModel',
524                         xns: Roo.grid,
525                         dataIndex : 'company_id_comptype',
526                         header : 'Type',
527                         width : 50,
528                         renderer : function(v,x,r) {
529                             if (r.data.office_id) {
530                                 return String.format('{0} - {1}', v, r.data.office_id_name); 
531                             } 
532                             return String.format('{0}', v); 
533                         }
534                     },
535                     {
536                         xtype: 'ColumnModel',
537                         xns: Roo.grid,
538                         dataIndex : 'company_id_name',
539                         header : 'Company',
540                         width : 75,
541                         renderer : function(v,x,r) {
542                             if (r.data.office_id) {
543                                 return String.format('{0} - {1}', v, r.data.office_id_name); 
544                             } 
545                             return String.format('{0}', v); 
546                         }
547                     },
548                     {
549                         xtype: 'ColumnModel',
550                         xns: Roo.grid,
551                         header : 'Name',
552                         width : 200,
553                         dataIndex : 'name',
554                         renderer : function(v) { return String.format('{0}', v); }
555                     },
556                     {
557                         xtype: 'ColumnModel',
558                         xns: Roo.grid,
559                         dataIndex : 'role',
560                         header : 'Role',
561                         width : 100,
562                         renderer : function(v) { return String.format('{0}', v); }
563                     },
564                     {
565                         xtype: 'ColumnModel',
566                         xns: Roo.grid,
567                         dataIndex : 'phone',
568                         header : 'Phone',
569                         width : 100,
570                         renderer : function(v) { return String.format('{0}', v); }
571                     },
572                     {
573                         xtype: 'ColumnModel',
574                         xns: Roo.grid,
575                         dataIndex : 'fax',
576                         header : 'Fax',
577                         width : 100,
578                         renderer : function(v) { return String.format('{0}', v); }
579                     },
580                     {
581                         xtype: 'ColumnModel',
582                         xns: Roo.grid,
583                         header : 'Email',
584                         width : 200,
585                         dataIndex : 'email',
586                         renderer : function(v) { return String.format('{0}', v); }
587                     },
588                     {
589                         xtype: 'ColumnModel',
590                         xns: Roo.grid,
591                         header : 'Active',
592                         width : 75,
593                         dataIndex : 'active',
594                         renderer : function(v) { return String.format('{0}', v); }
595                     }
596                 ]
597             }
598         });
599         this.layout = this.panel.layout;
600
601     }
602 });