latest updates
[namibia] / public / templates / page / valuationreport.js
1 var template_valuationreport = function( static )
2 {
3         this.static   = static;
4         this.elements = {
5                         dateFrom        : new App.TemplateElement.FieldComponent('dateFrom'),
6                         dateTo          : new App.TemplateElement.FieldComponent('dateTo')
7                 };
8         this.ti = null;
9         this.init = function( ti ) {
10                 this.ti = ti;
11                 App.DataStore.loadSelectListData('groups', true, 'Company', 'Group.SelectList');
12                 App.API.getTask(
13                                 'reportPortalValuation', 'Report', 'Report.Valuation',
14                                 null, {}, function(){}, _w.taskContractError
15                         );
16                 this.ti.hydrate({
17                         'dateFrom' : {
18                                 type  : 'date',
19                                 id    : 'dateFrom',
20                                 title : 'Date from',
21                                 style : 'datepicker',
22                                 value : ''
23                         },
24                         'dateTo' : {
25                                 type  : 'date',
26                                 id    : 'dateTp',
27                                 title : 'Date to',
28                                 style : 'datepicker',
29                                 value : ''
30                         }
31                 });
32         };
33         this.construct = function() {
34                 $('#frmValuationReport').validate({
35                         rules: {
36                                 dateFrom: {required: false, dateISO: true},
37                                 dateTo: {required: false, dateISO: true}
38                         },
39                         messages: {
40                                 dateFrom: {
41                                         dateISO: "Must be a valid date."
42                                 },
43                                 dateTo: {
44                                         dateISO: "Must be a valid date."
45                                 }
46                         },
47                         submitHandler: function( form ) {
48                                 var data = {Report: _t['valuationreport'].harvest()};
49                                 App.API.execTask(
50                                                 'reportPortalValuation', data, {},
51                                                 function () {}, _w.taskExecError,
52                                                 'EXPORT', true
53                                 );
54                         }
55                 });
56                 $('#btnReport').prop('disabled', false);
57         };
58         this.destruct = function() {};
59 };