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