1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Working on proposals

This commit is contained in:
Hillel Coren 2018-01-31 16:33:33 +02:00
parent d649fc84a1
commit 0708d1a4aa
8 changed files with 43 additions and 34 deletions

View File

@ -65,6 +65,13 @@ class ProposalCategoryController extends BaseController
return View::make('proposals/categories.edit', $data);
}
public function show($publicId)
{
Session::reflash();
return redirect("proposals/categories/$publicId/edit");
}
public function edit(ProposalCategoryRequest $request)
{
$proposalCategory = $request->entity();
@ -75,8 +82,6 @@ class ProposalCategoryController extends BaseController
'method' => 'PUT',
'url' => 'proposals/categories/' . $proposalCategory->public_id,
'title' => trans('texts.edit_proposal_category'),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
'clientPublicId' => $proposalCategory->client ? $proposalCategory->client->public_id : null,
];
return View::make('proposals/categories.edit', $data);

View File

@ -66,6 +66,13 @@ class ProposalController extends BaseController
return View::make('proposals.edit', $data);
}
public function show($publicId)
{
Session::reflash();
return redirect("proposals/$publicId/edit");
}
public function edit(ProposalRequest $request)
{
$proposal = $request->entity();

View File

@ -65,6 +65,13 @@ class ProposalSnippetController extends BaseController
return View::make('proposals/snippets/edit', $data);
}
public function show($publicId)
{
Session::reflash();
return redirect("proposals/snippets/$publicId/edit");
}
public function edit(ProposalSnippetRequest $request)
{
$proposalSnippet = $request->entity();

View File

@ -65,6 +65,13 @@ class ProposalTemplateController extends BaseController
return View::make('proposals/templates/edit', $data);
}
public function show($publicId)
{
Session::reflash();
return redirect("proposals/templates/$publicId/edit");
}
public function edit(ProposalTemplateRequest $request)
{
$proposalTemplate = $request->entity();

View File

@ -29,7 +29,7 @@ class ProposalCategoryDatatable extends EntityDatatable
[
trans('texts.edit_category'),
function ($model) {
return URL::to("proposal_categories/{$model->public_id}/edit");
return URL::to("proposals/categories/{$model->public_id}/edit");
},
function ($model) {
return Auth::user()->can('editByOwner', [ENTITY_PROPOSAL_CATEGORY, $model->user_id]);

View File

@ -23,40 +23,22 @@ class ProposalCategoryRepository extends BaseRepository
{
$query = DB::table('proposal_categories')
->where('proposal_categories.account_id', '=', Auth::user()->account_id)
->leftjoin('invoices', 'invoices.id', '=', 'proposal_categories.quote_id')
->leftjoin('clients', 'clients.id', '=', 'invoices.client_id')
->leftJoin('contacts', 'contacts.client_id', '=', 'clients.id')
->where('clients.deleted_at', '=', null)
->where('contacts.deleted_at', '=', null)
->where('contacts.is_primary', '=', true)
->select(
'proposal_categories.name as proposal',
'proposal_categories.name',
'proposal_categories.public_id',
'proposal_categories.user_id',
'proposal_categories.deleted_at',
'proposal_categories.is_deleted',
'proposal_categories.private_notes',
DB::raw("COALESCE(NULLIF(clients.name,''), NULLIF(CONCAT(contacts.first_name, ' ', contacts.last_name),''), NULLIF(contacts.email,'')) client_name"),
'clients.user_id as client_user_id',
'clients.public_id as client_public_id'
'proposal_categories.is_deleted'
);
$this->applyFilters($query, ENTITY_PROPOSAL_CATEGORY);
if ($filter) {
$query->where(function ($query) use ($filter) {
$query->where('clients.name', 'like', '%'.$filter.'%')
->orWhere('contacts.first_name', 'like', '%'.$filter.'%')
->orWhere('contacts.last_name', 'like', '%'.$filter.'%')
->orWhere('contacts.email', 'like', '%'.$filter.'%')
->orWhere('proposal_categories.name', 'like', '%'.$filter.'%');
$query->Where('proposal_categories.name', 'like', '%'.$filter.'%');
});
}
if ($userId) {
$query->where('proposal_categories.user_id', '=', $userId);
}
return $query;
}

View File

@ -34,10 +34,10 @@ class AuthServiceProvider extends ServiceProvider
\App\Models\PaymentTerm::class => \App\Policies\PaymentTermPolicy::class,
\App\Models\Project::class => \App\Policies\ProjectPolicy::class,
\App\Models\AccountGatewayToken::class => \App\Policies\CustomerPolicy::class,
\App\Models\Proposal::class => \App\Policies\Proposal::class,
\App\Models\ProposalSnippet::class => \App\Policies\ProposalSnippet::class,
\App\Models\ProposalTemplate::class => \App\Policies\ProposalTemplate::class,
\App\Models\ProposalCategory::class => \App\Policies\ProposalCategory::class,
\App\Models\Proposal::class => \App\Policies\ProposalPolicy::class,
\App\Models\ProposalSnippet::class => \App\Policies\ProposalSnippetPolicy::class,
\App\Models\ProposalTemplate::class => \App\Policies\ProposalTemplatePolicy::class,
\App\Models\ProposalCategory::class => \App\Policies\ProposalCategoryPolicy::class,
];
/**

View File

@ -205,18 +205,19 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
Route::get('api/quotes/{client_id?}', 'QuoteController@getDatatable');
Route::post('quotes/bulk', 'QuoteController@bulk');
Route::get('proposals/categories/{proposal_categories}/edit', 'ProposalCategoryController@edit');
Route::get('proposals/categories/create', 'ProposalCategoryController@create');
Route::resource('proposals/categories', 'ProposalCategoryController');
Route::get('api/proposal/categories', 'ProposalCategoryController@getDatatable');
Route::get('api/proposal_categories', 'ProposalCategoryController@getDatatable');
Route::get('proposals/snippets/{proposal_snippets}/edit', 'ProposalSnippetController@edit');
Route::get('proposals/snippets/create', 'ProposalSnippetController@create');
Route::resource('proposals/snippets', 'ProposalSnippetController');
Route::get('api/proposal/snippets', 'ProposalSnippetController@getDatatable');
Route::get('api/proposal_snippets', 'ProposalSnippetController@getDatatable');
Route::get('proposals/templates/{proposal_templates}/edit', 'ProposalTemplateController@edit');
Route::get('proposals/templates/create', 'ProposalTemplateController@create');
Route::resource('proposals/templates', 'ProposalTemplateController');
Route::get('api/proposals/templates', 'ProposalTemplateController@getDatatable');
Route::get('api/proposal_templates', 'ProposalTemplateController@getDatatable');
Route::get('proposals/{proposals}/edit', 'ProposalController@edit');
Route::get('proposals/create/{quote_id?}', 'ProposalController@create');
Route::resource('proposals', 'ProposalController');
Route::get('api/proposals', 'ProposalController@getDatatable');