mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-14 11:44:40 -04:00
Fix saving task without a client
This commit is contained in:
parent
3ae8df3fdf
commit
afb34d1de6
@ -1,7 +1,5 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Events\TaskWasCreated;
|
|
||||||
use App\Events\TaskWasUpdated;
|
|
||||||
use Auth;
|
use Auth;
|
||||||
use View;
|
use View;
|
||||||
use URL;
|
use URL;
|
||||||
@ -236,10 +234,8 @@ class TaskController extends BaseController
|
|||||||
|
|
||||||
if($publicId) {
|
if($publicId) {
|
||||||
Session::flash('message', trans('texts.updated_task'));
|
Session::flash('message', trans('texts.updated_task'));
|
||||||
event(new TaskWasUpdated($task));
|
|
||||||
} else {
|
} else {
|
||||||
Session::flash('message', trans('texts.created_task'));
|
Session::flash('message', trans('texts.created_task'));
|
||||||
event(new TaskWasCreated($task));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($action, ['invoice', 'add_to_invoice'])) {
|
if (in_array($action, ['invoice', 'add_to_invoice'])) {
|
||||||
|
@ -102,7 +102,7 @@ class Activity extends Eloquent
|
|||||||
$task = $this->task;
|
$task = $this->task;
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'client' => link_to($client->getRoute(), $client->getDisplayName()),
|
'client' => $client ? link_to($client->getRoute(), $client->getDisplayName()) : null,
|
||||||
'user' => $isSystem ? '<i>' . trans('texts.system') . '</i>' : $user->getDisplayName(),
|
'user' => $isSystem ? '<i>' . trans('texts.system') . '</i>' : $user->getDisplayName(),
|
||||||
'invoice' => $invoice ? link_to($invoice->getRoute(), $invoice->getDisplayName()) : null,
|
'invoice' => $invoice ? link_to($invoice->getRoute(), $invoice->getDisplayName()) : null,
|
||||||
'quote' => $invoice ? link_to($invoice->getRoute(), $invoice->getDisplayName()) : null,
|
'quote' => $invoice ? link_to($invoice->getRoute(), $invoice->getDisplayName()) : null,
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
use Utils;
|
use Utils;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Laracasts\Presenter\PresentableTrait;
|
use Laracasts\Presenter\PresentableTrait;
|
||||||
|
use App\Events\TaskWasCreated;
|
||||||
|
use App\Events\TaskWasUpdated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Task
|
* Class Task
|
||||||
@ -142,3 +144,12 @@ class Task extends EntityModel
|
|||||||
return "/tasks/{$this->public_id}/edit";
|
return "/tasks/{$this->public_id}/edit";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Task::created(function ($task) {
|
||||||
|
event(new TaskWasCreated($task));
|
||||||
|
});
|
||||||
|
|
||||||
|
Task::updated(function ($task) {
|
||||||
|
event(new TaskWasUpdated($task));
|
||||||
|
});
|
||||||
|
@ -20,14 +20,14 @@ class ActivityRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
// init activity and copy over context
|
// init activity and copy over context
|
||||||
$activity = self::getBlank($altEntity ?: $client);
|
$activity = self::getBlank($altEntity ?: ($client ?: $entity));
|
||||||
$activity = Utils::copyContext($activity, $entity);
|
$activity = Utils::copyContext($activity, $entity);
|
||||||
$activity = Utils::copyContext($activity, $altEntity);
|
$activity = Utils::copyContext($activity, $altEntity);
|
||||||
|
|
||||||
$activity->client_id = $client->id;
|
|
||||||
$activity->activity_type_id = $activityTypeId;
|
$activity->activity_type_id = $activityTypeId;
|
||||||
$activity->adjustment = $balanceChange;
|
$activity->adjustment = $balanceChange;
|
||||||
$activity->balance = $client->balance + $balanceChange;
|
$activity->client_id = $client ? $client->id : 0;
|
||||||
|
$activity->balance = $client ? ($client->balance + $balanceChange) : 0;
|
||||||
|
|
||||||
$keyField = $entity->getKeyField();
|
$keyField = $entity->getKeyField();
|
||||||
$activity->$keyField = $entity->id;
|
$activity->$keyField = $entity->id;
|
||||||
@ -35,7 +35,9 @@ class ActivityRepository
|
|||||||
$activity->ip = Request::getClientIp();
|
$activity->ip = Request::getClientIp();
|
||||||
$activity->save();
|
$activity->save();
|
||||||
|
|
||||||
$client->updateBalances($balanceChange, $paidToDateChange);
|
if ($client) {
|
||||||
|
$client->updateBalances($balanceChange, $paidToDateChange);
|
||||||
|
}
|
||||||
|
|
||||||
return $activity;
|
return $activity;
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ class SupportNewPricing extends Migration
|
|||||||
// https://github.com/invoiceninja/invoiceninja/pull/955
|
// https://github.com/invoiceninja/invoiceninja/pull/955
|
||||||
Schema::table('activities', function (Blueprint $table) {
|
Schema::table('activities', function (Blueprint $table) {
|
||||||
$table->integer('task_id')->after('invitation_id')->nullable();
|
$table->integer('task_id')->after('invitation_id')->nullable();
|
||||||
|
$table->dropForeign('activities_client_id_foreign');
|
||||||
});
|
});
|
||||||
|
|
||||||
// https://github.com/invoiceninja/invoiceninja/pull/950
|
// https://github.com/invoiceninja/invoiceninja/pull/950
|
||||||
|
Loading…
x
Reference in New Issue
Block a user