mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-06 02:34:37 -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;
|
||||
|
||||
use App\Events\TaskWasCreated;
|
||||
use App\Events\TaskWasUpdated;
|
||||
use Auth;
|
||||
use View;
|
||||
use URL;
|
||||
@ -236,10 +234,8 @@ class TaskController extends BaseController
|
||||
|
||||
if($publicId) {
|
||||
Session::flash('message', trans('texts.updated_task'));
|
||||
event(new TaskWasUpdated($task));
|
||||
} else {
|
||||
Session::flash('message', trans('texts.created_task'));
|
||||
event(new TaskWasCreated($task));
|
||||
}
|
||||
|
||||
if (in_array($action, ['invoice', 'add_to_invoice'])) {
|
||||
|
@ -102,7 +102,7 @@ class Activity extends Eloquent
|
||||
$task = $this->task;
|
||||
|
||||
$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(),
|
||||
'invoice' => $invoice ? link_to($invoice->getRoute(), $invoice->getDisplayName()) : null,
|
||||
'quote' => $invoice ? link_to($invoice->getRoute(), $invoice->getDisplayName()) : null,
|
||||
|
@ -3,6 +3,8 @@
|
||||
use Utils;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Laracasts\Presenter\PresentableTrait;
|
||||
use App\Events\TaskWasCreated;
|
||||
use App\Events\TaskWasUpdated;
|
||||
|
||||
/**
|
||||
* Class Task
|
||||
@ -142,3 +144,12 @@ class Task extends EntityModel
|
||||
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
|
||||
$activity = self::getBlank($altEntity ?: $client);
|
||||
$activity = self::getBlank($altEntity ?: ($client ?: $entity));
|
||||
$activity = Utils::copyContext($activity, $entity);
|
||||
$activity = Utils::copyContext($activity, $altEntity);
|
||||
|
||||
$activity->client_id = $client->id;
|
||||
$activity->activity_type_id = $activityTypeId;
|
||||
$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();
|
||||
$activity->$keyField = $entity->id;
|
||||
@ -35,7 +35,9 @@ class ActivityRepository
|
||||
$activity->ip = Request::getClientIp();
|
||||
$activity->save();
|
||||
|
||||
if ($client) {
|
||||
$client->updateBalances($balanceChange, $paidToDateChange);
|
||||
}
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class SupportNewPricing extends Migration
|
||||
// https://github.com/invoiceninja/invoiceninja/pull/955
|
||||
Schema::table('activities', function (Blueprint $table) {
|
||||
$table->integer('task_id')->after('invitation_id')->nullable();
|
||||
$table->dropForeign('activities_client_id_foreign');
|
||||
});
|
||||
|
||||
// https://github.com/invoiceninja/invoiceninja/pull/950
|
||||
|
Loading…
x
Reference in New Issue
Block a user