mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Proposals
This commit is contained in:
parent
09c6debbc9
commit
db6cc52faa
@ -360,6 +360,7 @@ class InitLookup extends Command
|
|||||||
DB::statement('truncate lookup_users');
|
DB::statement('truncate lookup_users');
|
||||||
DB::statement('truncate lookup_contacts');
|
DB::statement('truncate lookup_contacts');
|
||||||
DB::statement('truncate lookup_invitations');
|
DB::statement('truncate lookup_invitations');
|
||||||
|
DB::statement('truncate lookup_proposal_invitations');
|
||||||
DB::statement('truncate lookup_account_tokens');
|
DB::statement('truncate lookup_account_tokens');
|
||||||
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
|
DB::statement('SET FOREIGN_KEY_CHECKS = 1');
|
||||||
}
|
}
|
||||||
|
@ -134,4 +134,11 @@ class ProposalController extends BaseController
|
|||||||
|
|
||||||
return redirect()->to('/proposals');
|
return redirect()->to('/proposals');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function download(ProposalRequest $request)
|
||||||
|
{
|
||||||
|
$proposal = $request->entity();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ use Closure;
|
|||||||
use App\Models\LookupAccount;
|
use App\Models\LookupAccount;
|
||||||
use App\Models\LookupContact;
|
use App\Models\LookupContact;
|
||||||
use App\Models\LookupInvitation;
|
use App\Models\LookupInvitation;
|
||||||
|
use App\Models\LookupProposalInvitation;
|
||||||
use App\Models\LookupAccountToken;
|
use App\Models\LookupAccountToken;
|
||||||
use App\Models\LookupUser;
|
use App\Models\LookupUser;
|
||||||
use Auth;
|
use Auth;
|
||||||
@ -43,6 +44,8 @@ class DatabaseLookup
|
|||||||
} elseif ($guard == 'contact') {
|
} elseif ($guard == 'contact') {
|
||||||
if ($key = request()->invitation_key) {
|
if ($key = request()->invitation_key) {
|
||||||
LookupInvitation::setServerByField('invitation_key', $key);
|
LookupInvitation::setServerByField('invitation_key', $key);
|
||||||
|
} elseif ($key = request()->proposal_invitation_key) {
|
||||||
|
LookupProposalInvitation::setServerByField('invitation_key', $key);
|
||||||
} elseif ($key = request()->contact_key ?: session('contact_key')) {
|
} elseif ($key = request()->contact_key ?: session('contact_key')) {
|
||||||
LookupContact::setServerByField('contact_key', $key);
|
LookupContact::setServerByField('contact_key', $key);
|
||||||
} elseif ($key = request()->account_key) {
|
} elseif ($key = request()->account_key) {
|
||||||
|
@ -76,6 +76,7 @@ class PurgeAccountData extends Job
|
|||||||
$lookupAccount = LookupAccount::whereAccountKey($account->account_key)->firstOrFail();
|
$lookupAccount = LookupAccount::whereAccountKey($account->account_key)->firstOrFail();
|
||||||
DB::table('lookup_contacts')->where('lookup_account_id', '=', $lookupAccount->id)->delete();
|
DB::table('lookup_contacts')->where('lookup_account_id', '=', $lookupAccount->id)->delete();
|
||||||
DB::table('lookup_invitations')->where('lookup_account_id', '=', $lookupAccount->id)->delete();
|
DB::table('lookup_invitations')->where('lookup_account_id', '=', $lookupAccount->id)->delete();
|
||||||
|
DB::table('lookup_proposal_invitations')->where('lookup_account_id', '=', $lookupAccount->id)->delete();
|
||||||
|
|
||||||
config(['database.default' => $current]);
|
config(['database.default' => $current]);
|
||||||
}
|
}
|
||||||
|
47
app/Models/LookupProposalInvitation.php
Normal file
47
app/Models/LookupProposalInvitation.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Eloquent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ExpenseCategory.
|
||||||
|
*/
|
||||||
|
class LookupProposalInvitation extends LookupModel
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'lookup_account_id',
|
||||||
|
'invitation_key',
|
||||||
|
'message_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function updateInvitation($accountKey, $invitation)
|
||||||
|
{
|
||||||
|
if (! env('MULTI_DB_ENABLED')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $invitation->message_id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current = config('database.default');
|
||||||
|
config(['database.default' => DB_NINJA_LOOKUP]);
|
||||||
|
|
||||||
|
$lookupAccount = LookupAccount::whereAccountKey($accountKey)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$lookupInvitation = LookupProposalInvitation::whereLookupAccountId($lookupAccount->id)
|
||||||
|
->whereInvitationKey($invitation->invitation_key)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
$lookupInvitation->message_id = $invitation->message_id;
|
||||||
|
$lookupInvitation->save();
|
||||||
|
|
||||||
|
config(['database.default' => $current]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
//use App\Models\LookupProposalInvitation;
|
use App\Models\LookupProposalInvitation;
|
||||||
use App\Models\Traits\Inviteable;
|
use App\Models\Traits\Inviteable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +60,6 @@ class ProposalInvitation extends EntityModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
ProposalInvitation::creating(function ($invitation)
|
ProposalInvitation::creating(function ($invitation)
|
||||||
{
|
{
|
||||||
LookupProposalInvitation::createNew($invitation->account->account_key, [
|
LookupProposalInvitation::createNew($invitation->account->account_key, [
|
||||||
@ -68,7 +67,8 @@ ProposalInvitation::creating(function ($invitation)
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
ProposalInvitation::updating(function ($invitation) {
|
ProposalInvitation::updating(function ($invitation)
|
||||||
|
{
|
||||||
$dirty = $invitation->getDirty();
|
$dirty = $invitation->getDirty();
|
||||||
if (array_key_exists('message_id', $dirty)) {
|
if (array_key_exists('message_id', $dirty)) {
|
||||||
LookupProposalInvitation::updateInvitation($invitation->account->account_key, $invitation);
|
LookupProposalInvitation::updateInvitation($invitation->account->account_key, $invitation);
|
||||||
@ -83,4 +83,3 @@ ProposalInvitation::deleted(function ($invitation)
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
@ -128,6 +128,14 @@ class AddSubscriptionFormat extends Migration
|
|||||||
$table->unique(['account_id', 'public_id']);
|
$table->unique(['account_id', 'public_id']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Schema::create('lookup_proposal_invitations', function ($table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->unsignedInteger('lookup_account_id')->index();
|
||||||
|
$table->string('invitation_key')->unique();
|
||||||
|
$table->string('message_id')->nullable()->unique();
|
||||||
|
|
||||||
|
$table->foreign('lookup_account_id')->references('id')->on('lookup_accounts')->onDelete('cascade');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,5 +158,6 @@ class AddSubscriptionFormat extends Migration
|
|||||||
Schema::dropIfExists('proposal_snippets');
|
Schema::dropIfExists('proposal_snippets');
|
||||||
Schema::dropIfExists('proposal_categories');
|
Schema::dropIfExists('proposal_categories');
|
||||||
Schema::dropIfExists('proposal_invitations');
|
Schema::dropIfExists('proposal_invitations');
|
||||||
|
Schema::dropIfExists('lookup_proposal_invitations');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,10 @@
|
|||||||
->appendIcon(Icon::create('remove-circle'))
|
->appendIcon(Icon::create('remove-circle'))
|
||||||
->asLinkTo(HTMLUtils::previousUrl('/proposals')) !!}
|
->asLinkTo(HTMLUtils::previousUrl('/proposals')) !!}
|
||||||
|
|
||||||
|
{!! Button::primary(trans('texts.download_pdf'))
|
||||||
|
->withAttributes(['onclick' => 'onDownloadClick()'])
|
||||||
|
->appendIcon(Icon::create('download-alt')) !!}
|
||||||
|
|
||||||
{!! Button::success(trans("texts.save"))
|
{!! Button::success(trans("texts.save"))
|
||||||
->submit()
|
->submit()
|
||||||
->appendIcon(Icon::create('floppy-disk')) !!}
|
->appendIcon(Icon::create('floppy-disk')) !!}
|
||||||
@ -86,6 +90,10 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onDownloadClick() {
|
||||||
|
location.href = "{{ url("/proposals/{$proposal->public_id}/download") }}";
|
||||||
|
}
|
||||||
|
|
||||||
function loadTemplate() {
|
function loadTemplate() {
|
||||||
var templateId = $('select#proposal_template_id').val();
|
var templateId = $('select#proposal_template_id').val();
|
||||||
var template = templateMap[templateId];
|
var template = templateMap[templateId];
|
||||||
@ -164,7 +172,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var invoiceId = {{ ! empty($invoicePublicId) ? $invoicePublicId : 0 }};
|
var invoiceId = {{ ! empty($invoicePublicId) ? $invoicePublicId : 0 }};
|
||||||
var $invoiceSelect = $('select#invoice_id');
|
var $invoiceSelect = $('select#invoice_id');
|
||||||
|
@ -227,6 +227,7 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
|
|||||||
|
|
||||||
Route::post('proposals/bulk', 'ProposalController@bulk');
|
Route::post('proposals/bulk', 'ProposalController@bulk');
|
||||||
Route::get('proposals/{proposals}/edit', 'ProposalController@edit');
|
Route::get('proposals/{proposals}/edit', 'ProposalController@edit');
|
||||||
|
Route::get('proposals/{proposals}/download', 'ProposalController@download');
|
||||||
Route::get('proposals/create/{invoice_id?}/{proposal_template_id?}', 'ProposalController@create');
|
Route::get('proposals/create/{invoice_id?}/{proposal_template_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