Commit 3b15a66d3390c6ea73f74f7d5ef5c77dce03bb9e

Authored by Swarn Singh
Exists in master

Merge branch 'master' of git.viithiisys.com:viithiisys/acufuel

app/partials/ContactView/ContactView.controller.js
... ... @@ -108,5 +108,20 @@
108 108 }
109 109 })
110 110 }
  111 +
  112 + $scope.exportContacts = function() {
  113 + $scope.showLoader = true;
  114 + var fileName = "contacts.csv";
  115 + var a = document.createElement("a");
  116 + document.body.appendChild(a);
  117 + ContactViewService.exportContacts().then(function(result) {
  118 + var file = new Blob([result], {type: 'application/csv'});
  119 + var fileURL = URL.createObjectURL(file);
  120 + a.href = fileURL;
  121 + a.download = fileName;
  122 + a.click();
  123 + $scope.showLoader = false;
  124 + })
  125 + }
111 126  
112 127 }]);
113 128 \ No newline at end of file
... ...
app/partials/ContactView/ContactView.html
... ... @@ -26,15 +26,15 @@
26 26 <i class="fa fa-caret-down" aria-hidden="true"></i>
27 27 </a>
28 28 </li>
29   - <li style="margin: 0px 10px 4px 40px;"><input type="text" style="height:31px;"class="form-control" name="name" id="name" placeholder="Search In Table" ng-model="search" ng-keyup="searchString(search)" ng-minlength="minlength"></li>
30   - <li><button type="button" class="btn btn-default btn-sm">Clear Search And Filters</button></li>
  29 + <li style="margin: 0px 10px 4px 40px;"><input type="text" style="height:31px;"class="form-control" ng-model="searchText" placeholder="Search In Table" ng-model="search" ng-minlength="minlength"></li>
  30 + <li><button type="button" class="btn btn-default btn-sm" ng-click="displayContactList.filter({}); searchText=null">Clear Search And Filters</button></li>
31 31 <li style="float: right"> <button type="submit" data-toggle="modal" data-target="#contact-modal-3" class="btn btn-success btn-sm"> <i class="fa fa-plus" aria-hidden="true"></i> Add Contact </button></li>
32 32 </ul>
33 33 <br>
34 34 <div class="tab-content customer-table" style="margin:0px">
35 35 <div class="tab-pane active" id="companyView">
36 36 <table ng-table="displayContactList" class="table table-striped table-condensed" show-filter="true">
37   - <tr ng-repeat="row in $data track by row.id" style="cursor: pointer;" ui-sref="app.viewContact({id : row.id})">
  37 + <tr ng-repeat="row in $data | filter:searchText" style="cursor: pointer;" ui-sref="app.viewContact({id : row.id})">
38 38 <td data-title="'Last Name'" filter="{lastName: 'text'}" sortable="'lastName'">
39 39 {{row.lastName}}
40 40 </td>
... ... @@ -62,7 +62,7 @@
62 62 </tr>
63 63 </table>
64 64  
65   - <button type="button" class="btn btn-warning exportBtn">Export Customers</button>
  65 + <button type="button" ng-click="exportContacts()" class="btn btn-warning exportBtn">Export CSV</button>
66 66  
67 67 <!-- <table class="table table-striped">
68 68 <thead>
... ...
app/partials/ContactView/ContactView.service.js
... ... @@ -53,6 +53,21 @@
53 53 })
54 54 return deferred.promise;
55 55 }
  56 +
  57 + this.exportContacts = function(){
  58 + var deferred = $q.defer();
  59 + $http({
  60 + method : 'GET',
  61 + url : BASE_URL.url +'/company/contact/export'
  62 + })
  63 + .then(function (result){
  64 + deferred.resolve(result.data);
  65 + },function (result){
  66 + console.log(result)
  67 + deferred.resolve(result.data);
  68 + })
  69 + return deferred.promise;
  70 + }
56 71 }
57 72  
58 73 })();
59 74 \ No newline at end of file
... ...
app/partials/FuelVendors/FuelVendors.controller.js
... ... @@ -41,6 +41,7 @@
41 41 $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id;
42 42 }
43 43 }
  44 + $scope.companyList[i].source = "Vendor"
