mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 22:24:34 -04:00
Additions for hosted
This commit is contained in:
parent
f1601f6339
commit
acb756b229
@ -14,6 +14,7 @@ namespace App\Http\Requests\Expense;
|
|||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
use App\Http\ValidationRules\Expense\UniqueExpenseNumberRule;
|
use App\Http\ValidationRules\Expense\UniqueExpenseNumberRule;
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
|
use App\Models\Project;
|
||||||
use App\Models\PurchaseOrder;
|
use App\Models\PurchaseOrder;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
@ -65,13 +66,29 @@ class StoreExpenseRequest extends Request
|
|||||||
$input['color'] = '';
|
$input['color'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Ensure the project is related */
|
||||||
|
if (array_key_exists('project_id', $input) && isset($input['project_id'])) {
|
||||||
|
$project = Project::withTrashed()->find($input['project_id'])->company()->first();
|
||||||
|
|
||||||
|
if($project){
|
||||||
|
$input['client_id'] = $project->client_id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unset($input['project_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages()
|
public function messages()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'unique' => ctrans('validation.unique', ['attribute' => 'email']),
|
// 'unique' => ctrans('validation.unique', ['attribute' => 'number']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Http\Requests\Expense;
|
namespace App\Http\Requests\Expense;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Project;
|
||||||
use App\Utils\Traits\ChecksEntityStatus;
|
use App\Utils\Traits\ChecksEntityStatus;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
@ -35,10 +36,7 @@ class UpdateExpenseRequest extends Request
|
|||||||
{
|
{
|
||||||
/* Ensure we have a client name, and that all emails are unique*/
|
/* Ensure we have a client name, and that all emails are unique*/
|
||||||
$rules = [];
|
$rules = [];
|
||||||
// $rules['country_id'] = 'integer|nullable';
|
|
||||||
|
|
||||||
// $rules['contacts.*.email'] = 'nullable|distinct';
|
|
||||||
|
|
||||||
if (isset($this->number)) {
|
if (isset($this->number)) {
|
||||||
$rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id)->ignore($this->expense->id);
|
$rules['number'] = Rule::unique('expenses')->where('company_id', auth()->user()->company()->id)->ignore($this->expense->id);
|
||||||
}
|
}
|
||||||
@ -46,16 +44,6 @@ class UpdateExpenseRequest extends Request
|
|||||||
return $this->globalRules($rules);
|
return $this->globalRules($rules);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function messages()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'unique' => ctrans('validation.unique', ['attribute' => 'email']),
|
|
||||||
'email' => ctrans('validation.email', ['attribute' => 'email']),
|
|
||||||
'name.required' => ctrans('validation.required', ['attribute' => 'name']),
|
|
||||||
'required' => ctrans('validation.required', ['attribute' => 'email']),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function prepareForValidation()
|
public function prepareForValidation()
|
||||||
{
|
{
|
||||||
$input = $this->all();
|
$input = $this->all();
|
||||||
@ -74,6 +62,20 @@ class UpdateExpenseRequest extends Request
|
|||||||
$input['currency_id'] = (string) auth()->user()->company()->settings->currency_id;
|
$input['currency_id'] = (string) auth()->user()->company()->settings->currency_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure the project is related */
|
||||||
|
if (array_key_exists('project_id', $input) && isset($input['project_id'])) {
|
||||||
|
$project = Project::withTrashed()->find($input['project_id'])->company()->first();
|
||||||
|
|
||||||
|
if($project){
|
||||||
|
$input['client_id'] = $project->client_id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unset($input['project_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$this->replace($input);
|
$this->replace($input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
89
app/Notifications/Ninja/UserQualityNotification.php
Normal file
89
app/Notifications/Ninja/UserQualityNotification.php
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Notifications\Ninja;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class UserQualityNotification extends Notification
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
protected User $user;
|
||||||
|
|
||||||
|
protected string $account_key;
|
||||||
|
|
||||||
|
public function __construct(User $user, string $account_key)
|
||||||
|
{
|
||||||
|
$this->user = $user;
|
||||||
|
$this->account_key = $account_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function via($notifiable)
|
||||||
|
{
|
||||||
|
return ['slack'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail($notifiable)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @param mixed $notifiable
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function toArray($notifiable)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toSlack($notifiable)
|
||||||
|
{
|
||||||
|
|
||||||
|
$content = "User Quality notification {$this->user->present()->name()} \n";
|
||||||
|
$content .= "Account: {$this->account_key }\n";
|
||||||
|
|
||||||
|
return (new SlackMessage)
|
||||||
|
->success()
|
||||||
|
->from(ctrans('texts.notification_bot'))
|
||||||
|
->image('https://app.invoiceninja.com/favicon.png')
|
||||||
|
->content($content);
|
||||||
|
}
|
||||||
|
}
|
@ -23,7 +23,8 @@ class UserObserver
|
|||||||
*/
|
*/
|
||||||
public function created(User $user)
|
public function created(User $user)
|
||||||
{
|
{
|
||||||
//
|
if(class_exists(\Modules\Admin\Jobs\Account\UserQuality::class))
|
||||||
|
(new \Modules\Admin\Jobs\Account\UserQuality($user, $user->account->key))->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +35,9 @@ class UserObserver
|
|||||||
*/
|
*/
|
||||||
public function updated(User $user)
|
public function updated(User $user)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(class_exists(\Modules\Admin\Jobs\Account\UserQuality::class))
|
||||||
|
(new \Modules\Admin\Jobs\Account\UserQuality($user, $user->account->key))->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user