1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00

Working on proposals

This commit is contained in:
Hillel Coren 2018-01-31 14:21:33 +02:00
parent f45c39d6f4
commit d649fc84a1
14 changed files with 291 additions and 6 deletions

View File

@ -53,7 +53,7 @@ class ProposalCategoryController extends BaseController
{
$data = [
'account' => auth()->user()->account,
'proposalCategory' => null,
'category' => null,
'method' => 'POST',
'url' => 'proposals/categories',
'title' => trans('texts.new_proposal_category'),
@ -71,7 +71,7 @@ class ProposalCategoryController extends BaseController
$data = [
'account' => auth()->user()->account,
'proposalCategory' => $proposalCategory,
'category' => $proposalCategory,
'method' => 'PUT',
'url' => 'proposals/categories/' . $proposalCategory->public_id,
'title' => trans('texts.edit_proposal_category'),

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
class CreateProposalCategoryRequest extends ProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->can('create', ENTITY_PROPOSAL_CATEGORY);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
];
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
class CreateProposalRequest extends ProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->can('create', ENTITY_PROPOSAL);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'quote_id' => 'required',
'template_id' => 'required',
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
class CreateProposalSnippetRequest extends ProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->can('create', ENTITY_PROPOSAL_SNIPPET);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
class CreateProposalTemplateRequest extends ProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->user()->can('create', ENTITY_PROPOSAL_TEMPLATE);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests;
class UpdateProposalCategoryRequest extends ProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->entity() && $this->user()->can('edit', $this->entity());
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if (! $this->entity()) {
return [];
}
return [
'name' => 'required',
];
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Http\Requests;
class UpdateProposalRequest extends ProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->entity() && $this->user()->can('edit', $this->entity());
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if (! $this->entity()) {
return [];
}
return [
'quote_id' => 'required',
'template_id' => 'required',
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests;
class UpdateProposalSnippetRequest extends ProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->entity() && $this->user()->can('edit', $this->entity());
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if (! $this->entity()) {
return [];
}
return [
'name' => 'required',
];
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Http\Requests;
class UpdateProposalTemplateRequest extends ProjectRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return $this->entity() && $this->user()->can('edit', $this->entity());
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
if (! $this->entity()) {
return [];
}
return [
'name' => 'required',
];
}
}

View File

@ -22,6 +22,7 @@ class ProposalCategory extends EntityModel
* @var array
*/
protected $fillable = [
'name',
];
/**
@ -42,7 +43,7 @@ class ProposalCategory extends EntityModel
*/
public function getRoute()
{
return "/proposal_categories/{$this->public_id}";
return "/proposals/categories/{$this->public_id}";
}
/**

View File

@ -42,7 +42,7 @@ class ProposalSnippet extends EntityModel
*/
public function getRoute()
{
return "/proposal_snippets/{$this->public_id}";
return "/proposals/snippets/{$this->public_id}";
}
/**

View File

@ -42,7 +42,7 @@ class ProposalTemplate extends EntityModel
*/
public function getRoute()
{
return "/proposal_templates/{$this->public_id}";
return "/proposals/templates/{$this->public_id}";
}
/**

View File

@ -62,7 +62,7 @@ class ProposalCategoryRepository extends BaseRepository
public function save($input, $proposal = false)
{
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
$publicId = isset($input['public_id']) ? $input['public_id'] : false;
if (! $proposal) {
$proposal = ProposalCategory::createNew();

View File

@ -3,5 +3,47 @@
@section('content')
{!! Former::open($url)
->addClass('col-lg-10 col-lg-offset-1 warn-on-exit')
->method($method)
->rules([
'name' => 'required',
]) !!}
@if ($category)
{!! Former::populate($category) !!}
@endif
<span style="display:none">
{!! Former::text('public_id') !!}
</span>
<div class="row">
<div class="col-lg-10 col-lg-offset-1">
<div class="panel panel-default">
<div class="panel-body">
{!! Former::text('name') !!}
</div>
</div>
</div>
</div>
<center class="buttons">
{!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(HTMLUtils::previousUrl('/expense_categories'))->appendIcon(Icon::create('remove-circle')) !!}
{!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!}
</center>
{!! Former::close() !!}
<script>
$(function() {
$('#name').focus();
});
</script>
@stop