mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-08 14:34:36 -04:00
Proposals
This commit is contained in:
parent
21b23a93cf
commit
e822ec04b3
@ -62,7 +62,7 @@ class ProposalController extends BaseController
|
|||||||
'title' => trans('texts.new_proposal'),
|
'title' => trans('texts.new_proposal'),
|
||||||
'invoices' => Invoice::scope()->with('client.contacts')->unapprovedQuotes()->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->invoice_id,
|
||||||
];
|
];
|
||||||
|
|
||||||
return View::make('proposals.edit', $data);
|
return View::make('proposals.edit', $data);
|
||||||
|
@ -2,7 +2,33 @@
|
|||||||
|
|
||||||
namespace App\Http\Requests;
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use App\Models\ProposalCategory;
|
||||||
|
|
||||||
class ProposalSnippetRequest extends EntityRequest
|
class ProposalSnippetRequest extends EntityRequest
|
||||||
{
|
{
|
||||||
protected $entityType = ENTITY_PROPOSAL_SNIPPET;
|
protected $entityType = ENTITY_PROPOSAL_SNIPPET;
|
||||||
|
|
||||||
|
public function sanitize()
|
||||||
|
{
|
||||||
|
$input = $this->all();
|
||||||
|
|
||||||
|
// check if we're creating a new proposal category
|
||||||
|
if ($this->proposal_category_id == '-1') {
|
||||||
|
$data = [
|
||||||
|
'name' => trim($this->proposal_category_name)
|
||||||
|
];
|
||||||
|
if (ProposalCategory::validate($data) === true) {
|
||||||
|
$category = app('App\Ninja\Repositories\ProposalCategoryRepository')->save($data);
|
||||||
|
$input['proposal_category_id'] = $category->id;
|
||||||
|
} else {
|
||||||
|
$input['proposal_category_id'] = null;
|
||||||
|
}
|
||||||
|
} elseif ($this->proposal_category_id) {
|
||||||
|
$input['proposal_category_id'] = ProposalCategory::getPrivateId($this->proposal_category_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->replace($input);
|
||||||
|
|
||||||
|
return $this->all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
return "javascript:submitForm_{$entityType}('markSent', {$model->public_id})";
|
return "javascript:submitForm_{$entityType}('markSent', {$model->public_id})";
|
||||||
},
|
},
|
||||||
function ($model) {
|
function ($model) {
|
||||||
return $model->invoice_status_id < INVOICE_STATUS_SENT && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
return ! $model->is_public && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -167,6 +167,15 @@ class InvoiceDatatable extends EntityDatatable
|
|||||||
return $entityType == ENTITY_QUOTE && $model->quote_invoice_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
return $entityType == ENTITY_QUOTE && $model->quote_invoice_id && Auth::user()->can('editByOwner', [ENTITY_INVOICE, $model->user_id]);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
trans('texts.new_proposal'),
|
||||||
|
function ($model) {
|
||||||
|
return URL::to("proposals/create/{$model->public_id}");
|
||||||
|
},
|
||||||
|
function ($model) use ($entityType) {
|
||||||
|
return $entityType == ENTITY_QUOTE && ! $model->quote_invoice_id && $model->invoice_status_id < INVOICE_STATUS_APPROVED && Auth::user()->can('create', ENTITY_PROPOSAL);
|
||||||
|
},
|
||||||
|
],
|
||||||
[
|
[
|
||||||
trans('texts.convert_to_invoice'),
|
trans('texts.convert_to_invoice'),
|
||||||
function ($model) {
|
function ($model) {
|
||||||
|
@ -261,6 +261,9 @@ class InvoicePresenter extends EntityPresenter
|
|||||||
if ($invoice->quote_invoice_id) {
|
if ($invoice->quote_invoice_id) {
|
||||||
$actions[] = ['url' => url("invoices/{$invoice->quote_invoice_id}/edit"), 'label' => trans('texts.view_invoice')];
|
$actions[] = ['url' => url("invoices/{$invoice->quote_invoice_id}/edit"), 'label' => trans('texts.view_invoice')];
|
||||||
} else {
|
} else {
|
||||||
|
if (! $invoice->isApproved()) {
|
||||||
|
$actions[] = ['url' => url("proposals/create/{$invoice->public_id}"), 'label' => trans('texts.new_proposal')];
|
||||||
|
}
|
||||||
$actions[] = ['url' => 'javascript:onConvertClick()', 'label' => trans('texts.convert_to_invoice')];
|
$actions[] = ['url' => 'javascript:onConvertClick()', 'label' => trans('texts.convert_to_invoice')];
|
||||||
}
|
}
|
||||||
} elseif ($entityType == ENTITY_INVOICE) {
|
} elseif ($entityType == ENTITY_INVOICE) {
|
||||||
|
@ -2726,6 +2726,7 @@ $LANG = array(
|
|||||||
'standard' => 'Standard',
|
'standard' => 'Standard',
|
||||||
'icon' => 'Icon',
|
'icon' => 'Icon',
|
||||||
'proposal_not_found' => 'The requested proposal is not available',
|
'proposal_not_found' => 'The requested proposal is not available',
|
||||||
|
'create_proposal_category' => 'Create category',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -80,6 +80,9 @@
|
|||||||
$(function() {
|
$(function() {
|
||||||
var categoryId = {{ $categoryPublicId ?: 0 }};
|
var categoryId = {{ $categoryPublicId ?: 0 }};
|
||||||
var $proposal_categorySelect = $('select#proposal_category_id');
|
var $proposal_categorySelect = $('select#proposal_category_id');
|
||||||
|
@if (Auth::user()->can('create', ENTITY_PROPOSAL_CATEGORY))
|
||||||
|
$proposal_categorySelect.append(new Option("{{ trans('texts.create_proposal_category') }}: $name", '-1'));
|
||||||
|
@endif
|
||||||
for (var i = 0; i < categories.length; i++) {
|
for (var i = 0; i < categories.length; i++) {
|
||||||
var category = categories[i];
|
var category = categories[i];
|
||||||
categoryMap[category.public_id] = category;
|
categoryMap[category.public_id] = category;
|
||||||
|
@ -226,7 +226,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
|
|||||||
|
|
||||||
Route::post('proposals/proposals/bulk', 'ProposalController@bulk');
|
Route::post('proposals/proposals/bulk', 'ProposalController@bulk');
|
||||||
Route::get('proposals/{proposals}/edit', 'ProposalController@edit');
|
Route::get('proposals/{proposals}/edit', 'ProposalController@edit');
|
||||||
Route::get('proposals/create/{quote_id?}', 'ProposalController@create');
|
Route::get('proposals/create/{invoice_id?}', 'ProposalController@create');
|
||||||
Route::resource('proposals', 'ProposalController');
|
Route::resource('proposals', 'ProposalController');
|
||||||
Route::get('api/proposals', 'ProposalController@getDatatable');
|
Route::get('api/proposals', 'ProposalController@getDatatable');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user