44 45 }
45 46 $scope.displayVendorList = new NgTableParams({
46 47 page: 1,
... ... @@ -53,7 +54,7 @@
53 54  
54 55 $scope.editMargin = function(vendor){
55 56 console.log(vendor.masterMargin)
56   -
  57 + $scope.showLoader = true;
57 58 var companyMargin = "vendorName=" + vendor.vendorName + "&masterMargin=" + vendor.masterMargin
58 59 + "&addressOne=" + vendor.addressOne + "&addressTwo=" + vendor.addressTwo + "&city=" + vendor.city + "&state="
59 60 + vendor.state + "&country=" + vendor.country + "&zipcode=" + vendor.zipcode + "&internalNote="
... ... @@ -63,10 +64,12 @@
63 64  
64 65 ViewFuelVendorService.updateContact(companyMargin).then(function(result) {
65 66 if(result != null && result.success){
  67 + $scope.showLoader = false;
66 68 toastr.success(''+result.success+'', {
67 69 closeButton: true
68 70 })
69 71 }else{
  72 + $scope.showLoader = false;
70 73 toastr.error(''+result.statusText+'', {
71 74 closeButton: true
72 75 })
... ... @@ -138,5 +141,20 @@
138 141 }
139 142  
140 143 }
  144 +
  145 + $scope.exportVendors = function() {
  146 + $scope.showLoader = true;
  147 + var fileName = "vendors.csv";
  148 + var a = document.createElement("a");
  149 + document.body.appendChild(a);
  150 + FuelVendorsService.exportVendors().then(function(result) {
  151 + var file = new Blob([result], {type: 'application/csv'});
  152 + var fileURL = URL.createObjectURL(file);
  153 + a.href = fileURL;
  154 + a.download = fileName;
  155 + a.click();
  156 + $scope.showLoader = false;
  157 + })
  158 + }
141 159  
142 160 }
143 161 \ No newline at end of file
... ...
app/partials/FuelVendors/FuelVendors.html
... ... @@ -93,42 +93,42 @@
93 93 <i class="fa fa-caret-down" aria-hidden="true"></i>
94 94 </a>
95 95 </li>
96   - <li style="margin: 0px 10px 4px 40px;"><input type="text" style="height:31px;"class="form-control" name="name" id="name" placeholder="Search In Table"></li>
97   - <li><button type="button" class="btn btn-default btn-sm">Clear Search And Filters</button></li>
  96 + <li style="margin: 0px 10px 4px 40px;"><input type="text" style="height:31px;"class="form-control" ng-model="searchText" placeholder="Search In Table"></li>
  97 + <li><button type="button" class="btn btn-default btn-sm" ng-click="displayVendorList.filter({}); searchText=null">Clear Search And Filters</button></li>
98 98 <li style="float:right"><button type="submit" data-toggle="modal" data-target="#vendor-modal-3" class="btn btn-success btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> Add Vendor</button></li>
99 99 </ul>
100 100 <br>
101 101 <div class="tab-content customer-table" style="margin:0px">
102 102 <div class="tab-pane active" id="companyView">
103 103 <table ng-table="displayVendorList" class="table table-striped table-condensed" show-filter="true">
104   - <tr ng-repeat="row in $data track by row.id" style="cursor: pointer;" ui-sref="app.viewFuelVendor({id : row.id})">
105   - <td data-title="'Vendor Name'" filter="{vendorName: 'text'}" sortable="'vendorName'">
  104 + <tr ng-repeat="row in $data | filter:searchText" style="cursor: pointer;">
  105 + <td data-title="'Vendor Name'" filter="{vendorName: 'text'}" sortable="'vendorName'" ui-sref="app.viewFuelVendor({id : row.id})">
106 106 {{row.vendorName}}
107 107 </td>
108   - <td data-title="'Main Phone'" filter="{newContactNumber: 'text'}" sortable="'newContactNumber'">
  108 + <td data-title="'Main Phone'" filter="{newContactNumber: 'text'}" sortable="'newContactNumber'" ui-sref="app.viewFuelVendor({id : row.id})">
109 109 {{row.newContactNumber}}
110 110 </td>
111   - <td data-title="'Primary Contact'" filter="{primaryContactName: 'text'}" sortable="'primaryContactName'">
  111 + <td data-title="'Primary Contact'" filter="{primaryContactName: 'text'}" sortable="'primaryContactName'" ui-sref="app.viewFuelVendor({id : row.id})">
112 112 {{row.primaryContactName}}
113 113 </td>
114 114  
115   - <td data-title="'Status'" filter="{activate: 'select'}" filter-data="statusFilter" sortable="'activate'">
  115 + <td data-title="'Status'" filter="{activate: 'select'}" filter-data="statusFilter" sortable="'activate'" ui-sref="app.viewFuelVendor({id : row.id})">
116 116 <button type="button" ng-if="row.activate == true" class="btn btn-success btn-xs">Active</button>
117 117 <button type="button" ng-if="row.activate == false" class="btn btn-warning btn-xs">InActive</button>
118 118 </td>
119   - <td data-title="'Source'" filter="{source: 'text'}" sortable="'source'">
120   - Vendor
  119 + <td data-title="'Source'" filter="{source: 'text'}" sortable="'source'" ui-sref="app.viewFuelVendor({id : row.id})">
  120 + {{row.source}}
121 121 </td>
122 122 <td data-title="'Margin Setting'" filter="{masterMargin: 'select'}" filter-data="marginFilterOptions" sortable="'masterMargin'">
123 123 <select class="form-control" ng-change="editMargin(row)" style="height:31px;" ng-model="row.masterMargin" ng-selected="" ng-options="margin.id as margin.marginName for margin in jetMarginList" required></select>
124 124 </td>
125   - <td data-title="'All In'" filter="{allIn: 'text'}" sortable="'allIn'">
  125 + <td data-title="'All In'" filter="{marginAllIn: 'text'}" sortable="'marginAllIn'" ui-sref="app.viewFuelVendor({id : row.id})">
126 126 {{row.marginAllIn}}
127 127 </td>
128 128 </tr>
129 129 </table>
130 130  
131   - <button type="button" class="btn btn-warning exportBtn">Export Customers</button>
  131 + <button type="button" ng-click="exportVendors()" class="btn btn-warning exportBtn">Export CSV</button>
132 132  
133 133 <!-- <table class="table table-striped">
134 134 <thead>
... ...
app/partials/FuelVendors/FuelVendors.service.js
... ... @@ -56,6 +56,21 @@
56 56 })
57 57 return deferred.promise;
58 58 }
  59 +
  60 + this.exportVendors = function(){
  61 + var deferred = $q.defer();
  62 + $http({
  63 + method : 'GET',
  64 + url : BASE_URL.url +'/vendor/export'
  65 + })
  66 + .then(function (result){
  67 + deferred.resolve(result.data);
  68 + },function (result){
  69 + console.log(result)
  70 + deferred.resolve(result.data);
  71 + })
  72 + return deferred.promise;
  73 + }
