mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Proposals
This commit is contained in:
parent
4502cf2531
commit
b3f6bc7b9b
@ -67,21 +67,17 @@ class ClientPortalController extends BaseController
|
||||
|
||||
$account = $invitation->account;
|
||||
$proposal = $invitation->proposal;
|
||||
$invitation = Invitation::whereContactId($invitation->contact_id)
|
||||
->whereInvoiceId($proposal->invoice_id)
|
||||
->firstOrFail();
|
||||
|
||||
$data = [
|
||||
'proposalInvitation' => $invitation,
|
||||
'proposal' => $proposal,
|
||||
'account' => $account,
|
||||
'invitation' => $invitation,
|
||||
];
|
||||
|
||||
if (request()->raw) {
|
||||
return view('invited.proposal_raw', $data);
|
||||
}
|
||||
|
||||
$data['invitation'] = Invitation::whereContactId($invitation->contact_id)
|
||||
->whereInvoiceId($proposal->invoice_id)
|
||||
->firstOrFail();
|
||||
|
||||
return view('invited.proposal', $data);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ class ProposalController extends BaseController
|
||||
'method' => 'POST',
|
||||
'url' => 'proposals',
|
||||
'title' => trans('texts.new_proposal'),
|
||||
'invoices' => Invoice::scope()->with('client.contacts')->quotes()->orderBy('id')->get(),
|
||||
'invoices' => Invoice::scope()->with('client.contacts')->unapprovedQuotes()->orderBy('id')->get(),
|
||||
'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(),
|
||||
'invoicePublicId' => $request->invoicee_id,
|
||||
];
|
||||
@ -86,7 +86,7 @@ class ProposalController extends BaseController
|
||||
'method' => 'PUT',
|
||||
'url' => 'proposals/' . $proposal->public_id,
|
||||
'title' => trans('texts.edit_proposal'),
|
||||
'invoices' => Invoice::scope()->with('client.contacts')->quotes()->orderBy('id')->get(),
|
||||
'invoices' => Invoice::scope()->with('client.contacts')->unapprovedQuotes($proposal->invoice_id)->orderBy('id')->get(),
|
||||
'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(),
|
||||
'invoicePublicId' => $proposal->invoice ? $proposal->invoice->public_id : null,
|
||||
'templatePublicId' => $proposal->proposal_template ? $proposal->proposal_template->public_id : null,
|
||||
|
@ -54,6 +54,7 @@ class PurgeAccountData extends Job
|
||||
'proposal_templates',
|
||||
'proposal_snippets',
|
||||
'proposal_categories',
|
||||
'proposal_invitations',
|
||||
];
|
||||
|
||||
foreach ($tables as $table) {
|
||||
|
@ -451,6 +451,23 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
->where('is_recurring', '=', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function scopeUnapprovedQuotes($query, $includeInvoiceId = false)
|
||||
{
|
||||
return $query->quotes()
|
||||
->where(function ($query) use ($includeInvoiceId) {
|
||||
$query->whereId($includeInvoiceId)
|
||||
->orWhere(function ($query) {
|
||||
$query->where('invoice_status_id', '<', INVOICE_STATUS_APPROVED)
|
||||
->whereNull('quote_invoice_id');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $query
|
||||
* @param $typeId
|
||||
@ -846,7 +863,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
||||
*/
|
||||
public function isApproved()
|
||||
{
|
||||
return $this->invoice_status_id >= INVOICE_STATUS_APPROVED;
|
||||
return $this->invoice_status_id >= INVOICE_STATUS_APPROVED || $this->quote_invoice_id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,22 +9,13 @@
|
||||
@endif
|
||||
</div>
|
||||
<div class="clearfix"></div><br/>
|
||||
<iframe src="{{ url('/proposal/' . $proposalInvitation->invitation_key . '?raw=true') }}" scrolling="no" onload="resizeIframe(this)"
|
||||
frameborder="0" width="100%" height="1000px" style="background-color:white; border: solid 1px #DDD;"></iframe>
|
||||
<iframe id="proposalIframe" scrolling="no" onload="resizeIframe(this)" frameborder="0" width="100%"
|
||||
style="background-color:white; border: solid 1px #DDD;"></iframe>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function onApproveClick() {
|
||||
@if ($account->requiresAuthorization($proposal->invoice))
|
||||
window.pendingPaymentFunction = approveQuote;
|
||||
showAuthorizationModal();
|
||||
@else
|
||||
approveQuote();
|
||||
@endif
|
||||
}
|
||||
|
||||
function approveQuote() {
|
||||
$('#approveButton').prop('disabled', true);
|
||||
location.href = "{{ url('/approve/' . $invitation->invitation_key) }}";
|
||||
}
|
||||
@ -33,6 +24,17 @@
|
||||
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
|
||||
}
|
||||
|
||||
$(function() {
|
||||
var html = {!! json_encode($proposal->html) !!};
|
||||
var css = {!! json_encode($proposal->css) !!};
|
||||
|
||||
var content = '<html><head><style>' + css + '</style></head><body>' + html + '</body></html>';
|
||||
var iFrame = document.getElementById('proposalIframe').contentWindow.document;
|
||||
|
||||
iFrame.write(content);
|
||||
iFrame.close();
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@stop
|
||||
|
@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{App::getLocale()}}">
|
||||
<head>
|
||||
<style>
|
||||
{!! $proposal->css !!}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{!! $proposal->html !!}
|
||||
</body>
|
@ -147,8 +147,10 @@
|
||||
@include('partials/entity_combobox', ['entityType' => ENTITY_INVOICE])
|
||||
if (invoiceId) {
|
||||
var invoice = invoiceMap[invoiceId];
|
||||
$invoiceSelect.val(invoice.public_id);
|
||||
setComboboxValue($('.invoice-select'), invoice.public_id, invoice.invoice_number + ' - ' + getClientDisplayName(invoice.client));
|
||||
if (invoice) {
|
||||
$invoiceSelect.val(invoice.public_id);
|
||||
setComboboxValue($('.invoice-select'), invoice.public_id, invoice.invoice_number + ' - ' + getClientDisplayName(invoice.client));
|
||||
}
|
||||
}
|
||||
$invoiceSelect.change(loadTemplate);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user