1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Proposals

This commit is contained in:
Hillel Coren 2018-02-12 14:55:56 +02:00
parent 0658b77e71
commit c9933331ec
4 changed files with 30 additions and 13 deletions

View File

@ -58,19 +58,15 @@ class ProposalController extends BaseController
public function create(ProposalRequest $request)
{
$account = auth()->user()->account;
$data = [
'account' => $account,
$data = array_merge($this->getViewmodel(), [
'proposal' => null,
'method' => 'POST',
'url' => 'proposals',
'title' => trans('texts.new_proposal'),
'invoices' => Invoice::scope()->with('client.contacts', 'client.country')->unapprovedQuotes()->orderBy('id')->get(),
'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(),
'invoicePublicId' => $request->invoice_id,
'templatePublicId' => $request->proposal_template_id,
];
]);
return View::make('proposals.edit', $data);
}
@ -84,24 +80,38 @@ class ProposalController extends BaseController
public function edit(ProposalRequest $request)
{
$account = auth()->user()->account;
$proposal = $request->entity();
$data = [
'account' => $account,
$data = array_merge($this->getViewmodel(), [
'proposal' => $proposal,
'method' => 'PUT',
'url' => 'proposals/' . $proposal->public_id,
'title' => trans('texts.edit_proposal'),
'invoices' => Invoice::scope()->with('client.contacts', 'client.country')->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,
];
]);
return View::make('proposals.edit', $data);
}
private function getViewmodel()
{
$account = auth()->user()->account;
$templates = ProposalTemplate::whereAccountId($account->id)->orderBy('name')->get();
if (! $templates->count()) {
$templates = ProposalTemplate::whereNull('account_id')->orderBy('name')->get();
}
$data = [
'templates' => $templates,
'account' => $account,
];
return $data;
}
public function store(CreateProposalRequest $request)
{
$proposal = $this->proposalService->save($request->input());

View File

@ -2677,6 +2677,7 @@ $LANG = array(
'archived_proposals' => 'Successfully archived :count proposals',
'deleted_proposals' => 'Successfully archived :count proposals',
'restored_proposal' => 'Successfully restored proposal',
'restore_proposal' => 'Restore Proposal',
'snippet' => 'Snippet',
'snippets' => 'Snippets',
'proposal_snippet' => 'Snippet',
@ -2693,6 +2694,7 @@ $LANG = array(
'archived_proposal_snippets' => 'Successfully archived :count snippets',
'deleted_proposal_snippets' => 'Successfully archived :count snippets',
'restored_proposal_snippet' => 'Successfully restored snippet',
'restore_proposal_snippet' => 'Restore Snippet',
'template' => 'Template',
'templates' => 'Templates',
'proposal_template' => 'Template',
@ -2709,6 +2711,7 @@ $LANG = array(
'archived_proposal_templates' => 'Successfully archived :count templates',
'deleted_proposal_templates' => 'Successfully archived :count templates',
'restored_proposal_template' => 'Successfully restored template',
'restore_proposal_template' => 'Restore Template',
'proposal_category' => 'Category',
'proposal_categories' => 'Categories',
'new_proposal_category' => 'New Category',
@ -2723,6 +2726,7 @@ $LANG = array(
'archived_proposal_categories' => 'Successfully archived :count categories',
'deleted_proposal_categories' => 'Successfully archived :count categories',
'restored_proposal_category' => 'Successfully restored category',
'restore_proposal_category' => 'Restore Category',
'delete_status' => 'Delete Status',
'standard' => 'Standard',
'icon' => 'Icon',

View File

@ -128,7 +128,7 @@
var html = mergeTemplate(template.html);
// grapesjsEditor.CssComposer.getAll().reset();
grapesjsEditor.CssComposer.getAll().reset();
grapesjsEditor.setComponents(html);
grapesjsEditor.setStyle(template.css);
}

View File

@ -100,7 +100,10 @@
var template = customTemplateMap[templateId];
}
grapesjsEditor.CssComposer.getAll().reset();
grapesjsEditor.setComponents(template.html);
grapesjsEditor.setStyle(template.css);
$('.template-select').val(null).blur();
}