mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 02:14:35 -04:00
Fixes for Templates - Add Assigned User functionality (#3044)
* Request Cancellation * Add fields to settings * Recurring invoice cancellation request * change REST endpoint for entity_id templates
This commit is contained in:
parent
06a120e128
commit
97a4fb3696
@ -147,6 +147,11 @@ class Client extends BaseModel
|
|||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function country()
|
public function country()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Country::class);
|
return $this->belongsTo(Country::class);
|
||||||
|
@ -15,5 +15,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
|
|
||||||
class Credit extends BaseModel
|
class Credit extends BaseModel
|
||||||
{
|
{
|
||||||
//
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,9 @@ class Expense extends BaseModel
|
|||||||
{
|
{
|
||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,11 @@ class Invoice extends BaseModel
|
|||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function invitations()
|
public function invitations()
|
||||||
{
|
{
|
||||||
return $this->hasMany(InvoiceInvitation::class);
|
return $this->hasMany(InvoiceInvitation::class);
|
||||||
|
@ -77,6 +77,11 @@ class Payment extends BaseModel
|
|||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function documents()
|
public function documents()
|
||||||
{
|
{
|
||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
|
@ -50,6 +50,11 @@ class Product extends BaseModel
|
|||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function documents()
|
public function documents()
|
||||||
{
|
{
|
||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
|
@ -39,4 +39,9 @@ class Proposal extends BaseModel
|
|||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,11 @@ class Quote extends BaseModel
|
|||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function invitations()
|
public function invitations()
|
||||||
{
|
{
|
||||||
return $this->hasMany(QuoteInvitation::class);
|
return $this->hasMany(QuoteInvitation::class);
|
||||||
|
@ -110,6 +110,11 @@ class RecurringInvoice extends BaseModel
|
|||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function invoices()
|
public function invoices()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Invoice::class, "id", "recurring_invoice_id");
|
return $this->hasMany(Invoice::class, "id", "recurring_invoice_id");
|
||||||
|
@ -107,6 +107,11 @@ class RecurringQuote extends BaseModel
|
|||||||
return $this->belongsTo(User::class);
|
return $this->belongsTo(User::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
public function invitations()
|
public function invitations()
|
||||||
{
|
{
|
||||||
$this->morphMany(RecurringQuoteInvitation::class);
|
$this->morphMany(RecurringQuoteInvitation::class);
|
||||||
|
@ -45,4 +45,9 @@ class Task extends BaseModel
|
|||||||
return $this->morphMany(Document::class, 'documentable');
|
return $this->morphMany(Document::class, 'documentable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assigned_user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class ,'assigned_user_id', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ use Illuminate\Notifications\Notifiable;
|
|||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use Laracasts\Presenter\PresentableTrait;
|
use Laracasts\Presenter\PresentableTrait;
|
||||||
|
|
||||||
class User extends Authenticatable implements MustVerifyEmail
|
class User extends Authenticatable implements MustVerifyEmail
|
||||||
@ -141,7 +140,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
*/
|
*/
|
||||||
public function setCompany($company)
|
public function setCompany($company)
|
||||||
{
|
{
|
||||||
\Log::error('setting company');
|
|
||||||
$this->company = $company;
|
$this->company = $company;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,6 +279,19 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a boolean value if the user is assigned to the current Entity
|
||||||
|
*
|
||||||
|
* @param string Entity
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function assigned($entity) : bool
|
||||||
|
{
|
||||||
|
|
||||||
|
return ! empty($entity->assigned_user_id) && $entity->assigned_user_id == $this->id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flattens a stdClass representation of the User Permissions
|
* Flattens a stdClass representation of the User Permissions
|
||||||
* into a Collection
|
* into a Collection
|
||||||
@ -350,5 +361,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
return $this->email;
|
return $this->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ class EntityPolicy
|
|||||||
|
|
||||||
return ($user->isAdmin() && $entity->company_id == $user->companyId())
|
return ($user->isAdmin() && $entity->company_id == $user->companyId())
|
||||||
|| ($user->hasPermission('edit_' . strtolower(class_basename($entity))) && $entity->company_id == $user->companyId())
|
|| ($user->hasPermission('edit_' . strtolower(class_basename($entity))) && $entity->company_id == $user->companyId())
|
||||||
|| $user->owns($entity);
|
|| $user->owns($entity)
|
||||||
|
|| $user->assigned($entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +69,8 @@ class EntityPolicy
|
|||||||
|
|
||||||
return ($user->isAdmin() && $entity->company_id == $user->companyId())
|
return ($user->isAdmin() && $entity->company_id == $user->companyId())
|
||||||
|| ($user->hasPermission('view_' . strtolower(class_basename($entity))) && $entity->company_id == $user->companyId())
|
|| ($user->hasPermission('view_' . strtolower(class_basename($entity))) && $entity->company_id == $user->companyId())
|
||||||
|| $user->owns($entity);
|
|| $user->owns($entity)
|
||||||
|
|| $user->assigned($entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,6 +280,7 @@ class CreateUsersTable extends Migration
|
|||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->unsignedInteger('company_id')->index();
|
$table->unsignedInteger('company_id')->index();
|
||||||
$table->unsignedInteger('user_id')->index();
|
$table->unsignedInteger('user_id')->index();
|
||||||
|
$table->unsignedInteger('assigned_user_id')->nullable();
|
||||||
|
|
||||||
$table->string('name')->nullable();
|
$table->string('name')->nullable();
|
||||||
$table->string('website')->nullable();
|
$table->string('website')->nullable();
|
||||||
@ -412,6 +413,7 @@ class CreateUsersTable extends Migration
|
|||||||
$t->increments('id');
|
$t->increments('id');
|
||||||
$t->unsignedInteger('client_id')->index();
|
$t->unsignedInteger('client_id')->index();
|
||||||
$t->unsignedInteger('user_id');
|
$t->unsignedInteger('user_id');
|
||||||
|
$t->unsignedInteger('assigned_user_id')->nullable();
|
||||||
$t->unsignedInteger('company_id')->index();
|
$t->unsignedInteger('company_id')->index();
|
||||||
$t->unsignedInteger('status_id');
|
$t->unsignedInteger('status_id');
|
||||||
|
|
||||||
@ -478,6 +480,7 @@ class CreateUsersTable extends Migration
|
|||||||
$t->increments('id');
|
$t->increments('id');
|
||||||
$t->unsignedInteger('client_id')->index();
|
$t->unsignedInteger('client_id')->index();
|
||||||
$t->unsignedInteger('user_id');
|
$t->unsignedInteger('user_id');
|
||||||
|
$t->unsignedInteger('assigned_user_id')->nullable();
|
||||||
$t->unsignedInteger('company_id')->index();
|
$t->unsignedInteger('company_id')->index();
|
||||||
|
|
||||||
$t->unsignedInteger('status_id')->index();
|
$t->unsignedInteger('status_id')->index();
|
||||||
@ -541,6 +544,7 @@ class CreateUsersTable extends Migration
|
|||||||
$t->increments('id');
|
$t->increments('id');
|
||||||
$t->unsignedInteger('client_id')->index();
|
$t->unsignedInteger('client_id')->index();
|
||||||
$t->unsignedInteger('user_id');
|
$t->unsignedInteger('user_id');
|
||||||
|
$t->unsignedInteger('assigned_user_id')->nullable();
|
||||||
$t->unsignedInteger('company_id')->index();
|
$t->unsignedInteger('company_id')->index();
|
||||||
|
|
||||||
$t->unsignedInteger('status_id')->index();
|
$t->unsignedInteger('status_id')->index();
|
||||||
@ -602,6 +606,7 @@ class CreateUsersTable extends Migration
|
|||||||
$t->increments('id');
|
$t->increments('id');
|
||||||
$t->unsignedInteger('client_id')->index();
|
$t->unsignedInteger('client_id')->index();
|
||||||
$t->unsignedInteger('user_id');
|
$t->unsignedInteger('user_id');
|
||||||
|
$t->unsignedInteger('assigned_user_id')->nullable();
|
||||||
$t->unsignedInteger('company_id')->index();
|
$t->unsignedInteger('company_id')->index();
|
||||||
$t->unsignedInteger('status_id');
|
$t->unsignedInteger('status_id');
|
||||||
$t->unsignedInteger('design_id');
|
$t->unsignedInteger('design_id');
|
||||||
@ -708,6 +713,7 @@ class CreateUsersTable extends Migration
|
|||||||
$t->increments('id');
|
$t->increments('id');
|
||||||
$t->unsignedInteger('company_id')->index();
|
$t->unsignedInteger('company_id')->index();
|
||||||
$t->unsignedInteger('user_id');
|
$t->unsignedInteger('user_id');
|
||||||
|
$t->unsignedInteger('assigned_user_id')->nullable();
|
||||||
|
|
||||||
$t->string('custom_value1')->nullable();
|
$t->string('custom_value1')->nullable();
|
||||||
$t->string('custom_value2')->nullable();
|
$t->string('custom_value2')->nullable();
|
||||||
@ -743,6 +749,7 @@ class CreateUsersTable extends Migration
|
|||||||
$t->unsignedInteger('company_id')->index();
|
$t->unsignedInteger('company_id')->index();
|
||||||
$t->unsignedInteger('client_id')->index();
|
$t->unsignedInteger('client_id')->index();
|
||||||
$t->unsignedInteger('user_id')->nullable();
|
$t->unsignedInteger('user_id')->nullable();
|
||||||
|
$t->unsignedInteger('assigned_user_id')->nullable();
|
||||||
$t->unsignedInteger('client_contact_id')->nullable();
|
$t->unsignedInteger('client_contact_id')->nullable();
|
||||||
$t->unsignedInteger('invitation_id')->nullable();
|
$t->unsignedInteger('invitation_id')->nullable();
|
||||||
$t->unsignedInteger('company_gateway_id')->nullable();
|
$t->unsignedInteger('company_gateway_id')->nullable();
|
||||||
@ -784,6 +791,7 @@ class CreateUsersTable extends Migration
|
|||||||
Schema::create('tasks', function ($table) {
|
Schema::create('tasks', function ($table) {
|
||||||
$table->increments('id');
|
$table->increments('id');
|
||||||
$table->unsignedInteger('user_id');
|
$table->unsignedInteger('user_id');
|
||||||
|
$table->unsignedInteger('assigned_user_id')->nullable();
|
||||||
$table->unsignedInteger('company_id')->index();
|
$table->unsignedInteger('company_id')->index();
|
||||||
$table->unsignedInteger('client_id')->nullable();
|
$table->unsignedInteger('client_id')->nullable();
|
||||||
$table->unsignedInteger('invoice_id')->nullable();
|
$table->unsignedInteger('invoice_id')->nullable();
|
||||||
|
@ -84,7 +84,7 @@ Route::group(['middleware' => ['api_db','api_secret_check','token_auth'], 'prefi
|
|||||||
Route::post('refresh', 'Auth\LoginController@refresh');
|
Route::post('refresh', 'Auth\LoginController@refresh');
|
||||||
|
|
||||||
Route::get('templates/{entity}/create', 'TemplateController@create')->name('templates.create');
|
Route::get('templates/{entity}/create', 'TemplateController@create')->name('templates.create');
|
||||||
Route::get('templates/{entity}/{entity_id}', 'TemplateController@show')->name('templates.show');
|
Route::post('templates/{entity}/{entity_id}', 'TemplateController@show')->name('templates.show');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Route::resource('tasks', 'TaskController'); // name = (tasks. index / create / show / update / destroy / edit
|
Route::resource('tasks', 'TaskController'); // name = (tasks. index / create / show / update / destroy / edit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user