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