mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add documents placeholder for emails
This commit is contained in:
parent
10fa256809
commit
2a7e8cb4b7
@ -33,6 +33,10 @@ class DocumentController extends BaseController
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return static::getDownloadResponse($document);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDownloadResponse($document){
|
||||||
$direct_url = $document->getDirectUrl();
|
$direct_url = $document->getDirectUrl();
|
||||||
if($direct_url){
|
if($direct_url){
|
||||||
return redirect($direct_url);
|
return redirect($direct_url);
|
||||||
|
@ -414,5 +414,30 @@ class PublicClientController extends BaseController
|
|||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getDocument($invitationKey, $publicId){
|
||||||
|
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||||
|
return $this->returnError();
|
||||||
|
}
|
||||||
|
|
||||||
|
Session::put('invitation_key', $invitationKey); // track current invitation
|
||||||
|
|
||||||
|
$clientId = $invitation->invoice->client_id;
|
||||||
|
$document = Document::scope($publicId, $invitation->account_id)->firstOrFail();
|
||||||
|
|
||||||
|
$authorized = false;
|
||||||
|
if($document->expense && $document->expense->client_id == $invitation->invoice->client_id){
|
||||||
|
$authorized = true;
|
||||||
|
} else if($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id){
|
||||||
|
$authorized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$authorized){
|
||||||
|
return Response::view('error', array('error'=>'Not authorized'), 403);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DocumentController::getDownloadResponse($document);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class Authenticate {
|
|||||||
|
|
||||||
// Does this account require portal passwords?
|
// Does this account require portal passwords?
|
||||||
$account = Account::whereId($account_id)->first();
|
$account = Account::whereId($account_id)->first();
|
||||||
if(!$account->enable_portal_password || !$account->isPro()){
|
if($account && (!$account->enable_portal_password || !$account->isPro())){
|
||||||
$authenticated = true;
|
$authenticated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ Route::group(['middleware' => 'auth:client'], function() {
|
|||||||
Route::get('client/payments', 'PublicClientController@paymentIndex');
|
Route::get('client/payments', 'PublicClientController@paymentIndex');
|
||||||
Route::get('client/dashboard', 'PublicClientController@dashboard');
|
Route::get('client/dashboard', 'PublicClientController@dashboard');
|
||||||
Route::get('client/document/js/{public_id}/{filename}', 'PublicClientController@getDocumentVFSJS');
|
Route::get('client/document/js/{public_id}/{filename}', 'PublicClientController@getDocumentVFSJS');
|
||||||
|
Route::get('client/document/{invitation_key}/{public_id}/{filename?}', 'PublicClientController@getDocument');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('api/client.quotes', array('as'=>'api.client.quotes', 'uses'=>'PublicClientController@quoteDatatable'));
|
Route::get('api/client.quotes', array('as'=>'api.client.quotes', 'uses'=>'PublicClientController@quoteDatatable'));
|
||||||
|
@ -138,6 +138,10 @@ class Document extends EntityModel
|
|||||||
return url('document/'.$this->public_id.'/'.$this->name);
|
return url('document/'.$this->public_id.'/'.$this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getClientUrl($invitation){
|
||||||
|
return url('client/document/'.$invitation->invitation_key.'/'.$this->public_id.'/'.$this->name);
|
||||||
|
}
|
||||||
|
|
||||||
public function getVFSJSUrl(){
|
public function getVFSJSUrl(){
|
||||||
return url('document/js/'.$this->public_id.'/'.$this->name.'.js');
|
return url('document/js/'.$this->public_id.'/'.$this->name.'.js');
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php namespace App\Ninja\Mailers;
|
<?php namespace App\Ninja\Mailers;
|
||||||
|
|
||||||
use Form;
|
use Form;
|
||||||
|
use HTML;
|
||||||
use Utils;
|
use Utils;
|
||||||
use Event;
|
use Event;
|
||||||
use URL;
|
use URL;
|
||||||
@ -28,6 +29,7 @@ class ContactMailer extends Mailer
|
|||||||
'invoice',
|
'invoice',
|
||||||
'quote',
|
'quote',
|
||||||
'password',
|
'password',
|
||||||
|
'documents',
|
||||||
'viewLink',
|
'viewLink',
|
||||||
'viewButton',
|
'viewButton',
|
||||||
'paymentLink',
|
'paymentLink',
|
||||||
@ -281,7 +283,16 @@ class ContactMailer extends Mailer
|
|||||||
$invitation = $data['invitation'];
|
$invitation = $data['invitation'];
|
||||||
$invoice = $invitation->invoice;
|
$invoice = $invitation->invoice;
|
||||||
$passwordHTML = isset($data['password'])?'<p>'.trans('texts.password').': '.$data['password'].'<p>':false;
|
$passwordHTML = isset($data['password'])?'<p>'.trans('texts.password').': '.$data['password'].'<p>':false;
|
||||||
|
$documentsHTML = '';
|
||||||
|
|
||||||
|
if($account->isPro() && count($invoice->documents)){
|
||||||
|
$documentsHTML .= trans('texts.email_documents_header').'<ul>';
|
||||||
|
foreach($invoice->documents as $document){
|
||||||
|
$documentsHTML .= '<li><a href="'.HTML::entities($document->getClientUrl($invitation)).'">'.HTML::entities($document->name).'</a></li>';
|
||||||
|
}
|
||||||
|
$documentsHTML .= '</ul>';
|
||||||
|
}
|
||||||
|
|
||||||
$variables = [
|
$variables = [
|
||||||
'$footer' => $account->getEmailFooter(),
|
'$footer' => $account->getEmailFooter(),
|
||||||
'$client' => $client->getDisplayName(),
|
'$client' => $client->getDisplayName(),
|
||||||
@ -303,6 +314,7 @@ class ContactMailer extends Mailer
|
|||||||
'$customClient2' => $account->custom_client_label2,
|
'$customClient2' => $account->custom_client_label2,
|
||||||
'$customInvoice1' => $account->custom_invoice_text_label1,
|
'$customInvoice1' => $account->custom_invoice_text_label1,
|
||||||
'$customInvoice2' => $account->custom_invoice_text_label2,
|
'$customInvoice2' => $account->custom_invoice_text_label2,
|
||||||
|
'$documents' => $documentsHTML,
|
||||||
];
|
];
|
||||||
|
|
||||||
// Add variables for available payment types
|
// Add variables for available payment types
|
||||||
|
@ -1098,6 +1098,9 @@ $LANG = array(
|
|||||||
'december' => 'December',
|
'december' => 'December',
|
||||||
|
|
||||||
// Documents
|
// Documents
|
||||||
|
'email_documents_header' => 'Documents:',
|
||||||
|
'email_documents_example_1' => 'Widgets Receipt.pdf',
|
||||||
|
'email_documents_example_2' => 'Final Deliverable.zip',
|
||||||
'invoice_documents' => 'Attached Documents',
|
'invoice_documents' => 'Attached Documents',
|
||||||
'document_upload_message' => 'Drop files here or click to upload.',
|
'document_upload_message' => 'Drop files here or click to upload.',
|
||||||
'invoice_embed_documents' => 'Embed Documents',
|
'invoice_embed_documents' => 'Embed Documents',
|
||||||
|
@ -201,6 +201,13 @@
|
|||||||
|
|
||||||
var keys = {!! json_encode(\App\Ninja\Mailers\ContactMailer::$variableFields) !!};
|
var keys = {!! json_encode(\App\Ninja\Mailers\ContactMailer::$variableFields) !!};
|
||||||
var passwordHtml = "{!! $account->isPro() && $account->enable_portal_password && $account->send_portal_password?'<p>'.trans('texts.password').': 6h2NWNdw6<p>':'' !!}";
|
var passwordHtml = "{!! $account->isPro() && $account->enable_portal_password && $account->send_portal_password?'<p>'.trans('texts.password').': 6h2NWNdw6<p>':'' !!}";
|
||||||
|
|
||||||
|
@if ($account->isPro())
|
||||||
|
var documentsHtml = "{!! trans('texts.email_documents_header').'<ul><li><a>'.trans('texts.email_documents_example_1').'</a></li><li><a>'.trans('texts.email_documents_example_2').'</a></li></ul>' !!}";
|
||||||
|
@else
|
||||||
|
var documentsHtml = "";
|
||||||
|
@endif
|
||||||
|
|
||||||
var vals = [
|
var vals = [
|
||||||
{!! json_encode($emailFooter) !!},
|
{!! json_encode($emailFooter) !!},
|
||||||
"{{ $account->getDisplayName() }}",
|
"{{ $account->getDisplayName() }}",
|
||||||
@ -213,6 +220,7 @@
|
|||||||
"0001",
|
"0001",
|
||||||
"0001",
|
"0001",
|
||||||
passwordHtml,
|
passwordHtml,
|
||||||
|
documentsHtml,
|
||||||
"{{ URL::to('/view/...') }}$password",
|
"{{ URL::to('/view/...') }}$password",
|
||||||
'{!! Form::flatButton('view_invoice', '#0b4d78') !!}$password',
|
'{!! Form::flatButton('view_invoice', '#0b4d78') !!}$password',
|
||||||
"{{ URL::to('/payment/...') }}$password",
|
"{{ URL::to('/payment/...') }}$password",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user