text changes to registration mail content
[namibia] / public / templates / page / loginreport.js
1 var template_loginreport = function( static )
2 {
3         this.static   = static;
4         this.elements = {
5                         group : new App.TemplateElement.FieldComponent('group'),
6                         groupDivision : new App.TemplateElement.FieldComponent('groupDivision'),
7                         company : new App.TemplateElement.FieldComponent('company')
8                 };
9         this.ti = null;
10         this.init = function( ti ) {
11                 this.ti = ti;
12                 App.DataStore.loadSelectListData('groups', true, 'Company', 'Group.SelectList');
13                 App.API.getTask(
14                                 'reportLogin', 'Report', 'Report.Login',
15                                 null, {}, function(){}, _w.taskContractError
16                         );
17                 this.ti.hydrate({
18                                                 'group' : {
19                                 type  : 'select',
20                                 id    : 'group',
21                                 title : 'Group Member',
22                                 value : '',
23                                 dataStoreId : 'groups',
24                                 onChange    : function () {
25                                         if (!App.DataStore.getItem('BuildSelect:group', false))
26                                         {
27                                                 var groupId = $('#group').val();
28                                                 $('#groupDivision').val('');
29                                                 $('#company').val('');
30                                                 App.DataStore.loadSelectListData(
31                                                                 'groupdivisions', false, 'Company', 'GroupDivision.SelectList',
32                                                                 null, {Filter: {group: groupId}}
33                                                                 );
34                                                 App.DataStore.loadSelectListData(
35                                                                 'companies', false, 'Company', 'Company.SelectList',
36                                                                 null, {Filter: {group: groupId}}
37                                                                 );
38                                         }
39                                 }
40                         },
41                         'groupDivision' : {
42                                 type  : 'select',
43                                 id    : 'groupDivision',
44                                 title : 'Group Division',
45                                 value : '',
46                                 dataStoreId : 'groupdivisions',
47                                 onChange    : function () {
48                                         if (!App.DataStore.getItem('BuildSelect:groupDivision', false))
49                                         {
50                                                 var groupDivisionId = $('#groupDivision').val();
51                                                 $('#company').val('');
52                                                 App.DataStore.loadSelectListData(
53                                                                 'companies', false, 'Company', 'Company.SelectList',
54                                                                 null, {Filter: {groupDivision: groupDivisionId}}
55                                                                 );
56                                         }
57                                 }
58                         },
59                         'company' : {
60                                 type  : 'select',
61                                 id    : 'company',
62                                 title : 'Company',
63                                 value : '',
64                                 dataStoreId : 'companies'
65                         }
66                 });
67         };
68         this.construct = function() {
69                 $('#frmLoginReport').validate({
70                         rules: {
71                                 dateFrom: {required: true, number: true}
72                         },
73                         submitHandler: function( form ) {
74                                 var data = {Report: _t['loginreport'].harvest()};
75                                 App.API.execTask(
76                                                 'reportLogin', data, {},
77                                                 function () {}, _w.taskExecError,
78                                                 'EXPORT', true
79                                 );
80                         }
81                 });
82                 $('#btnReport').prop('disabled', false);
83         };
84         this.destruct = function() {};
85 };