mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 13:47:32 -04:00 
			
		
		
		
	Attempt to refresh account list from auth page
This commit is contained in:
		
							parent
							
								
									3542e35da0
								
							
						
					
					
						commit
						d6039cec3a
					
				| @ -31,6 +31,7 @@ class YodleeController extends BaseController | ||||
| 
 | ||||
|         $company = $request->getCompany(); | ||||
| 
 | ||||
| 
 | ||||
|         if($company->account->bank_integration_account_id){ | ||||
| 
 | ||||
|             $flow = 'edit'; | ||||
| @ -54,6 +55,9 @@ class YodleeController extends BaseController | ||||
|          | ||||
|         $yodlee = new Yodlee($token); | ||||
| 
 | ||||
|         if($request->has('window_closed') && $request->input("window_closed") == "true") | ||||
|             $this->getAccounts($company, $token); | ||||
| 
 | ||||
|         $data = [ | ||||
|             'access_token' => $yodlee->getAccessToken(), | ||||
|             'fasttrack_url' => $yodlee->getFastTrackUrl(), | ||||
| @ -61,10 +65,43 @@ class YodleeController extends BaseController | ||||
|             'flow' => $flow, | ||||
|             'company' => $company, | ||||
|             'account' => $company->account, | ||||
|             'completed' => $request->has('window_closed') ? true : false, | ||||
|         ]; | ||||
| 
 | ||||
|         return view('bank.yodlee.auth', $data); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     private function getAccounts($company, $token) | ||||
|     { | ||||
|         $yodlee = new Yodlee($token); | ||||
| 
 | ||||
|         $accounts = $yodlee->getAccounts();  | ||||
| 
 | ||||
|         foreach($accounts as $account) | ||||
|         { | ||||
| 
 | ||||
|             if(!BankIntegration::where('bank_account_id', $account['id'])->where('company_id', $company->id)->exists()) | ||||
|             { | ||||
|                 $bank_integration = new BankIntegration(); | ||||
|                 $bank_integration->company_id = $company->id; | ||||
|                 $bank_integration->account_id = $company->account_id; | ||||
|                 $bank_integration->user_id = $company->owner()->id; | ||||
|                 $bank_integration->bank_account_id = $account['id']; | ||||
|                 $bank_integration->bank_account_type = $account['account_type']; | ||||
|                 $bank_integration->bank_account_name = $account['account_name']; | ||||
|                 $bank_integration->bank_account_status = $account['account_status']; | ||||
|                 $bank_integration->bank_account_number = $account['account_number']; | ||||
|                 $bank_integration->provider_id = $account['provider_id']; | ||||
|                 $bank_integration->provider_name = $account['provider_name']; | ||||
|                 $bank_integration->nickname = $account['nickname']; | ||||
|                 $bank_integration->balance = $account['current_balance']; | ||||
|                 $bank_integration->currency = $account['account_currency']; | ||||
|                  | ||||
|                 $bank_integration->save(); | ||||
|             } | ||||
| 
 | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -55,14 +55,9 @@ | ||||
|         @endif | ||||
|     </div> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     <div id="cta" class="mb-4" x-data="{ open: false }"> | ||||
| 
 | ||||
|       <button @click="open = !open" x-show="!open" type="submit" class="button button-primary bg-blue-600 my-4" id="btn-fastlink">{{ ctrans('texts.add_bank_account') }} | ||||
|       </button> | ||||
|       <button @click="open = !open" x-show="!open" type="submit" class="button button-primary bg-blue-600 my-4" id="btn-fastlink">{{ ctrans('texts.add_bank_account') }}</button> | ||||
| 
 | ||||
|       <div x-show="open" class="fixed top-0 left-0 right-0 bottom-0 w-full h-screen z-50 overflow-hidden bg-gray-700 opacity-75 flex flex-col items-center justify-center"> | ||||
|         <div class="loader ease-linear rounded-full border-4 border-t-4 border-gray-200 h-12 w-12 mb-4"></div> | ||||
| @ -73,7 +68,7 @@ | ||||
|     </div> | ||||
| 
 | ||||
|     <div id="completed" class="mb-4"> | ||||
|       <a class="button button-primary bg-blue-600 my-4" href="https://invoicing.co">Return to admin portal.</a> | ||||
|       <a class="button button-primary bg-blue-600 my-4" href="{{ config('ninja.app_url') }}">Return to admin portal.</a> | ||||
|     </div> | ||||
| 
 | ||||
| </div> | ||||
| @ -89,6 +84,16 @@ | ||||
| 
 | ||||
|   (function (window) { | ||||
|     //Open FastLink
 | ||||
| 
 | ||||
|     @if($completed) | ||||
| 
 | ||||
|       var completed = document.getElementById('completed'); | ||||
|       completed.style.display = "block"; //block
 | ||||
|       var hideme = document.getElementById('cta'); | ||||
|       hideme.style.display = "none"; | ||||
| 
 | ||||
|     @endif | ||||
| 
 | ||||
|     var fastlinkBtn = document.getElementById('btn-fastlink'); | ||||
|     fastlinkBtn.addEventListener( | ||||
|       'click',  | ||||
| @ -118,6 +123,9 @@ | ||||
| 
 | ||||
|                   var completed = document.getElementById('completed'); | ||||
|                   completed.style.display = "block"; //block
 | ||||
| 
 | ||||
|                   window.location.href = window.location.pathname+"?"+$.param({'window_closed':'true'}) | ||||
| 
 | ||||
|             }, | ||||
|             onEvent: function (data) { | ||||
|               // will be called on intermittent status update.
 | ||||
| @ -131,6 +139,7 @@ | ||||
|         }, | ||||
|     false); | ||||
|   }(window)); | ||||
|    | ||||
| </script> | ||||
| 
 | ||||
| @endpush | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user