1// Invoices Controllers ======================================================================================== 2 3// Variables ----------------------------------------------------- 4// --------------------------------------------------------------- 5 6// Functions ----------------------------------------------------- 7// --------------------------------------------------------------- 8 9// Ready --------------------------------------------------------- 10// --------------------------------------------------------------- 11 12 13angular.module('webSoDanca').controller('mySoDancaInvoicesController', ['$scope', 'util', 'dataService', '$timeout', function ($scope, util, dataService, $timeout) { 14 15 // Variables ----------------------------------------------------- 16 $scope.invoices = []; 17 $scope.searchOptions = [ 18 { name: 'Invoice #', field: 'number', type: 1 }, 19 { name: 'PO #', field: 'name', type: 1 }, 20 { name: 'Date Due', field: 'date_due', type: 2 }, 21 { name: 'Amount Due', field: 'amount_due', type: 3 }, 22 { name: 'Status', field: 'state', type: 4 } 23 ]; 24 $scope.tableHeaders = [ 25 { name: 'Invoice #', field: 'number' }, 26 { name: 'PO #', field: 'name' }, 27 { name: 'Date Due', field: 'date_due' }, 28 { name: 'Amount Due', field: 'amount_due', filters: [{ name: 'number', param: 2 }], "class": 'align_r', icon: 'fa fa-usd', totalFooter: true }, 29 { name: 'Status', field: 'state' } 30 ]; 31 32 $scope.search = { qtdShow: 50 }; 33 // --------------------------------------------------------------- 34 35 // Functions ----------------------------------------------------- 36 $scope.statement = function () { 37 var user = util.getUserClient(); 38 39 util.downloadPdf(user.commercial_entity, 'statement'); 40 }; 41 42 $scope.lineClick = function (invoice) { 43 var params = { 44 id: invoice.number 45 }; 46 util.goToPage('invoice_detail', params); 47 }; 48 $scope.loadInvoices = function (update) { 49 util.loading(true); 50 51 $timeout(() => { 52 53 let params = { 54 offset: $scope.invoices.length || 0, 55 limit: $scope.search.qtdShow, 56 partner: util.getUserClient().user_id 57 }; 58 59 if ($scope.invoices.length >= $scope.search.qtdShow) { 60 let newItems = []; 61 for (let i = 0; i < $scope.invoices.length; i++) { 62 if (i >= $scope.search.qtdShow) { 63 break; 64 } 65 newItems.push($scope.invoices[i]); 66 } 67 68 $scope.invoices = newItems; 69 util.loading(false); 70 return; 71 } else { 72 params.limit = $scope.search.qtdShow - $scope.invoices.length; 73 } 74 75 if ($scope.search.qtdShow !== $scope.invoices.length) update = true; 76 77 dataService.getInvoices(params, update).then((result) => { 78 79 $scope.invoices = $scope.invoices.concat(result); 80 util.loading(false); 81 82 }).catch(function (err) { 83 $scope.invoices.length = 0; 84 util.loading(false); 85 util.throwError(209, true, false, err); 86 }); 87 }, 100); 88 89 }; 90 $scope.qtyChange = () => { 91 $timeout(() => { 92 $scope.loadInvoices(); 93 }, 100); 94 }; 95 $scope.update = () => { 96 $scope.loadInvoices(true); 97 }; 98 $scope.goCart = function () { 99 util.goToPage('cart'); 100 }; 101 // --------------------------------------------------------------- 102 103 // OnReady ------------------------------------------------------- 104 $scope.loadInvoices(); 105 // --------------------------------------------------------------- 106 107 108}]); 109 110angular.module('webSoDanca').controller('mySoDancaInvoiceDetailController', ['$scope', 'util', 'dataService', '$stateParams', function ($scope, util, dataService, $stateParams) { 111 112 // Variables ----------------------------------------------------- 113 $scope.searchOptions = [ 114 { name: 'Name', field: 'product_name', type: 1 }, 115 { name: 'Price', field: 'price', type: 3 }, 116 { name: 'Qtd', field: 'quantity', type: 3 }, 117 { name: 'State', field: 'state', type: 4 } 118 ]; 119 $scope.tableHeaders = [ 120 { name: 'Name', field: 'product_name' }, 121 { name: 'Price', field: 'price', filters: [{ name: 'number', param: 2 }], "class": 'align_r', icon: 'fa fa-usd', totalFooter: true }, 122 { name: 'Qtd', field: 'quantity', filters: [{ name: 'number', param: 2 }], "class": 'align_r', totalFooter: true }, 123 { name: 'State', field: 'state', filters: [{ name: 'msCapitalize' }] } 124 ]; 125 // --------------------------------------------------------------- 126 127 // Functions ----------------------------------------------------- 128 $scope.back = function () { 129 util.goToPage("invoices"); 130 }; 131 $scope.getInvoice = function () { 132 133 util.loading(true); 134 135 var params = { 136 offset: 0, 137 limit: 0, 138 partner: util.getUserClient().user_id 139 }; 140 141 dataService.getInvoices(params).then(function (result) { 142 143 $scope.invoice = {}; 144 for (let p = 0; p < result.length; p++) { 145 if (result[p].number == $stateParams.id) { 146 $scope.invoice = result[p]; 147 break; 148 } 149 } 150 util.loading(false); 151 152 }).catch(function (result) { 153 $scope.orders.length = 0; 154 util.loading(false); 155 }); 156 157 }; 158 $scope.downloadPdf = function () { 159 util.downloadPdf($scope.invoice.id, 'invoice'); 160 }; 161 // --------------------------------------------------------------- 162 163 // OnReady ------------------------------------------------------- 164 $scope.getInvoice(); 165 // --------------------------------------------------------------- 166 167 168}]); 169 170//===========================================================================================================
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.