59 74 }
60 75  
61 76 })();
62 77 \ No newline at end of file
... ...
app/partials/customers/customers.controller.js
... ... @@ -92,6 +92,7 @@
92 92  
93 93 $scope.editMargin = function(customer){
94 94 console.log('customer', customer);
  95 + $scope.showLoader = true;
95 96 event.stopPropagation();
96 97  
97 98 var companyMargin = "companyName=" + customer.companyName + "&masterMargin=" + customer.masterMargin
... ... @@ -103,10 +104,12 @@
103 104  
104 105 ViewCompanyService.updateContact(companyMargin).then(function(result) {
105 106 if(result != null && result.success){
  107 + $scope.showLoader = false;
106 108 toastr.success(''+result.success+'', {
107 109 closeButton: true
108 110 })
109 111 }else{
  112 + $scope.showLoader = false;
110 113 toastr.error(''+result.statusText+'', {
111 114 closeButton: true
112 115 })
... ... @@ -271,6 +274,21 @@
271 274 }
272 275  
273 276 /* ng table */
  277 +
  278 + $scope.exportCompany = function() {
  279 + $scope.showLoader = true;
  280 + var fileName = "companies.csv";
  281 + var a = document.createElement("a");
  282 + document.body.appendChild(a);
  283 + CustomersService.exportCompany().then(function(result) {
  284 + var file = new Blob([result], {type: 'application/csv'});
  285 + var fileURL = URL.createObjectURL(file);
  286 + a.href = fileURL;
  287 + a.download = fileName;
  288 + a.click();
  289 + $scope.showLoader = false;
  290 + })
  291 + }
274 292  
275 293  
276 294 }
277 295 \ No newline at end of file
... ...
app/partials/customers/customers.html
... ... @@ -93,38 +93,38 @@
93 93 <i class="fa fa-caret-down" aria-hidden="true"></i>
94 94 </a>
95 95 </li>
96   - <li style="margin: 0px 10px 4px 40px;"><input type="text" style="height:31px;"class="form-control" name="name" id="name" placeholder="Search In Table"></li>
97   - <li><button type="button" class="btn btn-default btn-sm">Clear Search And Filters</button></li>
  96 + <li style="margin: 0px 10px 4px 40px;"><input type="text" style="height:31px;"class="form-control" ng-model="searchText" placeholder="Search In Table"></li>
  97 + <li><button type="button" class="btn btn-default btn-sm" ng-click="displayCompanyList.filter({}); searchText=null">Clear Search And Filters</button></li>
98 98 <li style="float:right"><button type="submit" data-toggle="modal" data-target="#demo-modal-3" class="btn btn-success btn-sm"><i class="fa fa-plus" aria-hidden="true"></i> Add Company</button></li>
99 99 </ul>
100 100 <br>
101 101 <div class="tab-content customer-table" style="margin:0px">
102 102 <div class="tab-pane active" id="companyView">
103 103 <table ng-table="displayCompanyList" class="table table-striped table-condensed" show-filter="true">
104   - <tr ng-repeat="row in $data track by row.id" style="cursor: pointer;" ui-sref="app.viewCompany({id : row.id})">
105   - <td data-title="'Company Name'" filter="{companyName: 'text'}" sortable="'companyName'">
  104 + <tr ng-repeat="row in $data | filter:searchText"" style="cursor: pointer;">
  105 + <td data-title="'Company Name'" filter="{companyName: 'text'}" sortable="'companyName'" ui-sref="app.viewCompany({id : row.id})">
106 106 {{row.companyName}}
107 107 </td>
108   - <td data-title="'Fleet'" filter="{companyAircraftSize: 'text'}" sortable="'companyAircraftSize'">
  108 + <td data-title="'Fleet'" filter="{companyAircraftSize: 'text'}" sortable="'companyAircraftSize'" ui-sref="app.viewCompany({id : row.id})">
109 109 {{row.companyAircraftSize}}
110 110 </td>
111   - <td data-title="'Main Phone'" filter="{newContactNumber: 'text'}" sortable="'newContactNumber'">
  111 + <td data-title="'Main Phone'" filter="{newContactNumber: 'text'}" sortable="'newContactNumber'" ui-sref="app.viewCompany({id : row.id})">
112 112 {{row.newContactNumber}}
113 113 </td>
114   - <td data-title="'Primary Contact'" filter="{primaryContactName: 'text'}" sortable="'primaryContactName'">
  114 + <td data-title="'Primary Contact'" filter="{primaryContactName: 'text'}" sortable="'primaryContactName'" ui-sref="app.viewCompany({id : row.id})">
115 115 {{row.primaryContactName}}
116 116 </td>
117   - <td data-title="'Base'" filter="{baseIcao: 'text'}" sortable="'baseIcao'">
  117 + <td data-title="'Base'" filter="{baseIcao: 'text'}" sortable="'baseIcao'" ui-sref="app.viewCompany({id : row.id})">
118 118 {{row.baseIcao}}
119 119 </td>
120   - <td data-title="'Status'" filter="{activate: 'select'}" filter-data="statusFilter" sortable="'activate'">
  120 + <td data-title="'Status'" filter="{activate: 'select'}" filter-data="statusFilter" sortable="'activate'" ui-sref="app.viewCompany({id : row.id})">
121 121 <button type="button" ng-if="row.activate == true" class="btn btn-success btn-xs">Active</button>
122 122 <button type="button" ng-if="row.activate == false" class="btn btn-warning btn-xs">InActive</button>
123 123 </td>
124 124 <td data-title="'Margin Setting'" filter="{masterMargin: 'select'}" filter-data="marginFilterOptions" sortable="'masterMargin'">
125 125 <select class="form-control" ng-change="editMargin(row)" style="height:31px;" ng-model="row.masterMargin" ng-selected="" ng-options="margin.id as margin.marginName for margin in jetMarginList" required></select>
126 126 </td>
127   - <td data-title="'All In'" filter="{allIn: 'text'}" sortable="'allIn'">
  127 + <td data-title="'All In'" filter="{marginAllIn: 'text'}" sortable="'marginAllIn'" ui-sref="app.viewCompany({id : row.id})">
128 128 {{row.marginAllIn}}
129 129 </td>
130 130 <td data-title="''">
... ... @@ -133,7 +133,7 @@
133 133 </tr>
134 134 </table>
135 135  
136   - <button type="button" class="btn btn-warning exportBtn">Export Customers</button>
  136 + <button type="button" ng-click="exportCompany()" class="btn btn-warning exportBtn">Export CSV</button>
137 137  
138 138 <!--
139 139 <table class="table table-striped">
... ...
app/partials/customers/customers.service.js
... ... @@ -148,8 +148,21 @@
148 148 })
149 149 return deferred.promise;
150 150 }
151   -
152 151  
  152 + this.exportCompany = function(){
  153 + var deferred = $q.defer();
  154 + $http({
  155 + method : 'GET',
  156 + url : BASE_URL.url +'/company/export'
  157 + })
  158 + .then(function (result){
  159 + deferred.resolve(result.data);
  160 + },function (result){
  161 + console.log(result)
  162 + deferred.resolve(result.data);
  163 + })
  164 + return deferred.promise;
  165 + }
153 166  
154 167 }
155 168  
... ...