mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 02:57:33 -05:00 
			
		
		
		
	Merge pull request #5722 from turbo124/v5-develop
Fixes for delivering PDFs over the wire
This commit is contained in:
		
						commit
						f2f0e1883f
					
				@ -269,13 +269,21 @@ class Credit extends BaseModel
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $file_path = $this->client->credit_filepath().$this->numberFormatter().'.pdf';
 | 
					        $file_path = $this->client->credit_filepath().$this->numberFormatter().'.pdf';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)){
 | 
				
			||||||
 | 
					            return Storage::disk(config('filesystems.default'))->{$type}($file_path);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        elseif(Ninja::isHosted() && $portal){
 | 
				
			||||||
 | 
					            $file_path = CreateEntityPdf::dispatchNow($invitation,config('filesystems.default'));
 | 
				
			||||||
 | 
					            return Storage::disk(config('filesystems.default'))->{$type}($file_path);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        if(Storage::disk('public')->exists($file_path))
 | 
					        if(Storage::disk('public')->exists($file_path))
 | 
				
			||||||
            return Storage::disk('public')->{$type}($file_path);
 | 
					            return Storage::disk('public')->{$type}($file_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $file_path = CreateEntityPdf::dispatchNow($invitation);
 | 
					        $file_path = CreateEntityPdf::dispatchNow($invitation);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            return Storage::disk('public')->{$type}($file_path);
 | 
					            return Storage::disk('public')->{$type}($file_path);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function markInvitationsSent()
 | 
					    public function markInvitationsSent()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->invitations->each(function ($invitation) {
 | 
					        $this->invitations->each(function ($invitation) {
 | 
				
			||||||
 | 
				
			|||||||
@ -410,11 +410,18 @@ class Invoice extends BaseModel
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $file_path = $this->client->invoice_filepath().$this->numberFormatter().'.pdf';
 | 
					        $file_path = $this->client->invoice_filepath().$this->numberFormatter().'.pdf';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)){
 | 
				
			||||||
 | 
					            return Storage::disk(config('filesystems.default'))->{$type}($file_path);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        elseif(Ninja::isHosted() && $portal){
 | 
				
			||||||
 | 
					            $file_path = CreateEntityPdf::dispatchNow($invitation,config('filesystems.default'));
 | 
				
			||||||
 | 
					            return Storage::disk(config('filesystems.default'))->{$type}($file_path);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        if(Storage::disk('public')->exists($file_path))
 | 
					        if(Storage::disk('public')->exists($file_path))
 | 
				
			||||||
            return Storage::disk('public')->{$type}($file_path);
 | 
					            return Storage::disk('public')->{$type}($file_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $file_path = CreateEntityPdf::dispatchNow($invitation);
 | 
					        $file_path = CreateEntityPdf::dispatchNow($invitation);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            return Storage::disk('public')->{$type}($file_path);
 | 
					            return Storage::disk('public')->{$type}($file_path);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -225,11 +225,18 @@ class Quote extends BaseModel
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $file_path = $this->client->quote_filepath().$this->numberFormatter().'.pdf';
 | 
					        $file_path = $this->client->quote_filepath().$this->numberFormatter().'.pdf';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)){
 | 
				
			||||||
 | 
					            return Storage::disk(config('filesystems.default'))->{$type}($file_path);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        elseif(Ninja::isHosted() && $portal){
 | 
				
			||||||
 | 
					            $file_path = CreateEntityPdf::dispatchNow($invitation,config('filesystems.default'));
 | 
				
			||||||
 | 
					            return Storage::disk(config('filesystems.default'))->{$type}($file_path);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        if(Storage::disk('public')->exists($file_path))
 | 
					        if(Storage::disk('public')->exists($file_path))
 | 
				
			||||||
            return Storage::disk('public')->{$type}($file_path);
 | 
					            return Storage::disk('public')->{$type}($file_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $file_path = CreateEntityPdf::dispatchNow($invitation);
 | 
					        $file_path = CreateEntityPdf::dispatchNow($invitation);
 | 
				
			||||||
 | 
					 | 
				
			||||||
            return Storage::disk('public')->{$type}($file_path);
 | 
					            return Storage::disk('public')->{$type}($file_path);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -16,6 +16,7 @@ use App\Factory\CreditInvitationFactory;
 | 
				
			|||||||
use App\Models\Credit;
 | 
					use App\Models\Credit;
 | 
				
			||||||
use App\Models\CreditInvitation;
 | 
					use App\Models\CreditInvitation;
 | 
				
			||||||
use App\Services\AbstractService;
 | 
					use App\Services\AbstractService;
 | 
				
			||||||
 | 
					use Illuminate\Support\Str;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CreateInvitations extends AbstractService
 | 
					class CreateInvitations extends AbstractService
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
@ -41,19 +41,12 @@ class GetInvoicePdf extends AbstractService
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $disk = 'public';
 | 
					        $disk = 'public';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // $disk = config('filesystems.default');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $file = Storage::disk($disk)->exists($file_path);
 | 
					        $file = Storage::disk($disk)->exists($file_path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (! $file) {
 | 
					        if (! $file) {
 | 
				
			||||||
            $file_path = CreateEntityPdf::dispatchNow($invitation);
 | 
					            $file_path = CreateEntityPdf::dispatchNow($invitation);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // /* Copy from remote disk to local when using cloud file storage. */
 | 
					 | 
				
			||||||
        // if(config('filesystems.default') == 's3')
 | 
					 | 
				
			||||||
        //     return TempFile::path(Storage::disk($disk)->url($file_path));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // return Storage::disk($disk)->url($file_path);
 | 
					 | 
				
			||||||
        return Storage::disk($disk)->path($file_path);
 | 
					        return Storage::disk($disk)->path($file_path);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user