mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Proposals
This commit is contained in:
parent
202aa83b4a
commit
76e5001826
@ -16,7 +16,6 @@ use App\Ninja\Repositories\DocumentRepository;
|
|||||||
use App\Ninja\Repositories\InvoiceRepository;
|
use App\Ninja\Repositories\InvoiceRepository;
|
||||||
use App\Ninja\Repositories\PaymentRepository;
|
use App\Ninja\Repositories\PaymentRepository;
|
||||||
use App\Ninja\Repositories\TaskRepository;
|
use App\Ninja\Repositories\TaskRepository;
|
||||||
use App\Ninja\Repositories\ProposalRepository;
|
|
||||||
use App\Services\PaymentService;
|
use App\Services\PaymentService;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Barracuda\ArchiveStream\ZipArchive;
|
use Barracuda\ArchiveStream\ZipArchive;
|
||||||
@ -38,7 +37,6 @@ class ClientPortalController extends BaseController
|
|||||||
private $invoiceRepo;
|
private $invoiceRepo;
|
||||||
private $paymentRepo;
|
private $paymentRepo;
|
||||||
private $documentRepo;
|
private $documentRepo;
|
||||||
private $propoosalRepo;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
InvoiceRepository $invoiceRepo,
|
InvoiceRepository $invoiceRepo,
|
||||||
@ -47,8 +45,7 @@ class ClientPortalController extends BaseController
|
|||||||
DocumentRepository $documentRepo,
|
DocumentRepository $documentRepo,
|
||||||
PaymentService $paymentService,
|
PaymentService $paymentService,
|
||||||
CreditRepository $creditRepo,
|
CreditRepository $creditRepo,
|
||||||
TaskRepository $taskRepo,
|
TaskRepository $taskRepo)
|
||||||
ProposalRepository $propoosalRepo)
|
|
||||||
{
|
{
|
||||||
$this->invoiceRepo = $invoiceRepo;
|
$this->invoiceRepo = $invoiceRepo;
|
||||||
$this->paymentRepo = $paymentRepo;
|
$this->paymentRepo = $paymentRepo;
|
||||||
@ -57,42 +54,6 @@ class ClientPortalController extends BaseController
|
|||||||
$this->paymentService = $paymentService;
|
$this->paymentService = $paymentService;
|
||||||
$this->creditRepo = $creditRepo;
|
$this->creditRepo = $creditRepo;
|
||||||
$this->taskRepo = $taskRepo;
|
$this->taskRepo = $taskRepo;
|
||||||
$this->propoosalRepo = $propoosalRepo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function viewProposal($invitationKey)
|
|
||||||
{
|
|
||||||
if (! $invitation = $this->propoosalRepo->findInvitationByKey($invitationKey)) {
|
|
||||||
return $this->returnError(trans('texts.proposal_not_found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$account = $invitation->account;
|
|
||||||
$proposal = $invitation->proposal;
|
|
||||||
$invoiceInvitation = Invitation::whereContactId($invitation->contact_id)
|
|
||||||
->whereInvoiceId($proposal->invoice_id)
|
|
||||||
->firstOrFail();
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'proposal' => $proposal,
|
|
||||||
'account' => $account,
|
|
||||||
'invoiceInvitation' => $invoiceInvitation,
|
|
||||||
'proposalInvitation' => $invitation,
|
|
||||||
];
|
|
||||||
|
|
||||||
return view('invited.proposal', $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function downloadProposal($invitationKey)
|
|
||||||
{
|
|
||||||
if (! $invitation = $this->propoosalRepo->findInvitationByKey($invitationKey)) {
|
|
||||||
return $this->returnError(trans('texts.proposal_not_found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$proposal = $invitation->proposal;
|
|
||||||
|
|
||||||
$mpdf = new \mPDF();
|
|
||||||
$mpdf->WriteHTML($proposal->present()->htmlDocument);
|
|
||||||
$mpdf->Output($proposal->present()->filename, 'D');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function viewInvoice($invitationKey)
|
public function viewInvoice($invitationKey)
|
||||||
@ -836,16 +797,6 @@ class ClientPortalController extends BaseController
|
|||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function getProposalDocument($accountKey, $publicId)
|
|
||||||
{
|
|
||||||
$account = Account::whereAccountKey($accountKey)->firstOrFail();
|
|
||||||
$document = Document::whereAccountId($account->id)->wherePublicId($publicId)->firstOrFail();
|
|
||||||
|
|
||||||
return DocumentController::getDownloadResponse($document);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function getDocument($invitationKey, $publicId)
|
public function getDocument($invitationKey, $publicId)
|
||||||
{
|
{
|
||||||
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||||
|
70
app/Http/Controllers/ClientPortalProposalController.php
Normal file
70
app/Http/Controllers/ClientPortalProposalController.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use mPDF;
|
||||||
|
use App\Models\Account;
|
||||||
|
use App\Models\Document;
|
||||||
|
use App\Models\Invitation;
|
||||||
|
use App\Ninja\Repositories\ProposalRepository;
|
||||||
|
|
||||||
|
class ClientPortalProposalController extends BaseController
|
||||||
|
{
|
||||||
|
private $invoiceRepo;
|
||||||
|
private $paymentRepo;
|
||||||
|
private $documentRepo;
|
||||||
|
private $propoosalRepo;
|
||||||
|
|
||||||
|
public function __construct(ProposalRepository $propoosalRepo)
|
||||||
|
{
|
||||||
|
$this->propoosalRepo = $propoosalRepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function viewProposal($invitationKey)
|
||||||
|
{
|
||||||
|
if (! $invitation = $this->propoosalRepo->findInvitationByKey($invitationKey)) {
|
||||||
|
return $this->returnError(trans('texts.proposal_not_found'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$account = $invitation->account;
|
||||||
|
$proposal = $invitation->proposal;
|
||||||
|
$invoiceInvitation = Invitation::whereContactId($invitation->contact_id)
|
||||||
|
->whereInvoiceId($proposal->invoice_id)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'proposal' => $proposal,
|
||||||
|
'account' => $account,
|
||||||
|
'invoiceInvitation' => $invoiceInvitation,
|
||||||
|
'proposalInvitation' => $invitation,
|
||||||
|
];
|
||||||
|
|
||||||
|
return view('invited.proposal', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downloadProposal($invitationKey)
|
||||||
|
{
|
||||||
|
if (! $invitation = $this->propoosalRepo->findInvitationByKey($invitationKey)) {
|
||||||
|
return $this->returnError(trans('texts.proposal_not_found'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$proposal = $invitation->proposal;
|
||||||
|
|
||||||
|
$mpdf = new mPDF();
|
||||||
|
$mpdf->WriteHTML($proposal->present()->htmlDocument);
|
||||||
|
$mpdf->Output($proposal->present()->filename, 'D');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProposalImage($accountKey, $documentKey)
|
||||||
|
{
|
||||||
|
$account = Account::whereAccountKey($accountKey)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$document = Document::whereAccountId($account->id)
|
||||||
|
->whereDocumentKey($documentKey)
|
||||||
|
->whereIsProposal(true)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
return DocumentController::getDownloadResponse($document);
|
||||||
|
}
|
||||||
|
}
|
@ -108,7 +108,7 @@ class DocumentController extends BaseController
|
|||||||
if ($request->grapesjs) {
|
if ($request->grapesjs) {
|
||||||
$response = [
|
$response = [
|
||||||
'data' => [
|
'data' => [
|
||||||
$result->getUrl()
|
$result->getProposalUrl()
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
|
@ -38,7 +38,7 @@ class ProposalComposer
|
|||||||
$data = [];
|
$data = [];
|
||||||
foreach ($documents as $document) {
|
foreach ($documents as $document) {
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'src' => $document->getUrl(),
|
'src' => $document->getProposalUrl(),
|
||||||
'public_id' => $document->public_id,
|
'public_id' => $document->public_id,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -272,6 +272,15 @@ class Document extends EntityModel
|
|||||||
return url('client/documents/'.$invitation->invitation_key.'/'.$this->public_id.'/'.$this->name);
|
return url('client/documents/'.$invitation->invitation_key.'/'.$this->public_id.'/'.$this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getProposalUrl()
|
||||||
|
{
|
||||||
|
if (! $this->is_proposal || ! $this->document_key) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return url('proposal/image/'. $this->account->account_key . '/' . $this->document_key . '/' . $this->name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -54,11 +54,14 @@ class DocumentRepository extends BaseRepository
|
|||||||
|
|
||||||
public function upload($data, &$doc_array = null)
|
public function upload($data, &$doc_array = null)
|
||||||
{
|
{
|
||||||
if (! empty($data['files']) && is_array($data['files'])) {
|
if (! empty($data['grapesjs']) && $data['grapesjs']) {
|
||||||
|
$isProposal = true;
|
||||||
$uploaded = $data['files'][0];
|
$uploaded = $data['files'][0];
|
||||||
} else {
|
} else {
|
||||||
|
$isProposal = false;
|
||||||
$uploaded = $data['file'];
|
$uploaded = $data['file'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$extension = strtolower($uploaded->getClientOriginalExtension());
|
$extension = strtolower($uploaded->getClientOriginalExtension());
|
||||||
if (empty(Document::$types[$extension]) && ! empty(Document::$extraExtensions[$extension])) {
|
if (empty(Document::$types[$extension]) && ! empty(Document::$extraExtensions[$extension])) {
|
||||||
$documentType = Document::$extraExtensions[$extension];
|
$documentType = Document::$extraExtensions[$extension];
|
||||||
@ -91,6 +94,11 @@ class DocumentRepository extends BaseRepository
|
|||||||
$document = Document::createNew();
|
$document = Document::createNew();
|
||||||
$document->fill($data);
|
$document->fill($data);
|
||||||
|
|
||||||
|
if ($isProposal) {
|
||||||
|
$document->is_proposal = true;
|
||||||
|
$document->document_key = strtolower(str_random(RANDOM_KEY_LENGTH));
|
||||||
|
}
|
||||||
|
|
||||||
$disk = $document->getDisk();
|
$disk = $document->getDisk();
|
||||||
if (! $disk->exists($filename)) {// Have we already stored the same file
|
if (! $disk->exists($filename)) {// Have we already stored the same file
|
||||||
$stream = fopen($filePath, 'r');
|
$stream = fopen($filePath, 'r');
|
||||||
|
File diff suppressed because one or more lines are too long
@ -16,9 +16,8 @@ Route::post('/get_started', 'AccountController@getStarted');
|
|||||||
// Client visible pages
|
// Client visible pages
|
||||||
Route::group(['middleware' => ['lookup:contact', 'auth:client']], function () {
|
Route::group(['middleware' => ['lookup:contact', 'auth:client']], function () {
|
||||||
Route::get('view/{invitation_key}', 'ClientPortalController@viewInvoice');
|
Route::get('view/{invitation_key}', 'ClientPortalController@viewInvoice');
|
||||||
Route::get('proposal/{proposal_invitation_key}/download', 'ClientPortalController@downloadProposal');
|
Route::get('proposal/{proposal_invitation_key}/download', 'ClientPortalProposalController@downloadProposal');
|
||||||
Route::get('proposal/{proposal_invitation_key}', 'ClientPortalController@viewProposal');
|
Route::get('proposal/{proposal_invitation_key}', 'ClientPortalProposalController@viewProposal');
|
||||||
//Route::get('proposal/document/{account_key}/{public_id}/{filename?}', 'ClientPortalController@getProposalDocument');
|
|
||||||
Route::get('download/{invitation_key}', 'ClientPortalController@download');
|
Route::get('download/{invitation_key}', 'ClientPortalController@download');
|
||||||
Route::put('sign/{invitation_key}', 'ClientPortalController@sign');
|
Route::put('sign/{invitation_key}', 'ClientPortalController@sign');
|
||||||
Route::get('view', 'HomeController@viewLogo');
|
Route::get('view', 'HomeController@viewLogo');
|
||||||
@ -107,6 +106,7 @@ Route::group(['middleware' => ['lookup:contact']], function () {
|
|||||||
Route::post('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\LoginController@login']);
|
Route::post('/client/login', ['as' => 'login', 'uses' => 'ClientAuth\LoginController@login']);
|
||||||
Route::post('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\ForgotPasswordController@sendResetLinkEmail']);
|
Route::post('/client/recover_password', ['as' => 'forgot', 'uses' => 'ClientAuth\ForgotPasswordController@sendResetLinkEmail']);
|
||||||
Route::post('/client/password/reset', ['as' => 'forgot', 'uses' => 'ClientAuth\ResetPasswordController@reset']);
|
Route::post('/client/password/reset', ['as' => 'forgot', 'uses' => 'ClientAuth\ResetPasswordController@reset']);
|
||||||
|
Route::get('/proposal/image/{account_key}/{document_key}/{filename?}', 'ClientPortalProposalController@getProposalImage');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Utils::isReseller()) {
|
if (Utils::isReseller()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user