1app.controller('dashCtrl', function ($scope, 2 $rootScope, 3 $cookies, 4 $http, 5 $uibModal, 6 $window, $location, 7 $log, 8 Data, 9 uiGridConstants, 10 AuthService, 11 orgServices, 12 modalService, 13 tbServices) { 14 // TODO: Clicking on sellers or buyers does not need to resolve the transactions object. 15 // Orders, sellers, buyers need to be in separate controllers. Null is pass for buyers and sellers until fixed 16 17 18 // Paginations 19 $scope.currentOrderPage = 1; 20 $scope.maxItems = 8; 21 22 $scope.$watch('AuthService', function(oldVal, newVal) { 23 24 }); 25 26 27 //#Chris: not sure why it occurs intermittently, promises, asynchronosity, scope level etc. 28 if (!angular.isUndefined(AuthService.User.uid)) { 29 console.log(AuthService.User.uid); 30 31 32 } else { 33 //#Chris: fix because authService doesn't reload from routechange start on a hard refresh 34 35 //alert("AuthService not been populated correctly in dash controller - setting from the cookies"); 36 // AuthService.User.uid = $cookies.get('uid'); 37 // AuthService.User.jobfunction = $cookies.get('jb'); 38 // AuthService.User.role = $cookies.get('role'); 39 if (AuthService.User.role === "seller") AuthService.User.role = "trader"; 40 41 // $scope.uid = $cookies.get('uid'); // if needed 42 43 } 44 45 // wait for session retrieval 46 AuthService.getSession().then(function () { 47 48 // #Cedric: this is probably wrong since currentUser is injected in $rootScope by AuthService 49 $scope.setCurrentUser(AuthService.User); 50 51 $scope.dataUser = {}; 52 53 54 // Change the view 55 $scope.changeAutoIntros = function () { 56 57 if ($scope.dataUser.intros_on_off == '1') { 58 59 } else { 60 61 62 } 63 64 }; 65 66 67 $scope.editPlan = function (userPlan, billing) { 68 69 var modalInstance = $uibModal.open({ 70 animation: $scope.animationsEnabled, 71 templateUrl: 'partials/edit_plan.html', 72 controller: 'editUserPlan', 73 animate: true, 74 size: 'md', 75 resolve: { 76 userPlan: function () { 77 return userPlan; 78 }, 79 billing: function () { 80 return billing; 81 } 82 } 83 }); 84 85 modalInstance.result.then(function () { 86 87 }, function () { 88 $log.info('Edit plan dismissed: ' + new Date()); 89 }); 90 91 }; 92 93 // var orgid = $cookies.get('orgid'); // wp fix when using AuthService.User.orgid this is intermittent so cookies used?? 94 const orgid = 0; // orgid is no longer used by the server 95 orgServices.getOrganisationsForId(orgid).then(function (torgs) { 96 $scope.orgGridOptions.data = torgs; 97 // get country name from legacy country list 98 torgs.forEach(function (org) { 99 100 // country name to be added 101 // org.country = tbServices.service('country').getByAlpha2(org.operationcountry); 102 // org.countryname = org.country.name; 103 104 // format the role description better 105 // if (org.roles == "['supplier']") org.rolename = "Supplier"; 106 // else if (org.roles == "['customer']") org.rolename = "Customer"; 107 // else { 108 // } 109 110 try { 111 org.rolename = org.extra_data.roles.map((role) => { 112 return role.title; 113 }).join(", "); 114 } catch (e) { 115 console.log(e); 116 } 117 118 }); 119 120 }); 121 122 123 $scope.toggleFiltering = function () { 124 $scope.orgGridOptions.enableFiltering = !$scope.orgGridOptions.enableFiltering; 125 $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN); 126 }; 127 128 $scope.deleteTorg = function (row) { 129 130 var org = row.entity; 131 var index = $scope.orgGridOptions.data.indexOf(org); 132 133 // one modal message at start 134 var modalOptions = { 135 closeButtonText: 'Cancel', 136 actionButtonText: 'OK', 137 headerText: 'Delete this trading partner?', 138 bodyText: 'Are you sure you want delete this trading partner from your list?' 139 }; 140 141 modalService.showModal({}, modalOptions).then(function (result) { 142 if (result === 'ok') { 143 144 var postdata = {"orgid": org.orgid, updated_by: AuthService.User.uid}; 145 146 // #156 to be replaced with organisation service method 147 $http({ 148 method: 'PUT', 149 url: 'api/v1/torganisation/delete', 150 data: postdata, 151 headers: {'Content-Type': 'application/json'}, 152 }).then( 153 function successCallback(response) { 154 155 $scope.orgGridOptions.data.splice(index, 1); 156 157 var msgobj = {status: "success", message: "Trading party has been deleted"}; 158 Data.toast(msgobj); 159 160 }, 161 function errorCallback(response) { 162 163 console.error("error deleting trading organisation" + response); 164 } 165 ); 166 } 167 }); 168 169 } 170 171 172 $scope.orgGridOptions = { 173 enableSorting: true, 174 enableFiltering: true, 175 enableGridMenu: true, 176 minRowsToShow: 15, 177 showTreeExpandNoChildren: false, 178 columnDefs: [ 179 { 180 field: 'orgid', 181 name: 'edit', 182 width: '5%', 183 headerCellTemplate: '<p></p>', 184 enableHiding: false, 185 cellTemplate: 'edit_torg_button.html', 186 pinnedLeft: true, 187 headerCellClass: 'button-head', 188 enableFiltering: false, 189 enableSorting: false, 190 enableColumnMenu: false 191 }, 192 // { field: 'orgid', name: '#', width: '5%', sort: { direction: uiGridConstants.DESC, priority: 1 } }, 193 {field: 'rolename', name: 'Type', width: '10%'}, 194 {field: 'organisation', name: 'Name', width: '30%', sort: {direction: uiGridConstants.ASC, priority: 1}}, 195 {field: 'extra_data.addresses.registered[0].country.name', name: 'Country', width: '20%'}, 196 {field: 'extra_data.contacts[0].name', name: 'Primary contact', width: '21%'}, 197 {field: 'fldUpdated', name: 'Last updated', width: '11%'}, 198 { 199 field: 'orgid', 200 name: 'delete', 201 width: '5%', 202 headerCellTemplate: '<p></p>', 203 enableHiding: false, 204 cellTemplate: 'delete_torg.html', 205 pinnedRight: true, 206 headerCellClass: 'button-head', 207 pinnedRight: true, 208 enableFiltering: false, 209 enableSorting: false, 210 enableColumnMenu: false 211 } 212 ], 213 onRegisterApi: function (gridApi) { 214 $scope.gridApi = gridApi; 215 216 } 217 }; 218 219 220 // -------- New buyer modal from buyers page ----- // TODO: Service for new/edit buyers 221 var url = $scope.applocation; 222 223 $scope.newtorg = function () { 224 225 orgServices.editTorgModal().then(function (result) { 226 227 228 }); 229 230 } 231 232 // -------- Edit organisation ----- // 233 234 $scope.editBuyer = function (buyer_obj) { 235 236 // $window.location.href = "/torg/" + buyer_obj.orgid; 237 $location.path("/torg/" + buyer_obj.orgid); 238 239 }; 240 241 242 $scope.userRole = AuthService.User.role; 243 244 $scope.sendingRequestSearchCompanies = false;
245 $scope.withResultsSearchCompanies = false; 246 247 $scope.companiesInfo = []; 248 249 $scope.showCarriers = function (org_data) { 250 $uibModal.open({ 251 animation: $scope.animationsEnabled, 252 templateUrl: 'partials/carrier_detail.html', 253 controller: 'companyCarriers', 254 size: 'lg', 255 resolve: { 256 org_data: function () { 257 return org_data; 258 } 259 } 260 }); 261 } 262 263 264 //-------------------------For Seller page-------------------------------------------- 265 266 // this has become the account page 267 /* 268 * For this we must know what type of role the user is 269 * e.g. business adviser or agent 270 * 271 * 272 * 273 * 274 */ 275 276 // $scope.seller = { 277 // type: 'trader', 278 // orgid: "", 279 // uid: $cookies.get("uid"), 280 // corporateform: "", 281 // employeeSize: "", 282 // industry: "", 283 // contactName: "", 284 // email: "", 285 // address: "", 286 // phone: "", 287 // directorprofile: "", 288 // directorname: "", 289 // directoremail: "", 290 // directoraddress: "", 291 // directorphone: "", 292 // directorbirthday: "", 293 // directoryearsliving: 0, 294 // organisation: "", 295 // operationcountry: "185", 296 // operationcountryString: "", 297 // companyRegNum: "", 298 // registeredAddress1: "", 299 // registeredAddress2: "", 300 // registeredCounty: "", 301 // registeredPostcode: "", 302 // tradesameregistered: "", 303 // tradingAddress1: "", 304 // tradingAddress2: "", 305 // tradingCounty: "", 306 // tradingPostcode: "", 307 // accounting: '', 308 // statutorydocs: "", 309 // bankdocs: "", 310 // managementdocs: "", 311 // createdBy: "", 312 // updatedBy: "", 313 // fldCreated: "", 314 // fldUpdated: "" 315 // }; 316 317 318 //-------------------------For Buyer page-------------------------------------------- 319 320 $scope.kyc = function (item) { 321 value = 0; 322 323 if (item.companyRegNum != "") value = value + 10; 324 if (item.contactName != "") value = value + 10; 325 if (item.phone != "") value = value + 5; 326 if (item.email != "") value = value + 5; 327 if (item.registeredAddress1 != "") value = value + 10; 328 if (item.tradingAddress1 != "") value = value + 10; 329 330 if (item.startedSince != "") value = value + 5; 331 332 return value; 333 }; 334 335 $scope.yearsExports = yearsExports; 336 $scope.yearsStarted = yearsStarted; 337 338 $scope.uorgStatutorydocs = ""; 339 $scope.uorgBankdocs = ""; 340 $scope.uorgManagementdocs = ""; 341 $scope.listTradersDocs = ""; 342 }); 343}); 344
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.