text changes to registration mail content
[namibia] / public / templates / page / transunionupload.js
1 var template_transunionupload = function (static)
2 {
3         this.static = static;
4         this.elements = {
5                 csvFile: new App.TemplateElement.FieldComponent('csvFile')
6         };
7         this.ti = null;
8         this.init = function (ti) {
9                 this.ti = ti;
10                 App.DataStore.loadSelectListData('groups', true, 'Company', 'Group.SelectList');
11                 App.API.getTask(
12                         'TransUnionUpload', 'Stock', 'Import.Upload',
13                         null, {}, function () {}, _w.taskContractError
14                 );
15                 this.ti.hydrate({
16                         'csvFile': {
17                                 type: 'document',
18                                 id: 'csvFile',
19                                 title: 'TransUnion CSV file'
20                         }
21                 });
22         };
23         this.construct = function () {
24                 $('#frmTransUnionUpload').validate({
25                         rules: {
26                                 csvFile: {required: true}
27                         },
28                         messages: {
29                                 csvFile: {
30                                         required: "CSV file required."
31                                 }
32                         },
33                         submitHandler: function (form) {
34                                 var data = {Upload: _t['transunionupload'].harvest()};
35                                 if ('' == data.Upload.csvFile)
36                                 {
37                                         alert('Please select a file to import.');
38                                         return false;
39                                 }
40                                 App.API.execTask(
41                                         'TransUnionUpload', data, {},
42                                         function (response)
43                                         {
44                                                 alert('Import Complete! Please note that this page will refresh when you click "OK."');
45                                                 window.location.reload(false);
46                                         },
47                                         function (response)
48                                         {
49                                                 alert(response.StatusReason);
50                                         }
51                                 );
52                         }
53                 });
54                 $('#btnSubmitFile').prop('disabled', false);
55         };
56         this.destruct = function () {};
57 };