mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 12:17:32 -04:00 
			
		
		
		
	Tweaks to BlueVine
This commit is contained in:
		
							parent
							
								
									3680985a20
								
							
						
					
					
						commit
						e1a84a29e1
					
				| @ -35,14 +35,17 @@ class DashboardController extends BaseController | ||||
|         $metrics = $dashboardRepo->totals($accountId, $userId, $viewAll); | ||||
|         $paidToDate = $dashboardRepo->paidToDate($account, $userId, $viewAll); | ||||
|         $averageInvoice = $dashboardRepo->averages($account, $userId, $viewAll); | ||||
|         $balances = $dashboardRepo->balances($accountId, $userId, $viewAll);         | ||||
|         $balances = $dashboardRepo->balances($accountId, $userId, $viewAll); | ||||
|         $activities = $dashboardRepo->activities($accountId, $userId, $viewAll); | ||||
|         $pastDue = $dashboardRepo->pastDue($accountId, $userId, $viewAll); | ||||
|         $upcoming = $dashboardRepo->upcoming($accountId, $userId, $viewAll); | ||||
|         $payments = $dashboardRepo->payments($accountId, $userId, $viewAll); | ||||
|         $expenses = $dashboardRepo->expenses($accountId, $userId, $viewAll); | ||||
|         $tasks = $dashboardRepo->tasks($accountId, $userId, $viewAll); | ||||
| 	    $showBlueVinePromo = !$account->bluevine_status && env('BLUEVINE_PARTNER_UNIQUE_ID'); | ||||
| 
 | ||||
| 	    $showBlueVinePromo = ! $account->bluevine_status | ||||
|             && env('BLUEVINE_PARTNER_UNIQUE_ID') | ||||
|             && $account->created_at <= date( 'Y-m-d', strtotime( '-1 month' )); | ||||
| 
 | ||||
|         // check if the account has quotes
 | ||||
|         $hasQuotes = false; | ||||
| @ -95,10 +98,10 @@ class DashboardController extends BaseController | ||||
| 	        'showBlueVinePromo' => $showBlueVinePromo, | ||||
|         ]; | ||||
| 
 | ||||
