mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Proposals
This commit is contained in:
parent
59ffd9c6f8
commit
7618053c60
@ -59,6 +59,7 @@ class ProposalSnippetController extends BaseController
|
||||
'url' => 'proposals/snippets',
|
||||
'title' => trans('texts.new_proposal_snippet'),
|
||||
'categories' => ProposalCategory::scope()->orderBy('name')->get(),
|
||||
'categoryPublicId' => 0,
|
||||
];
|
||||
|
||||
return View::make('proposals/snippets/edit', $data);
|
||||
@ -82,6 +83,7 @@ class ProposalSnippetController extends BaseController
|
||||
'url' => 'proposals/snippets/' . $proposalSnippet->public_id,
|
||||
'title' => trans('texts.edit_proposal_snippet'),
|
||||
'categories' => ProposalCategory::scope()->orderBy('name')->get(),
|
||||
'categoryPublicId' => $proposalSnippet->proposal_category ? $proposalSnippet->proposal_category->public_id : null,
|
||||
];
|
||||
|
||||
return View::make('proposals/snippets.edit', $data);
|
||||
|
@ -50,6 +50,10 @@ class PurgeAccountData extends Job
|
||||
'vendors',
|
||||
'contacts',
|
||||
'clients',
|
||||
'proposals',
|
||||
'proposal_templates',
|
||||
'proposal_snippets',
|
||||
'proposal_categories',
|
||||
];
|
||||
|
||||
foreach ($tables as $table) {
|
||||
|
@ -24,6 +24,7 @@ class ProposalSnippet extends EntityModel
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'private_notes',
|
||||
'proposal_category_id',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -55,6 +56,14 @@ class ProposalSnippet extends EntityModel
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function proposal_category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\ProposalCategory')->withTrashed();
|
||||
}
|
||||
|
||||
public function getDisplayName()
|
||||
{
|
||||
return $this->name;
|
||||
|
@ -22,7 +22,7 @@ class ProposalSnippetDatatable extends EntityDatatable
|
||||
}
|
||||
|
||||
return link_to("proposal_snippets/{$model->public_id}", $model->name)->toHtml();
|
||||
//$str = link_to("quotes/{$model->quote_public_id}", $model->quote_number)->toHtml();
|
||||
//$str = link_to("proposal_snippets/{$model->public_id}", $model->name)->toHtml();
|
||||
//return $this->addNote($str, $model->private_notes);
|
||||
},
|
||||
],
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Ninja\Repositories;
|
||||
|
||||
use App\Models\ProposalSnippet;
|
||||
use App\Models\ProposalCategory;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Utils;
|
||||
@ -22,13 +23,8 @@ class ProposalSnippetRepository extends BaseRepository
|
||||
public function find($filter = null, $userId = false)
|
||||
{
|
||||
$query = DB::table('proposal_snippets')
|
||||
->leftjoin('proposal_categories', 'proposal_categories.id', '=', 'proposal_snippets.proposal_category_id')
|
||||
->where('proposal_snippets.account_id', '=', Auth::user()->account_id)
|
||||
->leftjoin('invoices', 'invoices.id', '=', 'proposal_snippets.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_snippets.name as proposal',
|
||||
'proposal_snippets.public_id',
|
||||
@ -36,9 +32,7 @@ class ProposalSnippetRepository extends BaseRepository
|
||||
'proposal_snippets.deleted_at',
|
||||
'proposal_snippets.is_deleted',
|
||||
'proposal_snippets.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.name'
|
||||
);
|
||||
|
||||
$this->applyFilters($query, ENTITY_PROPOSAL_SNIPPET);
|
||||
@ -69,6 +63,11 @@ class ProposalSnippetRepository extends BaseRepository
|
||||
}
|
||||
|
||||
$proposal->fill($input);
|
||||
|
||||
if (isset($input['proposal_category_id'])) {
|
||||
$proposal->proposal_category_id = $input['proposal_category_id'] ? ProposalCategory::getPrivateId($input['proposal_category_id']) : null;
|
||||
}
|
||||
|
||||
$proposal->save();
|
||||
|
||||
return $proposal;
|
||||
|
@ -651,7 +651,7 @@ class ImportService
|
||||
$this->checkForFile($fileName);
|
||||
$file = file_get_contents($fileName);
|
||||
$data = array_map("str_getcsv", preg_split('/\r*\n+|\r+/', $file));
|
||||
|
||||
dd($data);
|
||||
if (count($data) > 0) {
|
||||
$headers = $data[0];
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
->id('mainForm')
|
||||
->rules([
|
||||
'name' => 'required',
|
||||
'category_id' => 'required',
|
||||
'proposal_category_id' => 'required',
|
||||
]) !!}
|
||||
|
||||
@if ($snippet)
|
||||
@ -43,7 +43,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{!! Former::text('name') !!}
|
||||
{!! Former::select('category_id')->addOption('', '')
|
||||
{!! Former::select('proposal_category_id')->addOption('', '')
|
||||
->label(trans('texts.category'))
|
||||
->addGroupClass('category-select') !!}
|
||||
</div>
|
||||
@ -81,14 +81,18 @@
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
var $proposal_categorySelect = $('select#category_id');
|
||||
var categoryId = {{ $categoryPublicId ?: 0 }};
|
||||
var $proposal_categorySelect = $('select#proposal_category_id');
|
||||
for (var i = 0; i < categories.length; i++) {
|
||||
var category = categories[i];
|
||||
categoryMap[category.public_id] = category;
|
||||
$proposal_categorySelect.append(new Option(category.name, category.public_id));
|
||||
}
|
||||
@include('partials/entity_combobox', ['entityType' => ENTITY_PROPOSAL_CATEGORY])
|
||||
if (categoryId) {
|
||||
var category = categoryMap[categoryId];
|
||||
setComboboxValue($('.category-select'), category.public_id, category.name);
|
||||
}
|
||||
|
||||
var editor = grapesjs.init({
|
||||
container : '#gjs',
|
||||
|
Loading…
Reference in New Issue
Block a user