mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #6237 from turbo124/v5-develop
Fixes for download invoices from client portal
This commit is contained in:
commit
c03238135e
@ -12,6 +12,7 @@
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ClientPortal\Contact\ContactPasswordResetRequest;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Account;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
@ -73,9 +74,8 @@ class ContactForgotPasswordController extends Controller
|
||||
return Password::broker('contacts');
|
||||
}
|
||||
|
||||
public function sendResetLinkEmail(Request $request)
|
||||
public function sendResetLinkEmail(ContactPasswordResetRequest $request)
|
||||
{
|
||||
//MultiDB::userFindAndSetDb($request->input('email'));
|
||||
|
||||
$user = MultiDB::hasContact($request->input('email'));
|
||||
|
||||
|
@ -24,6 +24,7 @@ use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\View\View;
|
||||
use ZipStream\Option\Archive;
|
||||
use ZipStream\ZipStream;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class InvoiceController extends Controller
|
||||
{
|
||||
@ -170,8 +171,10 @@ class InvoiceController extends Controller
|
||||
$invitation = $invoice->invitations->first();
|
||||
//$file = $invoice->pdf_file_path($invitation);
|
||||
$file = $invoice->service()->getInvoicePdf(auth()->user());
|
||||
return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);;
|
||||
|
||||
// return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);;
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
}
|
||||
|
||||
// enable output of HTTP headers
|
||||
|
@ -33,6 +33,7 @@ use App\Utils\Traits\SavesDocuments;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Class RecurringInvoiceController.
|
||||
@ -500,9 +501,12 @@ class RecurringInvoiceController extends BaseController
|
||||
$contact = $invitation->contact;
|
||||
$recurring_invoice = $invitation->recurring_invoice;
|
||||
|
||||
$file_path = $recurring_invoice->service()->getInvoicePdf($contact);
|
||||
$file = $recurring_invoice->service()->getInvoicePdf($contact);
|
||||
|
||||
return response()->streamDownload(function () use($file) {
|
||||
echo Storage::get($file);
|
||||
}, basename($file));
|
||||
|
||||
return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,12 +60,6 @@ class StripeConnectController extends BaseController
|
||||
$redirect_uri = 'https://invoicing.co/stripe/completed';
|
||||
$endpoint = "https://connect.stripe.com/oauth/authorize?response_type=code&client_id={$stripe_client_id}&redirect_uri={$redirect_uri}&scope=read_write&state={$token}";
|
||||
|
||||
// if($email = $request->getContact()->email)
|
||||
// $endpoint .= "&stripe_user[email]={$email}";
|
||||
|
||||
// $company_name = str_replace(" ", "_", $company->present()->name());
|
||||
// $endpoint .= "&stripe_user[business_name]={$company_name}";
|
||||
|
||||
return redirect($endpoint);
|
||||
}
|
||||
|
||||
@ -87,18 +81,24 @@ class StripeConnectController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
// nlog($response);
|
||||
|
||||
$company = Company::where('company_key', $request->getTokenContent()['company_key'])->first();
|
||||
|
||||
$company_gateway = CompanyGatewayFactory::create($company->id, $company->owner()->id);
|
||||
$fees_and_limits = new \stdClass;
|
||||
$fees_and_limits->{GatewayType::CREDIT_CARD} = new FeesAndLimits;
|
||||
$company_gateway->gateway_key = 'd14dd26a47cecc30fdd65700bfb67b34';
|
||||
$company_gateway->fees_and_limits = $fees_and_limits;
|
||||
$company_gateway->setConfig([]);
|
||||
$company_gateway->token_billing = 'always';
|
||||
// $company_gateway->save();
|
||||
$company_gateway = CompanyGateway::query()
|
||||
->where('gateway_key', 'd14dd26a47cecc30fdd65700bfb67b34')
|
||||
->where('company_id', $company->id)
|
||||
->first();
|
||||
|
||||
if(!$company_gateway)
|
||||
{
|
||||
$company_gateway = CompanyGatewayFactory::create($company->id, $company->owner()->id);
|
||||
$fees_and_limits = new \stdClass;
|
||||
$fees_and_limits->{GatewayType::CREDIT_CARD} = new FeesAndLimits;
|
||||
$company_gateway->gateway_key = 'd14dd26a47cecc30fdd65700bfb67b34';
|
||||
$company_gateway->fees_and_limits = $fees_and_limits;
|
||||
$company_gateway->setConfig([]);
|
||||
$company_gateway->token_billing = 'always';
|
||||
// $company_gateway->save();
|
||||
}
|
||||
|
||||
$payload = [
|
||||
'account_id' => $response->stripe_user_id,
|
||||
@ -111,18 +111,6 @@ class StripeConnectController extends BaseController
|
||||
"access_token" => $response->access_token
|
||||
];
|
||||
|
||||
/* Link account if existing account exists */
|
||||
// if($account_id = $this->checkAccountAlreadyLinkToEmail($company_gateway, $request->getContact()->email)) {
|
||||
|
||||
// $payload['account_id'] = $account_id;
|
||||
// $payload['stripe_user_id'] = $account_id;
|
||||
// $company_gateway->setConfig($payload);
|
||||
// $company_gateway->save();
|
||||
|
||||
// return view('auth.connect.existing');
|
||||
|
||||
// }
|
||||
|
||||
$company_gateway->setConfig($payload);
|
||||
$company_gateway->save();
|
||||
|
||||
|
@ -51,10 +51,10 @@ class QueryLogging
|
||||
$count = count($queries);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
|
||||
//nlog($request->method().' - '.urldecode($request->url()).": $count queries - ".$time);
|
||||
// if($count > 50)
|
||||
//nlog($queries);
|
||||
|
||||
if($count > 150)
|
||||
nlog($queries);
|
||||
|
||||
$ip = '';
|
||||
|
||||
if(request()->header('Cf-Connecting-Ip'))
|
||||
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\ClientPortal\Contact;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ContactPasswordResetRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'email' => 'required',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -28,12 +28,7 @@ class ImportJsonRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// 'import_type' => 'required',
|
||||
// 'files' => 'required_without:hash|array|min:1|max:6',
|
||||
// 'hash' => 'nullable|string',
|
||||
// 'column_map' => 'required_with:hash|array',
|
||||
// 'skip_header' => 'required_with:hash|boolean',
|
||||
// 'files.*' => 'file|mimes:csv,txt',
|
||||
'files' => 'file|mimes:zip',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace App\Models;
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\DataMapper\CompanySettings;
|
||||
use App\DataMapper\FeesAndLimits;
|
||||
use App\Models\CompanyGateway;
|
||||
use App\Models\Presenters\ClientPresenter;
|
||||
use App\Services\Client\ClientService;
|
||||
@ -430,6 +431,13 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
{
|
||||
$cg = CompanyGateway::find($pm['company_gateway_id']);
|
||||
|
||||
if($cg && !property_exists($cg->fees_and_limits, GatewayType::CREDIT_CARD)){
|
||||
$fees_and_limits = $cg->fees_and_limits;
|
||||
$fees_and_limits->{GatewayType::CREDIT_CARD} = new FeesAndLimits;
|
||||
$cg->fees_and_limits = $fees_and_limits;
|
||||
$cg->save();
|
||||
}
|
||||
|
||||
if($cg && $cg->fees_and_limits->{GatewayType::CREDIT_CARD}->is_enabled)
|
||||
return $cg;
|
||||
|
||||
@ -455,6 +463,13 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
{
|
||||
$cg = CompanyGateway::find($pm['company_gateway_id']);
|
||||
|
||||
if($$cg && !property_exists($cg->fees_and_limits, GatewayType::BANK_TRANSFER)){
|
||||
$fees_and_limits = $cg->fees_and_limits;
|
||||
$fees_and_limits->{GatewayType::BANK_TRANSFER} = new FeesAndLimits;
|
||||
$cg->fees_and_limits = $fees_and_limits;
|
||||
$cg->save();
|
||||
}
|
||||
|
||||
if($cg && $cg->fees_and_limits->{GatewayType::BANK_TRANSFER}->is_enabled)
|
||||
return $cg;
|
||||
}
|
||||
|
@ -202,6 +202,7 @@ class AuthorizeCreditCard
|
||||
private function processFailedResponse($data, $request)
|
||||
{
|
||||
$response = $data['response'];
|
||||
$amount = array_key_exists('amount_with_fee', $data) ? $data['amount_with_fee'] : 0;
|
||||
|
||||
PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransactionResponse()->getTransId(), $this->authorize->client->company, $data['amount_with_fee']);
|
||||
|
||||
|
@ -41,14 +41,14 @@ class GetInvoicePdf extends AbstractService
|
||||
|
||||
$file_path = $path.$this->entity->hashed_id.'.pdf';
|
||||
|
||||
$disk = 'public';
|
||||
$disk = config('filesystems.default');
|
||||
|
||||
$file = Storage::disk($disk)->exists($file_path);
|
||||
|
||||
if (! $file) {
|
||||
$file_path = CreateEntityPdf::dispatchNow($invitation);
|
||||
}
|
||||
|
||||
return Storage::disk($disk)->path($file_path);
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@
|
||||
<input type="email" name="email" id="email"
|
||||
class="input"
|
||||
value="{{ request()->query('email') ?? old('email') }}"
|
||||
autofocus>
|
||||
autofocus
|
||||
required>
|
||||
@error('email')
|
||||
<div class="validation validation-fail">
|
||||
{{ $message }}
|
||||
|
Loading…
Reference in New Issue
Block a user