| 	    if($showBlueVinePromo){ | ||||
| 	    if ($showBlueVinePromo) { | ||||
| 		    $usdLast12Months = 0; | ||||
| 
 | ||||
| 		    $paidLast12Months = $dashboardRepo->paidLast12Months( $account, $userId, $viewAll ); | ||||
|             $pastYear = date( 'Y-m-d', strtotime( '-1 year' )); | ||||
| 		    $paidLast12Months = $dashboardRepo->paidToDate( $account, $userId, $viewAll, $pastYear ); | ||||
| 
 | ||||
| 		    foreach ( $paidLast12Months as $item ) { | ||||
| 			    if ( $item->currency_id == null ) { | ||||
|  | ||||
| @ -47,7 +47,7 @@ class DashboardRepository | ||||
|                 $count += $item->count; | ||||
|                 $balance += isset($item->balance) ? $item->balance : 0; | ||||
|             }, $records); | ||||
|              | ||||
| 
 | ||||
|             $padding = $groupBy == 'DAYOFYEAR' ? 'day' : ($groupBy == 'WEEK' ? 'week' : 'month'); | ||||
|             $endDate->modify('+1 '.$padding); | ||||
|             $interval = new DateInterval('P1'.substr($groupBy, 0, 1)); | ||||
| @ -181,7 +181,7 @@ class DashboardRepository | ||||
|         return $metrics->groupBy('accounts.id')->first(); | ||||
|     } | ||||
| 
 | ||||
|     public function paidToDate($account, $userId, $viewAll) | ||||
|     public function paidToDate($account, $userId, $viewAll, $startDate = false) | ||||
|     { | ||||
|         $accountId = $account->id; | ||||
|         $select = DB::raw( | ||||
| @ -195,13 +195,16 @@ class DashboardRepository | ||||
|             ->where('payments.account_id', '=', $accountId) | ||||
|             ->where('clients.is_deleted', '=', false) | ||||
|             ->where('invoices.is_deleted', '=', false) | ||||
|             ->where('payments.is_deleted', '=', false) | ||||
|             ->whereNotIn('payments.payment_status_id', [PAYMENT_STATUS_VOIDED, PAYMENT_STATUS_FAILED]); | ||||
| 
 | ||||
|         if (!$viewAll){ | ||||
|             $paidToDate->where('invoices.user_id', '=', $userId); | ||||
|         } | ||||
| 
 | ||||
|         if ($account->financial_year_start) { | ||||
|         if ($startDate) { | ||||
|             $paidToDate->where('payments.payment_date', '>=', $startDate); | ||||
|         } elseif ($account->financial_year_start) { | ||||
|             $yearStart = str_replace('2000', date('Y'), $account->financial_year_start); | ||||
|             $paidToDate->where('payments.payment_date', '>=', $yearStart); | ||||
|         } | ||||
| @ -211,34 +214,6 @@ class DashboardRepository | ||||
|             ->get(); | ||||
|     } | ||||
| 
 | ||||
| 	public function paidLast12Months($account, $userId, $viewAll) | ||||
| 	{ | ||||
| 		$accountId = $account->id; | ||||
| 		$select = DB::raw( | ||||
| 			'SUM('.DB::getQueryGrammar()->wrap('payments.amount', true).' - '.DB::getQueryGrammar()->wrap('payments.refunded', true).') as value,' | ||||
| 			.DB::getQueryGrammar()->wrap('clients.currency_id', true).' as currency_id' | ||||
| 		); | ||||
| 		$paidLast12Months = DB::table('payments') | ||||
| 		                ->select($select) | ||||
| 		                ->leftJoin('invoices', 'invoices.id', '=', 'payments.invoice_id') | ||||
| 		                ->leftJoin('clients', 'clients.id', '=', 'invoices.client_id') | ||||
| 		                ->where('payments.account_id', '=', $accountId) | ||||
| 		                ->where('clients.is_deleted', '=', false) | ||||
| 		                ->where('invoices.is_deleted', '=', false) | ||||
| 						->where('payments.is_deleted', '=', false) | ||||
| 		                ->whereNotIn('payments.payment_status_id', [PAYMENT_STATUS_VOIDED, PAYMENT_STATUS_FAILED]); | ||||
| 
 | ||||
| 		if (!$viewAll){ | ||||
| 			$paidLast12Months->where('invoices.user_id', '=', $userId); | ||||
| 		} | ||||
| 
 | ||||
| 		$paidLast12Months->where( 'payments.payment_date', '>=', date( 'Y-m-d', strtotime( '-1 year' ) ) ); | ||||
| 
 | ||||
| 		return $paidLast12Months->groupBy('payments.account_id') | ||||
| 		                  ->groupBy(DB::raw('CASE WHEN '.DB::getQueryGrammar()->wrap('clients.currency_id', true).' IS NULL THEN '.($account->currency_id ?: DEFAULT_CURRENCY).' ELSE '.DB::getQueryGrammar()->wrap('clients.currency_id', true).' END')) | ||||
| 		                  ->get(); | ||||
| 	} | ||||
| 
 | ||||
|     public function averages($account, $userId, $viewAll) | ||||
|     { | ||||
|         $accountId = $account->id; | ||||
|  | ||||
| @ -2195,8 +2195,7 @@ $LANG = array( | ||||
| 	'bluevine_promo' => 'Get flexible business lines of credit and invoice factoring using BlueVine.', | ||||
| 	'bluevine_modal_label' => 'Sign up with BlueVine', | ||||
| 	'bluevine_modal_text' => '<h3>Fast funding for your business. No paperwork.</h3> | ||||
| <ul><li>Flexible business lines of credit and invoice factoring.</li> | ||||
| <li>Credit lines from $5,000 to $2M. Cash in as fast as 1 day.</li></ul>', | ||||
| <ul><li>Flexible business lines of credit and invoice factoring.</li></ul>', | ||||
| 	'bluevine_create_account' => 'Create an account', | ||||
| 	'quote_types' => 'Get a quote for', | ||||
| 	'invoice_factoring' => 'Invoice factoring', | ||||
| @ -2219,7 +2218,7 @@ $LANG = array( | ||||
| 	'bluevine_weekly_discount_rate'      => 'Weekly Discount Rate', | ||||
| 	'bluevine_minimum_fee_rate'          => 'Minimum Fee', | ||||
| 	'bluevine_line_of_credit'            => 'Line of Credit', | ||||
| 	'bluevine_interest_Rate'             => 'Interest Rate', | ||||
| 	'bluevine_interest_rate'             => 'Interest Rate', | ||||
| 	'bluevine_weekly_draw_rate'          => 'Weekly Draw Rate', | ||||
| 	'bluevine_continue'                  => 'Continue to BlueVine', | ||||
| 	'bluevine_completed'                 => 'BlueVine signup completed', | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| <div class="alert alert-info" id="bluevinePromo"> | ||||
|     {{ trans('texts.bluevine_promo') }} | ||||
|     {{ trans('texts.bluevine_promo') }}    | ||||
|     <a href="#" onclick="showBlueVineModal()" | ||||
|        class="btn btn-primary btn-sm">{{ trans('texts.learn_more') }}</a> | ||||
|     <a href="#" onclick="hideBlueVineMessage()" class="pull-right">{{ trans('texts.hide') }}</a> | ||||
| @ -15,8 +15,9 @@ | ||||
|             </div> | ||||
| 
 | ||||
|             <div class="modal-body"> | ||||
|             <div class="panel-body"> | ||||
|                 {!! Former::open('/bluevine/signup')->id('bluevineSignup') !!} | ||||
|                 {!! trans('texts.bluevine_modal_text') !!} | ||||
|                 {!! trans('texts.bluevine_modal_text') !!}<br/> | ||||
|                 <h3>{!! trans('texts.bluevine_create_account') !!}</h3> | ||||
|                 {!! Former::text('name')->id('bluevine_name')->placeholder(trans('texts.name'))->value($user->first_name . ' ' . $user->last_name)->required() !!} | ||||
|                 {!! Former::text('email')->id('bluevine_email')->placeholder(trans('texts.email'))->value($user->email)->required() !!} | ||||
| @ -50,6 +51,7 @@ | ||||
|                     ->label(trans('texts.desired_credit_limit_loc'))!!} | ||||
|                 {!! Former::close() !!} | ||||
|             </div> | ||||
|             </div> | ||||
| 
 | ||||
|             <div class="modal-footer"> | ||||
|                 <button type="button" class="btn btn-default" | ||||
| @ -216,7 +218,7 @@ | ||||
|                             quoteDetails.append(jQuery('<p>').text("{{trans('texts.bluevine_no_conditional_offer')}}")); | ||||
|                         } | ||||
| 
 | ||||
|                         $('#bluevineModal .modal-body').append( | ||||
|                         $('#bluevineModal .panel-body').append( | ||||
|                                 jQuery('<h3>').text("{{ trans('texts.bluevine_invoice_factoring') }}"), | ||||
|                                 quoteDetails | ||||
|                         ); | ||||
| @ -245,7 +247,7 @@ | ||||
|                             quoteDetails.append(jQuery('<p>').text("{{trans('texts.bluevine_no_conditional_offer')}}")); | ||||
|                         } | ||||
| 
 | ||||
|                         $('#bluevineModal .modal-body').append( | ||||
|                         $('#bluevineModal .panel-body').append( | ||||
|                                 jQuery('<h3>').text("{{ trans('texts.bluevine_line_of_credit') }}"), | ||||
|                                 quoteDetails | ||||
|                         ); | ||||
| @ -268,7 +270,7 @@ | ||||
|                         jQuery('<a class="btn btn-primary">').attr('href', redirectUrl).text("{{ trans('texts.bluevine_continue') }}") | ||||
|                 ) | ||||
|             } else { | ||||
|                 $('#bluevineModal .modal-body').append( | ||||
|                 $('#bluevineModal .panel-body').append( | ||||
|                         jQuery('<div class="alert alert-danger">').text(data.message ? data.message : "{{ trans('texts.bluevine_unexpected_error') }}") | ||||
|                 ); | ||||
|             } | ||||
| @ -276,11 +278,11 @@ | ||||
|             $('#bluevineModal .btn-primary').removeAttr('disabled'); | ||||
|         }, 'json').error( | ||||
|                 function () { | ||||
|                     $('#bluevineModal .modal-body').append( | ||||
|                     $('#bluevineModal .panel-body').append( | ||||
|                             jQuery('<div class="alert alert-danger">').text("{{ trans('texts.bluevine_unexpected_error') }}") | ||||
|                     ); | ||||
|                     $('#bluevineModal .btn-primary').removeAttr('disabled'); | ||||
|                 } | ||||
|         ); | ||||
|     } | ||||
| </script> | ||||
| </script> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user