1pipelbizControllers.controller("InvestmentsCtrl", [ 2 "userService", 3 "$scope", 4 "$stateParams", 5 "$filter", 6 "$timeout", 7 "uploadService", 8 "$state", 9 function InvestmentsCtrl(userService, $scope, $stateParams, $filter, $timeout, uploadService, $state) { 10 $scope.shownCampaign = {}; 11 $scope.isLastYear = false; 12 $scope.allNotifications = undefined; 13 $scope.sixNotifications = undefined; 14 $scope.cmpUrl = ""; 15 $scope.totalPercent = ""; 16 $scope.totalMoneyMade = ""; 17 $scope.campaignsTotalRaisedAmount = ""; 18 $scope.allConventions = undefined; 19 $scope.threeConventionsFuture = undefined; 20 $scope.threeConventionsDone = undefined; 21 $scope.viewAllNotifications = false; 22 $scope.viewAllConventions = false; 23 $scope.myCharges = []; 24 $scope.myInvestments = []; 25 $scope.myStocks = undefined; 26 $scope.myBonds = undefined; 27 $scope.issuedCompanies = [517, 52919, 52703, 52724, 52748, 52794, 52778, 52730, 52764, 52867, 52774, 52685, 52715, 52867, 52764, 52730, 52778, 52872]; 28 $scope.issuedC = ""; 29 $scope.updateInView = {}; 30 $scope.chargesCountPublic = undefined; 31 $scope.chargesCountAngel = undefined; 32 $scope.chargesCountPublicYear = undefined; 33 $scope.chargesCountAngelYear = undefined; 34 $scope.downloadLink = async function (link) { 35 const res = await uploadService.downloadDocument(link) 36 } 37 $scope.viewFile = (file) => { 38 uploadService.downloadDocument(file) 39 } 40 $scope.loadInvestment = async function (cmp_id, skipReload) { 41 const cmp = await $scope.getCampaignById(cmp_id); 42 if (!skipReload) { 43 await $scope.getAllInvestments(); 44 } 45 46 $scope.getGraphValuesByCampaignID(cmp_id, false); 47 48 const inv = $scope.myInvestments.find((inv) => inv?.cmp_id === cmp_id); 49 50 const campaign = {...(inv || {}), ...cmp}; 51 // console.log(campaign); 52 53 $scope.appDetails.title = pipelbiz.helpers.SpecialCharacters(campaign.cmp_name); 54 $scope.appDetails.description = pipelbiz.helpers.SpecialCharacters(campaign.cmp_summary); 55 if (campaign.cmp_company_logo_bigcover_section_files.length > 0) { 56 $scope.appDetails.image = campaign.cmp_company_logo_bigcover_section_files[0].ast_path; 57 } else { 58 $scope.appDetails.image = "https://pipelbiz.com/images/f6aa.png"; 59 } 60 61 campaign.cmp_total_investment = Number(campaign.cmp_total_investment) + Number(campaign.cmp_initial_amount); 62 campaign.cmp_investors_count = Number(campaign.cmp_initial_investors) + Number(campaign.cmp_investors_count); 63 64 document.body.style.setProperty("--main-color", "#" + campaign.cmp_color); 65 // $scope.changeColor(campaign.cmp_color); 66 campaign.cmp_investment_goal = parseFloat(campaign.cmp_investment_goal); 67 if (campaign.cmp_group_name) { 68 let cmp_slug = campaign.cmp_slug || campaign.cmp_id; 69 let newCanonical = $("link[rel=canonical]").attr("href").replace(cmp_slug, campaign.cmp_group_name); 70 $("link[rel=canonical]").attr("href", newCanonical); 71 } 72 73 campaign.cmp_name = pipelbiz.helpers.SpecialCharacters(campaign.cmp_name); 74 campaign.cmp_slogan = pipelbiz.helpers.SpecialCharacters(campaign.cmp_slogan); 75 76 campaign.usr_fname = pipelbiz.helpers.SpecialCharacters(campaign.usr_fname); 77 campaign.usr_lname = pipelbiz.helpers.SpecialCharacters(campaign.usr_lname); 78 campaign.cmp_summary = pipelbiz.helpers.SpecialCharacters(campaign.cmp_summary); 79 campaign.cmp_business_idea = pipelbiz.helpers.SpecialCharacters(campaign.cmp_business_idea); 80 campaign.cmp_nadlan_insurances = pipelbiz.helpers.SpecialCharacters(campaign.cmp_nadlan_insurances); 81 campaign.cmp_competition = pipelbiz.helpers.SpecialCharacters(campaign.cmp_competition); 82 campaign.cmp_funds_usage = pipelbiz.helpers.SpecialCharacters(campaign.cmp_funds_usage); 83 campaign.cmp_company_articles = pipelbiz.helpers.SpecialCharacters(campaign.cmp_company_articles); 84 campaign.cmp_company_clients = pipelbiz.helpers.SpecialCharacters(campaign.cmp_company_clients); 85 campaign.cmp_company_vision = pipelbiz.helpers.SpecialCharacters(campaign.cmp_company_vision); 86 campaign.cmp_company_activity = pipelbiz.helpers.SpecialCharacters(campaign.cmp_company_activity); 87 campaign.daysLeft = pipelbiz.helpers.getDaysLeft(campaign.cmp_manager_end_date); 88 $scope.getTotalCampaignsRaisedAmount(campaign.cmp_group_name); 89 campaign.cmp_days_left_for_publish = pipelbiz.helpers.getDaysLeft(campaign.cmp_manager_published_date, campaign.cmp_id); 90 // const campaignCalc = $scope.newCalc(campaign); 91 const campaignCalc = $scope.mapInvestment(campaign); 92 93 $scope.appDetails.currentCampaign = campaignCalc; 94 95 console.log("campaignCalc", campaignCalc); 96 console.log("campaign", campaign); 97 98 if (!skipReload) { 99 await $scope.getAllUpdates(); 100 } 101 campaignCalc.notifications = $scope.allNotifications?.filter((noti) => noti?.cmp_id === cmp_id); 102 campaignCalc.conventions = $scope.allConventions?.filter((noti) => noti?.cmp_id === cmp_id); 103 104 $scope.shownCampaign = campaignCalc; 105 106 if ($scope.shownCampaign.approvedInvestments == 0 && $scope.userDetails.usr_type == 1) { 107 if ($scope.shownCampaign.usr_id != $scope.userDetails.usr_id) { 108 $state.go("/"); 109 } 110 } 111 // $scope.$apply(); 112 $timeout(() => { 113 $scope.$apply(); 114 }, 1000); 115 }; 116 117 $scope.showAllNotifications = function () { 118 $scope.viewAllNotifications = true; 119 }; 120 $scope.showAllConventions = function () { 121 $scope.viewAllConventions = true; 122 }; 123 124 $scope.countCharges = function (charges) { 125 let totalSum = 0; 126 let stocksSum = 0; 127 let bondsSum = 0; 128 if (Array.isArray(charges)) { 129 const stocks = charges.filter((charge) => charge.cmp_nadlan != 1); 130 const bonds = charges.filter((charge) =>
130 charge.cmp_nadlan == 1); 131 for (const stock of stocks) { 132 stocksSum += parseFloat((stock.inv_actual_investment_amount || stock.inv_investment_amount) ?? 0); 133 } 134 for (const bond of bonds) { 135 bondsSum += parseFloat((bond.inv_actual_investment_amount || bond.inv_investment_amount) ?? 0); 136 } 137 totalSum = parseFloat(stocksSum + bondsSum); 138 } 139 return {totalSum, stocksSum, bondsSum}; 140 }; 141 $scope.mapOverallValues = function (investment, graph) { 142 console.log(graph); 143 console.log(investment); 144 145 } 146 $scope.mapInvestment = function (investment) { 147 investment.status = ""; 148 if (window.location.href.indexOf("localhost") > -1) { 149 $scope.cmpUrl = `${window.location.origin}/pipelbiz`; 150 } else { 151 $scope.cmpUrl = window.location.origin; 152 } 153 154 if (investment.cmp_slug && investment.cmp_cat_type == "0") { 155 $scope.cmpUrl += "/×שקע×ת/ס××ר××פ/" + investment.cmp_slug; 156 } else if (investment.cmp_slug && investment.cmp_cat_type == "2") { 157 $scope.cmpUrl += "/×שקע×ת/× ×××/" + investment.cmp_slug; 158 } else { 159 $scope.cmpUrl += "/Campaign/" + investment.cmp_id; 160 } 161 const invNew = $scope.newCalc(investment); 162 // invNew.graph = $scope.getGraphValuesByCampaignID(investment.cmp_id,true); 163 164 invNew.cmp_company_logo = (invNew.cmp_company_logo_section_files && invNew.cmp_company_logo_section_files[0] && invNew.cmp_company_logo_section_files[0].ast_path) || ""; 165 166 if ($scope.lang == "he") { 167 invNew.endDate = getHebrewDate(invNew.cmp_manager_end_date); 168 invNew.startDate = getHebrewDate(invNew.cmp_manager_published_date); 169 } else { 170 invNew.endDate = getEngDate(invNew.cmp_manager_end_date); 171 invNew.startDate = getEngDate(invNew.cmp_manager_published_date); 172 } 173 174 if ($scope.lang == "he") { 175 invNew.campaignType = invNew.cmp_old_model == 1 ? "×× ×'×" : "צ×××ר×"; 176 } else { 177 invNew.campaignType = invNew.cmp_old_model == 1 ? "Angel" : "Public"; 178 } 179 180 invNew.totalInvestments = 0; 181 invNew.approvedInvestments = 0; 182 invNew.totalShares = 0; 183 invNew.campaignStatus = ""; 184 invNew.certificate = ""; 185 invNew.taxReport = ""; 186 invNew.invReport = ""; 187 invNew.receipt = ""; 188 189 if (invNew.inv_money_transferred == 1 && $scope.getDaysLeft(invNew.cmp_manager_end_date) <= 0 && invNew.inv_canceld == 0) { 190 invNew.status = "Successfull transaction card finish"; 191 } else if (invNew.inv_money_transferred == 1 && invNew.inv_canceld == 0) { 192 invNew.status = "Successfull transaction card"; 193 } else if (invNew.inv_money_transferred == 0 && invNew.inv_status == 1 && invNew.inv_by == 1 && invNew.inv_canceld == 0) { 194 invNew.status = "Pending for bank transaction card"; 195 } 196 197 if (invNew.investements) { 198 for (let i = 0; i < invNew.investements.length; i++) { 199 // $scope.currentCamp = $scope.newMyInvestments[i] 200 invNew.campaignStatus = invNew.investements[i].status; 201 if ($scope.lang == "he") { 202 switch (invNew.campaignStatus) { 203 case "running": 204 invNew.campaignStatus = "×××× ×××ס"; 205 break; 206 case "ended successfully": 207 invNew.campaignStatus = "×××ס ××צ×××"; 208 break; 209 } 210 } else { 211 switch (invNew.campaignStatus) { 212 case "running": 213 invNew.campaignStatus = "Running"; 214 break; 215 case "ended successfully": 216 invNew.campaignStatus = "Successfully funded"; 217 break; 218 } 219 } 220 221 invNew.investements[i].inv_investment_amount = parseFloat(invNew.investements[i].inv_investment_amount); 222 if (invNew.investements[i].inv_money_transferred == 1 && invNew.investements[i].inv_canceld == 0) { 223 if (invNew.investements[i].inv_actual_investment_amount != "") { 224 invNew.approvedInvestments += Number(invNew.investements[i].inv_actual_investment_amount); 225 invNew.totalShares += Number(invNew.investements[i].inv_actual_stocks_amount); 226 } else { 227 invNew.approvedInvestments += Number(invNew.investements[i].inv_investment_amount); 228 invNew.totalShares += invNew.investements[i].inv_stocks_amount; 229 } 230 } 231 if (invNew.investements[i].inv_certificate != "") { 232 invNew.certificate = invNew.investements[i].inv_certificate; 233 } 234 if (invNew.investements[i].inv_receipt_link != "") { 235 invNew.receipt = invNew.investements[i].inv_receipt_link; 236 } 237 238 if (invNew.investements[i].inv_tax_deductions_file != "") { 239 invNew.taxReport = invNew.investements[i].inv_tax_deductions_file; 240 } 241 if (invNew.investements[i].inv_investment_report != "") { 242 invNew.invReport = invNew.investements[i].inv_investment_report; 243 } 244 invNew.totalInvestments += invNew.investements[i].inv_investment_amount; 245 if ($scope.lang == "he") { 246 invNew.investements[i].invCreated = getHebrewDate(invNew.investements[i].inv_created); 247 } else { 248 invNew.investements[i].invCreated = getEngDate(invNew.investements[i].inv_created); 249 } 250 } 251 } 252 253 return invNew; 254 }; 255 256 $scope.toggleMobileSummary = function () { 257 $(".summary-mobile-content").slideToggle(); 258 }; 259 260 $scope.toggleMobileAbout = function () { 261 $(".about-mobile-content").slideToggle(); 262 }; 263 264 $scope.getAllUpdates = async function (lastArr) { 265 const arr = lastArr ? [...lastArr] : await $scope.updatesGetMyNotifications(); 266 267 if (Array.isArray(arr)) {
268 $scope.dashboardDetails.updates = arr; 269 270 const allNotifications = arr.filter((noti) => !(noti.notification_type == "convention_invite" || noti.notification_type == "convention_protocol")); 271 const allConventions = arr.filter((noti) => noti.notification_type == "convention_invite" || noti.notification_type == "convention_protocol"); 272 273 $scope.allNotifications = allNotifications; 274 $scope.allConventions = allConventions; 275 276 $scope.sixNotifications = allNotifications.slice(0, 6); 277 278 const allConventionsFuture = allConventions.filter((conv) => conv.is_future); 279 const allConventionsDone = allConventions.filter((conv) => conv.is_done); 280 // $scope.allConventions = allConventions; 281 $scope.threeConventionsFuture = allConventionsFuture.slice(0, 3); 282 $scope.threeConventionsDone = allConventionsDone.slice(0, 3); 283 284 // $scope.$apply(); 285 $timeout(() => { 286 $scope.$apply(); 287 }, 1000); 288 } 289 }; 290 291 $scope.showUpdateModal = function (updateData) { 292 $scope.updateInView = updateData; 293 $("#company-update-modal").modal("show"); 294 }; 295 $scope.getGraphValuesByMultiple = async function (ids) { 296 297 return $.ajax({ 298 url: api_url + "graphValue.php", 299 data: {oper: "getGraphValuesByMultiple", ids: ids}, 300 type: "post", 301 // success: function (output) { 302 // if (output.alert_type == "alert-success") { 303 // $scope.testingTemp = output.data; 304 // } 305 // }, 306 }); 307 }; 308 $scope.getCurrentTotal = function (investment) { 309 310 if ((Number(investment.gv_y_value).toFixed(2) - Number(investment.cmp_calc_share_price).toFixed(2)) > 0) { 311 y = (investment.gv_y_value - investment.cmp_calc_share_price) * investment.totalShares; 312 return y; 313 } else { 314 return 0; 315 } 316 } 317 318 $scope.sumCertainInvests = function (investment) { 319 return investment.approvedInvestments; 320 // if ( (Number(investment.gv_y_value).toFixed(2) - Number(investment.cmp_calc_share_price).toFixed(2)) > 0 ){ 321 // return investment.approvedInvestments; 322 // } else { 323 // return 0; 324 // } 325 } 326 $scope.isNumber = function (value) { 327 return Number.isNaN(value); 328 } 329 $scope.getPercent = function (investment) { 330 331 g = (investment.gv_y_value / investment.cmp_calc_share_price); 332 d = g - 1 333 y = d * 100; 334 if (Number.isNaN(y)) { 335 return; 336 } else { 337 return y; 338 } 339 } 340 341 $scope.getTotalCampaignsRaisedAmount = function (groupName) { 342 $.ajax({ 343 url: api_url + "investment.php", 344 data: {oper: "getTotalCampaignsRaisedAmount", groupName: groupName}, 345 type: "post", 346 success: function (output) { 347 if (output.alert_type == "alert-success") { 348 let totalAmount = 0; 349 for (let i = 0; i < output.data.length; i++) { 350 if (output.data[i].proRataTotal == 0) { 351 totalAmount += Number(output.data[i].total); 352 } else { 353 totalAmount += Number(output.data[i].proRataTotal); 354 } 355 } 356 $scope.campaignsTotalRaisedAmount = totalAmount; 357 } 358 }, 359 }); 360 } 361 $scope.getAllInvestments = async function (lastArr) { 362 const arr = lastArr ? [...lastArr] : await $scope.getInvestments(); 363 364 // if ($scope.userDetails.usr_created < "2018-03-01 00:00:00") { 365 // await $scope.getOldInvestments(); 366 // } 367 368 if (Array.isArray(arr)) {
369 $scope.dashboardDetails.investments = arr; 370 $scope.myInvestments = arr; 371 $scope.myStocks = arr.filter((investment) => investment.cmp_nadlan != 1).map((investment) => $scope.mapInvestment(investment)); 372 $scope.myBonds = arr.filter((investment) => investment.cmp_nadlan == 1).map((investment) => $scope.mapInvestment(investment)); 373 $scope.filterdStocks = $scope.myStocks.filter((investment) => investment.approvedInvestments > 0); 374 console.log($scope.filterdStocks, "Stocks"); 375 $scope.filterdBonds = $scope.myBonds.filter((investment) => investment.approvedInvestments > 0); 376 $scope.investedCmpsIds = $scope.myStocks.filter((investment) => investment.approvedInvestments > 0).map((investment) => investment.cmp_id); 377 const multipleGraphValues = await $scope.getGraphValuesByMultiple($scope.investedCmpsIds); 378 mergedData = $scope.filterdStocks.map(data => ({ 379 ...data, 380 ...multipleGraphValues.data.find(newData => newData.gv_cmp_id == data.cmp_id) 381 })) 382 $scope.filterdStocks = $scope.filterdStocks.map(data => ({ 383 ...data, 384 ...multipleGraphValues.data.find(newData => newData.gv_cmp_id == data.cmp_id) 385 })) 386 $scope.companiesProfitAmountArray = mergedData.filter((investment) => (investment.campaignStatus == '×××ס ××צ×××' || investment.campaignStatus == 'Successfully funded') && Number(investment.gv_y_value).toFixed(2) != Number(investment.cmp_calc_share_price).toFixed(2) && investment.cmp_safe_agreement == 0 && !$scope.issuedCompanies.includes(Number(investment.cmp_id)) && typeof investment.gv_y_value != 'undefined').map((investment) => $scope.getCurrentTotal(investment)); 387 $scope.companiesProfitPercentArray = mergedData.filter((investment) => (investment.campaignStatus == '×××ס ××צ×××' || investment.campaignStatus == 'Successfully funded') && Number(investment.gv_y_value).toFixed(2) != Number(investment.cmp_calc_share_price).toFixed(2) && investment.cmp_safe_agreement == 0 && !$scope.issuedCompanies.includes(Number(investment.cmp_id)) && typeof investment.gv_y_value != 'undefined').map((investment) => $scope.getPercent(investment)); 388 $scope.totalInvestedForProfitCalc = mergedData.filter((investment) => (investment.campaignStatus == '×××ס ××צ×××' || investment.campaignStatus == 'Successfully funded') && investment.cmp_safe_agreement == 0 && !$scope.issuedCompanies.includes(Number(investment.cmp_id)) && typeof investment.gv_y_value != 'undefined').map((investment) => $scope.sumCertainInvests(investment)); 389 $scope.totalMoneyMade = $scope.companiesProfitAmountArray.reduce((a, b) => a + b, 0); 390 $scope.totalPercent = $scope.totalMoneyMade / $scope.totalInvestedForProfitCalc.reduce((a, b) => a + b, 0) * 100; 391 $scope.totalPercent = $scope.totalPercent >= 0 ? $scope.totalPercent : 0; 392 // $scope.totalPercent = $scope.companiesProfitPercentArray.reduce((a, b) => a + b, 0) / $scope.companiesProfitPercentArray.length; 393 // $scope.$apply(); 394 $timeout(() => { 395 $scope.$apply(); 396 }, 1000); 397 } 398 }; 399 400 $scope.getAllCharges = async function (lastArr) { 401 const arr = lastArr ? [...lastArr] : await $scope.getCharges(); 402 403 // if ($scope.userDetails.usr_created < "2018-03-01 00:00:00") { 404 // await $scope.getOldCharges(); 405 // } 406 407 console.log(arr); 408 if (Array.isArray(arr)) { 409 $scope.dashboardDetails.charges = arr; 410 $scope.myCharges = arr; 411 // $scope.myChargesLastYear = arr.filter(charge => charge.inv_money_transferred_updated && moment().diff(moment(charge.inv_money_transferred_updated), 'year') < 1); 412 // console.log($scope.myCharges) 413 // console.log($scope.myChargesLastYear) 414 415 const allPaidCharges = arr.filter((charge) => charge.inv_canceld != 1 && charge.inv_money_transferred == 1); 416 const chargesPublic = allPaidCharges.filter((charge) => charge.cmp_old_model != 1); 417 const chargesAngel = allPaidCharges.filter((charge) => charge.cmp_old_model == 1); 418 $scope.chargesCountPublic = $scope.countCharges(chargesPublic); 419 $scope.chargesCountAngel = $scope.countCharges(chargesAngel); 420 421 const chargesPublicYear = chargesPublic.filter((charge) => charge.inv_money_transferred_updated && moment().diff(moment(charge.inv_money_transferred_updated), "
421year") < 1); 422 const chargesAngelYear = chargesAngel.filter((charge) => charge.inv_money_transferred_updated && moment().diff(moment(charge.inv_money_transferred_updated), "year") < 1); 423 $scope.chargesCountPublicYear = $scope.countCharges(chargesPublicYear); 424 $scope.chargesCountAngelYear = $scope.countCharges(chargesAngelYear); 425 426 // $scope.$apply(); 427 $timeout(() => { 428 $scope.$apply(); 429 }, 1000); 430 } 431 }; 432 433 console.log("$scope.dashboardDetails.investments", $scope.dashboardDetails.investments); 434 435 if ($scope.dashboardDetails.investments && $scope.dashboardDetails.investments.length) { 436 $scope.getAllInvestments($scope.dashboardDetails.investments); 437 } 438 439 console.log("$scope.dashboardDetails.updates", $scope.dashboardDetails.updates); 440 441 if ($scope.dashboardDetails.updates && $scope.dashboardDetails.updates.length) { 442 $scope.getAllUpdates($scope.dashboardDetails.updates); 443 } 444 445 console.log("$scope.dashboardDetails.charges", $scope.dashboardDetails.charges); 446 447 if ($scope.dashboardDetails.charges && $scope.dashboardDetails.charges.length) { 448 $scope.getAllCharges($scope.dashboardDetails.charges); 449 } 450 451 if ($stateParams.cmpId) { 452 $scope.campaignId = $stateParams.cmpId; 453 console.log("campaignId", $scope.campaignId); 454 $scope.issuedC = $scope.issuedCompanies.includes(Number($scope.campaignId)); 455 const load = async function () { 456 await $scope.loadInvestment($scope.campaignId, true); 457 await $scope.loadInvestment($scope.campaignId); 458 // $scope.getGraphValuesByCampaignID($scope.campaignId) 459 }; 460 load(); 461 } else { 462 $scope.getAllInvestments(); 463 $scope.getAllUpdates(); 464 $scope.getAllCharges(); 465 } 466 }, 467]);
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.