mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Proposals
This commit is contained in:
parent
4502cf2531
commit
b3f6bc7b9b
@ -67,21 +67,17 @@ class ClientPortalController extends BaseController
|
|||||||
|
|
||||||
$account = $invitation->account;
|
$account = $invitation->account;
|
||||||
$proposal = $invitation->proposal;
|
$proposal = $invitation->proposal;
|
||||||
|
$invitation = Invitation::whereContactId($invitation->contact_id)
|
||||||
|
->whereInvoiceId($proposal->invoice_id)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'proposalInvitation' => $invitation,
|
'proposalInvitation' => $invitation,
|
||||||
'proposal' => $proposal,
|
'proposal' => $proposal,
|
||||||
'account' => $account,
|
'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);
|
return view('invited.proposal', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class ProposalController extends BaseController
|
|||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'url' => 'proposals',
|
'url' => 'proposals',
|
||||||
'title' => trans('texts.new_proposal'),
|
'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(),
|
'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(),
|
||||||
'invoicePublicId' => $request->invoicee_id,
|
'invoicePublicId' => $request->invoicee_id,
|
||||||
];
|
];
|
||||||
@ -86,7 +86,7 @@ class ProposalController extends BaseController
|
|||||||
'method' => 'PUT',
|
'method' => 'PUT',
|
||||||
'url' => 'proposals/' . $proposal->public_id,
|
'url' => 'proposals/' . $proposal->public_id,
|
||||||
'title' => trans('texts.edit_proposal'),
|
'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(),
|
'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(),
|
||||||
'invoicePublicId' => $proposal->invoice ? $proposal->invoice->public_id : null,
|
'invoicePublicId' => $proposal->invoice ? $proposal->invoice->public_id : null,
|
||||||
'templatePublicId' => $proposal->proposal_template ? $proposal->proposal_template->public_id : null,
|
'templatePublicId' => $proposal->proposal_template ? $proposal->proposal_template->public_id : null,
|
||||||
|
@ -54,6 +54,7 @@ class PurgeAccountData extends Job
|
|||||||
'proposal_templates',
|
'proposal_templates',
|
||||||
'proposal_snippets',
|
'proposal_snippets',
|
||||||
'proposal_categories',
|
'proposal_categories',
|
||||||
|
'proposal_invitations',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
|
@ -451,6 +451,23 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
->where('is_recurring', '=', false);
|
->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 $query
|
||||||
* @param $typeId
|
* @param $typeId
|
||||||
@ -846,7 +863,7 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
*/
|
*/
|
||||||
public function isApproved()
|
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
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div><br/>
|
<div class="clearfix"></div><br/>
|
||||||
<iframe src="{{ url('/proposal/' . $proposalInvitation->invitation_key . '?raw=true') }}" scrolling="no" onload="resizeIframe(this)"
|
<iframe id="proposalIframe" scrolling="no" onload="resizeIframe(this)" frameborder="0" width="100%"
|
||||||
frameborder="0" width="100%" height="1000px" style="background-color:white; border: solid 1px #DDD;"></iframe>
|
style="background-color:white; border: solid 1px #DDD;"></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
function onApproveClick() {
|
function onApproveClick() {
|
||||||
@if ($account->requiresAuthorization($proposal->invoice))
|
|
||||||
window.pendingPaymentFunction = approveQuote;
|
|
||||||
showAuthorizationModal();
|
|
||||||
@else
|
|
||||||
approveQuote();
|
|
||||||
@endif
|
|
||||||
}
|
|
||||||
|
|
||||||
function approveQuote() {
|
|
||||||
$('#approveButton').prop('disabled', true);
|
$('#approveButton').prop('disabled', true);
|
||||||
location.href = "{{ url('/approve/' . $invitation->invitation_key) }}";
|
location.href = "{{ url('/approve/' . $invitation->invitation_key) }}";
|
||||||
}
|
}
|
||||||
@ -33,6 +24,17 @@
|
|||||||
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
|
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>
|
</script>
|
||||||
|
|
||||||
@stop
|
@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])
|
@include('partials/entity_combobox', ['entityType' => ENTITY_INVOICE])
|
||||||
if (invoiceId) {
|
if (invoiceId) {
|
||||||
var invoice = invoiceMap[invoiceId];
|
var invoice = invoiceMap[invoiceId];
|
||||||
$invoiceSelect.val(invoice.public_id);
|
if (invoice) {
|
||||||
setComboboxValue($('.invoice-select'), invoice.public_id, invoice.invoice_number + ' - ' + getClientDisplayName(invoice.client));
|
$invoiceSelect.val(invoice.public_id);
|
||||||
|
setComboboxValue($('.invoice-select'), invoice.public_id, invoice.invoice_number + ' - ' + getClientDisplayName(invoice.client));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$invoiceSelect.change(loadTemplate);
|
$invoiceSelect.change(loadTemplate);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user