1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Log purged clients

This commit is contained in:
Hillel Coren 2018-04-26 10:28:50 +03:00
parent 9b1f5651c6
commit 54439ad4c6
2 changed files with 24 additions and 5 deletions

View File

@ -8,6 +8,7 @@ use App\Models\LookupAccount;
use DB;
use Exception;
use App\Libraries\HistoryUtils;
use Utils;
class PurgeClientData extends Job
{
@ -23,8 +24,24 @@ class PurgeClientData extends Job
*/
public function handle()
{
$invoices = $this->client->invoices()->withTrashed()->get();
$expenses = $this->client->expenses()->withTrashed()->get();
$user = auth()->user();
$client = $this->client;
$contact = $client->getPrimaryContact();
if (! $user->is_admin) {
return;
}
$message = sprintf('%s %s (%s) purged client: %s %s', date('Y-m-d h:i:s'), $user->email, request()->getClientIp(), $client->name, $contact->email);
if (config('app.log') == 'single') {
@file_put_contents(storage_path('logs/purged-clients.log'), $message, FILE_APPEND);
} else {
Utils::logError('[purged client] ' . $message);
}
$invoices = $client->invoices()->withTrashed()->get();
$expenses = $client->expenses()->withTrashed()->get();
foreach ($invoices as $invoice) {
foreach ($invoice->documents as $document) {

View File

@ -68,9 +68,11 @@
@if ($client->trashed())
@can('edit', $client)
{!! Button::danger(trans('texts.purge_client'))
->appendIcon(Icon::create('warning-sign'))
->withAttributes(['onclick' => 'onPurgeClick()']) !!}
@if (auth()->user()->is_admin)
{!! Button::danger(trans('texts.purge_client'))
->appendIcon(Icon::create('warning-sign'))
->withAttributes(['onclick' => 'onPurgeClick()']) !!}
@endif
{!! Button::primary(trans('texts.restore_client'))
->appendIcon(Icon::create('cloud-download'))
->withAttributes(['onclick' => 'onRestoreClick()']) !!}