Pman.Tab.AdminContacts.bjs
[Pman.Admin] / Pman.Tab.AdminContacts.bjs
1 {
2     "id": "roo-file-70",
3     "name": "Pman.Tab.AdminContacts",
4     "parent": "Pman.Tab.AdminContactsManager",
5     "title": "Pman.Tab.AdminContacts",
6     "path": "/home/chris/gitlive/Pman.Admin/Pman.Tab.AdminContacts.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
11             },
12             "autoScroll": true,
13             "background": true,
14             "fitContainer": true,
15             "fitToframe": true,
16             "region": "center",
17             "tableName": "Person",
18             "title": "Person",
19             "xtype": "GridPanel",
20             "|xns": "Roo",
21             "items": [
22                 {
23                     "listeners": {
24                         "|render": "function() \n{\n    _this.grid = this; \n    if (!_this.dialog) {\n        _this.dialog = Pman.Dialog.PersonEdit;\n        \n    }\n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
25                         "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n",
26                         "cellclick": "function (_self, rowIndex, columnIndex, e)\n{\n\n        var di = this.colModel.getDataIndex(columnIndex);\n        if (di != 'active') {\n            return;\n        }\n         \n        var rec = _this.grid.ds.getAt(rowIndex);\n        \n        rec.set('active', rec.data.active ? 0 : 1);\n        rec.commit();\n         \n        \n}"
27                     },
28                     "*prop": "grid",
29                     "autoExpandColumn": "name",
30                     "ddGroup": "groupDD",
31                     "enableDrag": true,
32                     "loadMask": true,
33                     "xtype": "Grid",
34                     "|xns": "Roo.grid",
35                     "items": [
36                         {
37                             "listeners": {
38                                 "beforeload": "function (_self, o)\n{\n    if(!_this.active_company_button.pressed){\n        o.params['!company_id_comptype'] = 'OWNER';\n    }\n    \n    o.params['query[search]'] = _this.searchBox.getValue();\n    \n    if (!_this.activeButton) {return; false;}\n    \n    if (_this.companyCombo &&   _this.companyCombo.getValue()) {\n        o.params.company_id =   _this.companyCombo.getValue();\n    }\n    \n    \n    o.params.active = _this.activeButton.pressed ? 0 : 1;\n    \n    if(_this.active_company_button.pressed){\n        o.params.company_id = 0;\n    }\n    if (!Pman.Tab.AdminContactsGroup) { \n        return false;\n    }\n    \n    \n    if (Pman.Tab.AdminContactsGroup && Pman.Tab.AdminContactsGroup.grid) {\n        var tms = Pman.Tab.AdminContactsGroup.grid.getSelectionModel().getSelected();\n        \n        if (!tms) {\n            return false;\n        }\n        o.params['query[in_group]'] = tms.data.id;\n        o.params['query[type]'] = 2; // group type..\n        \n    }\n    \n    if (Pman.Tab.AdminCountries && Pman.Tab.AdminCountries.grid) {\n        var tms = Pman.Tab.AdminCountries.grid.getSelectionModel().getSelected();\n        \n        if (!tms) {\n            return false;\n        }\n        o.params['query[in_country]'] = tms.data.country;\n        //o.params['query[type]'] = 2; // group type..\n        \n    }\n    \n    //o.params['query[name]'] = _this.searchBox.getValue();\n  \n}",
39                                 "update": "function (_self, record, operation)\n{\n    if (operation != 'commit') {\n        return;\n    }\n    // only used to change active status.\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/Person.php',\n        method :'POST',\n        params : {\n            id : record.data.id,\n            active: record.data.active\n            \n        },\n        success : function() {\n            // do nothing\n            \n            _this.grid.ds.remove(record);\n            \n        },\n        failure : function() \n        {\n            Roo.MessageBox.alert(\"Error\", \"saving failed\", function() {\n                _this.grid.footer.onClick('first');\n            });\n        }\n    });\n}"
40                             },
41                             "*prop": "dataSource",
42                             "remoteSort": true,
43                             "xtype": "Store",
44                             "|sortInfo": "{ field : 'name', direction: 'ASC' }",
45                             "|xns": "Roo.data",
46                             "items": [
47                                 {
48                                     "*prop": "proxy",
49                                     "xtype": "HttpProxy",
50                                     "method": "GET",
51                                     "|url": "baseURL + '/Roo/Person.php'",
52                                     "|xns": "Roo.data"
53                                 },
54                                 {
55                                     "|xns": "Roo.data",
56                                     "xtype": "JsonReader",
57                                     "totalProperty": "total",
58                                     "root": "data",
59                                     "*prop": "reader",
60                                     "id": "id",
61                                     "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    },\n    {\n        'name': 'phone',\n        'type': 'string'\n    },\n    {\n        'name': 'fax',\n        'type': 'string'\n    },\n    {\n        'name': 'email',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'role',\n        'type': 'string'\n    },\n    {\n        'name': 'active',\n        'type': 'int'\n    },\n    {\n        'name': 'remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'lang',\n        'type': 'string'\n    },\n    {\n        'name': 'no_reset_sent',\n        'type': 'int'\n    },\n    {\n        'name': 'action_type',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id',\n        'type': 'int'\n    },\n    {\n        'name': 'office_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'office_id_company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'office_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'office_id_address',\n        'type': 'string'\n    },\n    {\n        'name': 'office_id_phone',\n        'type': 'string'\n    },\n    {\n        'name': 'office_id_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'office_id_email',\n        'type': 'string'\n    },\n    {\n        'name': 'office_id_role',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_code',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'company_id_address',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_tel',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_email',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'company_id_isOwner',\n        'type': 'int'\n    },\n    {\n        'name': 'company_id_logo_id',\n        'type': 'int'\n    },\n    {\n        'name': 'company_id_background_color',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_comptype',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_url',\n        'type': 'string'\n    },\n    {\n        'name': 'company_id_main_office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'company_id_created_by',\n        'type': 'int'\n    },\n    {\n        'name': 'company_id_created_dt',\n        'type': 'date'\n    },\n    {\n        'name': 'company_id_updated_by',\n        'type': 'int'\n    },\n    {\n        'name': 'company_id_updated_dt',\n        'type': 'date'\n    },\n    {\n        'name': 'company_id_passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'project_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'project_id_code',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id_active',\n        'type': 'int'\n    },\n    {\n        'name': 'project_id_type',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id_client_id',\n        'type': 'int'\n    },\n    {\n        'name': 'project_id_team_id',\n        'type': 'int'\n    },\n    {\n        'name': 'project_id_file_location',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id_open_date',\n        'type': 'date'\n    },\n    {\n        'name': 'project_id_open_by',\n        'type': 'int'\n    },\n    {\n        'name': 'project_id_close_date',\n        'type': 'date'\n    },\n    {\n        'name': 'project_id_countries',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id_languages',\n        'type': 'string'\n    },\n    {\n        'name': 'project_id_agency_id',\n        'type': 'int'\n    },\n    {\n        'name': 'owner_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'owner_id_office_id',\n        'type': 'int'\n    },\n    {\n        'name': 'owner_id_name',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_phone',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_fax',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_email',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_company_id',\n        'type': 'int'\n    },\n    {\n        'name': 'owner_id_role',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_active',\n        'type': 'int'\n    },\n    {\n        'name': 'owner_id_remarks',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_passwd',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_owner_id',\n        'type': 'int'\n    },\n    {\n        'name': 'owner_id_lang',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_no_reset_sent',\n        'type': 'int'\n    },\n    {\n        'name': 'owner_id_action_type',\n        'type': 'string'\n    },\n    {\n        'name': 'owner_id_project_id',\n        'type': 'int'\n    }\n]"
62                                 }
63                             ]
64                         },
65                         {
66                             "*prop": "footer",
67                             "xtype": "PagingToolbar",
68                             "pageSize": 25,
69                             "displayInfo": true,
70                             "displayMsg": "Displaying Person{0} - {1} of {2}",
71                             "emptyMsg": "No Person found",
72                             "|xns": "Roo",
73                             "items": [
74                                 {
75                                     "text": "Drag person to add or remove from group",
76                                     "xtype": "TextItem",
77                                     "|xns": "Roo.Toolbar"
78                                 }
79                             ]
80                         },
81                         {
82                             "*prop": "toolbar",
83                             "xtype": "Toolbar",
84                             "|xns": "Roo",
85                             "items": [
86                                 {
87                                     "text": "Search",
88                                     "xtype": "TextItem",
89                                     "|xns": "Roo.Toolbar"
90                                 },
91                                 {
92                                     "listeners": {
93                                         "render": "function (_self)\n{\n    _this.searchBox = _self;\n}",
94                                         "show": "function (_self,e)\n{\n    if (e.getCharCode() != 13) {\n        return;\n    }\n    _this.grid.footer.onClick('first');\n}",
95                                         "specialkey": "function (_self, e)\n{\n  if (e.getKey() == 13) {\n    _this.grid.footer.onClick('first');\n  }\n}"
96                                     },
97                                     "xtype": "TextField",
98                                     "|xns": "Roo.form"
99                                 },
100                                 {
101                                     "listeners": {
102                                         "render": "function (_self)\n{\n  _this.companyCombo = _self;\n}",
103                                         "select": "function (combo, record, index)\n{\n   _this.grid.footer.onClick.defer(300,_this.grid.footer,[ 'first'] );\n}"
104                                     },
105                                     "displayField": "name",
106                                     "editable": true,
107                                     "emptyText": "Select Company",
108                                     "forceSelection": true,
109                                     "hiddenName": "company_id",
110                                     "listWidth": 400,
111                                     "loadingText": "Searching...",
112                                     "minChars": 2,
113                                     "name": "company_name",
114                                     "pageSize": 20,
115                                     "qtip": "Select Companies",
116                                     "queryParam": "query[name]",
117                                     "selectOnFocus": true,
118                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> </div>",
119                                     "triggerAction": "all",
120                                     "typeAhead": true,
121                                     "valueField": "id",
122                                     "width": 150,
123                                     "xtype": "ComboBox",
124                                     "|xns": "Roo.form",
125                                     "items": [
126                                         {
127                                             "listeners": {
128                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
129                                             },
130                                             "*prop": "store",
131                                             "remoteSort": true,
132                                             "xtype": "Store",
133                                             "|sortInfo": "{ direction : 'ASC', field: 'name' }",
134                                             "|xns": "Roo.data",
135                                             "items": [
136                                                 {
137                                                     "*prop": "proxy",
138                                                     "xtype": "HttpProxy",
139                                                     "method": "GET",
140                                                     "|xns": "Roo.data",
141                                                     "|url": "baseURL + '/Roo/Companies.php'"
142                                                 },
143                                                 {
144                                                     "*prop": "reader",
145                                                     "xtype": "JsonReader",
146                                                     "|xns": "Roo.data",
147                                                     "id": "id",
148                                                     "root": "data",
149                                                     "totalProperty": "total",
150                                                     "|fields": "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"code\",\"type\":\"string\"}]"
151                                                 }
152                                             ]
153                                         }
154                                     ]
155                                 },
156                                 {
157                                     "listeners": {
158                                         "|click": "function (_self, e)\n{\n_this.grid.footer.onClick('first');\n}"
159                                     },
160                                     "cls": "x-btn-icon",
161                                     "xtype": "Button",
162                                     "|icon": "rootURL + '/Pman/templates/images/search.gif'",
163                                     "|xns": "Roo.Toolbar"
164                                 },
165                                 {
166                                     "listeners": {
167                                         "|click": "function (_self, e)\n{\n_this.searchBox.setValue('');\n    _this.grid.footer.onClick('first');\n}"
168                                     },
169                                     "cls": "x-btn-icon",
170                                     "xtype": "Button",
171                                     "|icon": "rootURL + '/Pman/templates/images/edit-clear.gif'",
172                                     "|xns": "Roo.Toolbar"
173                                 },
174                                 {
175                                     "listeners": {
176                                         "toggle": "function (_self, pressed)\n{\n   _this.grid.footer.onClick('first');\n   this.setText(pressed ? \"Show Active\" : \"Show Removed\");\n   \n   \n}",
177                                         "render": "function (_self)\n{\n  _this.activeButton = _self;\n}"
178                                     },
179                                     "enableToggle": true,
180                                     "text": "Show Removed",
181                                     "xtype": "Button",
182                                     "|xns": "Roo.Toolbar"
183                                 },
184                                 {
185                                     "listeners": {
186                                         "toggle": "function (_self, pressed)\n{\n   _this.grid.footer.onClick('first');\n   this.setText(pressed ? \"Show Company\" : \"Show No Company\");\n   \n   \n}",
187                                         "render": "function (_self)\n{\n  _this.active_company_button = _self;\n}"
188                                     },
189                                     "enableToggle": true,
190                                     "text": "Show No Company",
191                                     "xtype": "Button",
192                                     "|xns": "Roo.Toolbar"
193                                 },
194                                 {
195                                     "listeners": {
196                                         "click": "function (_self, e)\n{\n    var s = _this.grid.getSelectionModel().getSelections();\n    if(s.length != 1){\n        Roo.MessageBox.alert(\"Error\", \"Select a Person\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Login.php',\n        method : 'GET',\n        params : {\n            'switch' : s[0].data.id\n        },\n        success : function (){\n            document.location = baseURL + '?ts=' + Math.random();\n        },\n        failure : function (d){\n            Roo.log(d);\n            Roo.MessageBox.alert(\"Error\", d);\n        }\n    });\n}"
197                                     },
198                                     "text": "Switch to Selected User",
199                                     "xtype": "Button",
200                                     "|xns": "Roo.Toolbar"
201                                 },
202                                 {
203                                     "|xns": "Roo.Toolbar",
204                                     "xtype": "Fill"
205                                 },
206                                 {
207                                     "listeners": {
208                                         "|click": "function()\n{\n    \n    _this.dialog.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
209                                     },
210                                     "cls": "x-btn-text-icon",
211                                     "text": "Add",
212                                     "xtype": "Button",
213                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
214                                     "|xns": "Roo.Toolbar"
215                                 },
216                                 {
217                                     "listeners": {
218                                         "|click": "function()\n{\n    \n    Pman.Dialog.PersonBulkAdd.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
219                                     },
220                                     "cls": "x-btn-text-icon",
221                                     "text": "Bulk Add",
222                                     "xtype": "Button",
223                                     "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
224                                     "|xns": "Roo.Toolbar"
225                                 },
226                                 {
227                                     "listeners": {
228                                         "|click": "function()\n{\n    var s = _this.grid.getSelectionModel().getSelections();\n    if (!s.length || (s.length > 1))  {\n        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n        return;\n    }\n  \n    _this.dialog.show(s[0].data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n    \n}\n"
229                                     },
230                                     "cls": "x-btn-text-icon",
231                                     "text": "Edit",
232                                     "xtype": "Button",
233                                     "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
234                                     "|xns": "Roo.Toolbar"
235                                 },
236                                 {
237                                     "listeners": {
238                                         "|click": "function()\n{\n     Pman.genericDelete(_this, 'Person'); \n}\n        "
239                                     },
240                                     "cls": "x-btn-text-icon",
241                                     "text": "Delete",
242                                     "xtype": "Button",
243                                     "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
244                                     "|xns": "Roo.Toolbar"
245                                 }
246                             ]
247                         },
248                         {
249                             "*prop": "colModel[]",
250                             "dataIndex": "project_id_code",
251                             "header": "Project",
252                             "hidden": true,
253                             "sortable": true,
254                             "width": 75,
255                             "xtype": "ColumnModel",
256                             "|renderer": "function(v,x,r) { \n      return String.format('<span qtip=\"{0}\">{1}</span>', \n                    r.data.project_id_name,\n                    v);\n }",
257                             "|xns": "Roo.grid"
258                         },
259                         {
260                             "*prop": "colModel[]",
261                             "dataIndex": "company_id_comptype",
262                             "header": "Type",
263                             "sortable": true,
264                             "width": 50,
265                             "xtype": "ColumnModel",
266                             "|renderer": "function(v,x,r) {\n    if (r.data.office_id) {\n        return String.format('{0} - {1}', v, r.data.office_id_name); \n    } \n    return String.format('{0}', v); \n}",
267                             "|xns": "Roo.grid"
268                         },
269                         {
270                             "*prop": "colModel[]",
271                             "dataIndex": "company_id_name",
272                             "header": "Company",
273                             "sortable": true,
274                             "width": 150,
275                             "xtype": "ColumnModel",
276                             "|renderer": "function(v,x,r) {\n    if (r.data.office_id) {\n        return String.format('{0} - {1}', v, r.data.office_id_name); \n    } \n    return String.format('{0}', v); \n}",
277                             "|xns": "Roo.grid"
278                         },
279                         {
280                             "*prop": "colModel[]",
281                             "dataIndex": "name",
282                             "header": "Name",
283                             "sortable": true,
284                             "width": 200,
285                             "xtype": "ColumnModel",
286                             "|renderer": "function(v) { return String.format('{0}', v); }",
287                             "|xns": "Roo.grid"
288                         },
289                         {
290                             "*prop": "colModel[]",
291                             "dataIndex": "role",
292                             "header": "Role",
293                             "width": 100,
294                             "xtype": "ColumnModel",
295                             "|renderer": "function(v) { return String.format('{0}', v); }",
296                             "|xns": "Roo.grid"
297                         },
298                         {
299                             "*prop": "colModel[]",
300                             "dataIndex": "phone",
301                             "header": "Phone",
302                             "width": 100,
303                             "xtype": "ColumnModel",
304                             "|renderer": "function(v) { return String.format('{0}', v); }",
305                             "|xns": "Roo.grid"
306                         },
307                         {
308                             "*prop": "colModel[]",
309                             "dataIndex": "fax",
310                             "header": "Fax",
311                             "width": 100,
312                             "xtype": "ColumnModel",
313                             "|renderer": "function(v) { return String.format('{0}', v); }",
314                             "|xns": "Roo.grid"
315                         },
316                         {
317                             "*prop": "colModel[]",
318                             "dataIndex": "email",
319                             "header": "Email",
320                             "sortable": true,
321                             "width": 200,
322                             "xtype": "ColumnModel",
323                             "|renderer": "function(v) {\n   return (v.length && v.indexOf('@') > 0 ) ? \n                    String.format('<a href=\"mailto:{0}\">{0}</a>',v) : v;\n }",
324                             "|xns": "Roo.grid"
325                         },
326                         {
327                             "*prop": "colModel[]",
328                             "dataIndex": "active",
329                             "header": "Active",
330                             "width": 75,
331                             "xtype": "ColumnModel",
332                             "|renderer": "function(v) {  \n    var state = v> 0 ?  '-checked' : '';\n\n    return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n                \n }",
333                             "|xns": "Roo.grid"
334                         }
335                     ]
336                 }
337             ]
338         }
339     ],
340     "permname": "Core.Person",
341     "modOrder": "001"
342 }