diff --git a/app/Filters/ClientFilters.php b/app/Filters/ClientFilters.php index 9b658ab020a4..b1c7964de383 100644 --- a/app/Filters/ClientFilters.php +++ b/app/Filters/ClientFilters.php @@ -112,7 +112,8 @@ class ClientFilters extends QueryFilters return $this->builder; } - return $this->builder->where('group_settings_id', $group_id); + return $this->builder->where('group_settings_id', $this->decodePrimaryKey($group_id)); + } /** diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 2cb1e8041b87..7d08aad6a391 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -11,12 +11,13 @@ namespace App\Http\Controllers\Auth; -use App\Http\Controllers\Controller; -use App\Libraries\MultiDB; use App\Models\Account; -use Illuminate\Foundation\Auth\SendsPasswordResetEmails; +use App\Models\Company; +use App\Libraries\MultiDB; use Illuminate\Http\Request; +use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Password; +use Illuminate\Foundation\Auth\SendsPasswordResetEmails; class ForgotPasswordController extends Controller { diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index 75436ed0325b..09419ac60f67 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -69,7 +69,7 @@ class ResetPasswordController extends Controller $account = Account::first(); } - return $this->render('auth.passwords.reset', ['root' => 'themes', 'token' => $token, 'account' => $account]); + return $this->render('auth.passwords.reset', ['root' => 'themes', 'token' => $token, 'account' => $account, 'email' => $request->email]); } /** @@ -111,4 +111,28 @@ class ResetPasswordController extends Controller return redirect('/'); } + + /** + * Get the response for a successful password reset. + * + * @param \Illuminate\Http\Request $request + * @param string $response + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse + */ + protected function sendResetResponse(Request $request, $response) + { + if ($request->wantsJson()) { + return new JsonResponse(['message' => trans($response)], 200); + } + + if(Ninja::isHosted() && $request->hasHeader('X-React')){ + return redirect('https://app.invoicing.co/#/login'); + } + elseif($request->hasHeader('X-React')) + return redirect('/#/login'); + + return redirect($this->redirectPath()) + ->with('status', trans($response)); + } + } diff --git a/app/Http/Controllers/Traits/VerifiesUserEmail.php b/app/Http/Controllers/Traits/VerifiesUserEmail.php index f821631c6b87..02b7353de0b1 100644 --- a/app/Http/Controllers/Traits/VerifiesUserEmail.php +++ b/app/Http/Controllers/Traits/VerifiesUserEmail.php @@ -84,6 +84,7 @@ trait VerifiesUserEmail return $this->render('auth.confirmed', [ 'root' => 'themes', 'message' => ctrans('texts.security_confirmation'), + 'redirect_url' => request()->hasHeader('X-React') ? 'https://app.invoicing.co/#/' : url('/'), ]); } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 60dbcf4d735f..bcabe5c16c0b 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -231,8 +231,11 @@ class UserController extends BaseController $return_user_collection = collect(); - $users->each(function ($user, $key) use ($action, $return_user_collection) { - if (auth()->user()->can('edit', $user)) { + /** @var \App\Models\User $logged_in_user */ + $logged_in_user = auth()->user(); + + $users->each(function ($user, $key) use ($logged_in_user, $action, $return_user_collection) { + if ($logged_in_user->can('edit', $user)) { $this->user_repo->{$action}($user); $return_user_collection->push($user->id); @@ -251,12 +254,11 @@ class UserController extends BaseController */ public function detach(DetachCompanyUserRequest $request, User $user) { - // if ($request->entityIsDeleted($user)) { - // return $request->disallowUpdate(); - // } + /** @var \App\Models\User $logged_in_user */ + $logged_in_user = auth()->user(); $company_user = CompanyUser::whereUserId($user->id) - ->whereCompanyId(auth()->user()->companyId()) + ->whereCompanyId($logged_in_user->companyId()) ->withTrashed() ->first(); diff --git a/app/Http/Middleware/Cors.php b/app/Http/Middleware/Cors.php index 869157ea686e..82926e3ddb50 100644 --- a/app/Http/Middleware/Cors.php +++ b/app/Http/Middleware/Cors.php @@ -15,7 +15,7 @@ class Cors // ALLOW OPTIONS METHOD $headers = [ 'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE', - 'Access-Control-Allow-Headers'=> 'X-API-PASSWORD-BASE64,X-API-COMPANY-KEY,X-CLIENT-VERSION,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Disposition,Range,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE', + 'Access-Control-Allow-Headers'=> 'X-React,X-API-PASSWORD-BASE64,X-API-COMPANY-KEY,X-CLIENT-VERSION,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Disposition,Range,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE', ]; return Response::make('OK', 200, $headers); @@ -25,7 +25,7 @@ class Cors $response->headers->set('Access-Control-Allow-Origin', '*'); $response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); - $response->headers->set('Access-Control-Allow-Headers', 'X-API-PASSWORD-BASE64,X-API-COMPANY-KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Disposition,Range,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE'); + $response->headers->set('Access-Control-Allow-Headers', 'X-React,X-API-PASSWORD-BASE64,X-API-COMPANY-KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Disposition,Range,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE'); $response->headers->set('Access-Control-Expose-Headers', 'X-APP-VERSION,X-MINIMUM-CLIENT-VERSION,Content-Disposition'); $response->headers->set('X-APP-VERSION', config('ninja.app_version')); $response->headers->set('X-MINIMUM-CLIENT-VERSION', config('ninja.minimum_client_version')); diff --git a/app/Models/Company.php b/app/Models/Company.php index b062d01d4b46..08714d252ce7 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -241,12 +241,12 @@ class Company extends BaseModel protected array $tax_coverage_countries = [ 'US', // //EU countries - // 'AT', // Austria + 'AT', // Austria // 'BE', // Belgium // 'BG', // Bulgaria // 'CY', // Cyprus // 'CZ', // Czech Republic - // 'DE', // Germany + 'DE', // Germany // 'DK', // Denmark // 'EE', // Estonia // 'ES', // Spain @@ -269,9 +269,12 @@ class Company extends BaseModel // 'SI', // Slovenia // 'SK', // Slovakia // //EU Countries + 'AU', // Australia ]; protected $fillable = [ + 'invoice_task_item_description', + 'invoice_task_project_header', 'invoice_task_hours', 'markdown_enabled', 'calculate_expense_tax_by_amount', diff --git a/app/Services/Invoice/ApplyPayment.php b/app/Services/Invoice/ApplyPayment.php index dd43a7dc7288..63763dfa58ef 100644 --- a/app/Services/Invoice/ApplyPayment.php +++ b/app/Services/Invoice/ApplyPayment.php @@ -11,25 +11,15 @@ namespace App\Services\Invoice; -use App\Jobs\Ninja\TransactionLog; use App\Models\Invoice; use App\Models\Payment; -use App\Models\TransactionEvent; use App\Services\AbstractService; class ApplyPayment extends AbstractService { - private $invoice; - private $payment; - - private $payment_amount; - - public function __construct($invoice, $payment, $payment_amount) + public function __construct(private Invoice $invoice, private Payment $payment, private float $payment_amount) { - $this->invoice = $invoice; - $this->payment = $payment; - $this->payment_amount = $payment_amount; } /* Apply payment to a single invoice */ diff --git a/app/Services/Invoice/CreateInvitations.php b/app/Services/Invoice/CreateInvitations.php index 1b352caf6f5a..5261df58f1b3 100644 --- a/app/Services/Invoice/CreateInvitations.php +++ b/app/Services/Invoice/CreateInvitations.php @@ -23,11 +23,8 @@ class CreateInvitations extends AbstractService { use MakesHash; - private $invoice; - - public function __construct(Invoice $invoice) + public function __construct(private Invoice $invoice) { - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 5c369a9a5c05..86ba365545c5 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -28,27 +28,13 @@ class GenerateDeliveryNote { use MakesHash, PdfMaker; - /** - * @var \App\Models\Invoice - */ - private $invoice; - - /** - * @var \App\Models\ClientContact - */ - private $contact; - /** * @var mixed */ private $disk; - public function __construct(Invoice $invoice, ClientContact $contact = null, $disk = null) + public function __construct(private Invoice $invoice, private ?ClientContact $contact = null, $disk = null) { - $this->invoice = $invoice; - - $this->contact = $contact; - $this->disk = $disk ?? config('filesystems.default'); } diff --git a/app/Services/Invoice/GetInvoicePdf.php b/app/Services/Invoice/GetInvoicePdf.php index 518d59c5f608..376cdfd95d98 100644 --- a/app/Services/Invoice/GetInvoicePdf.php +++ b/app/Services/Invoice/GetInvoicePdf.php @@ -19,11 +19,8 @@ use Illuminate\Support\Facades\Storage; class GetInvoicePdf extends AbstractService { - public function __construct(Invoice $invoice, ClientContact $contact = null) + public function __construct(public Invoice $invoice, public ?ClientContact $contact = null) { - $this->invoice = $invoice; - - $this->contact = $contact; } public function run() diff --git a/app/Services/Invoice/HandleCancellation.php b/app/Services/Invoice/HandleCancellation.php index 7cf689a30a42..fe83909e3e36 100644 --- a/app/Services/Invoice/HandleCancellation.php +++ b/app/Services/Invoice/HandleCancellation.php @@ -12,10 +12,7 @@ namespace App\Services\Invoice; use App\Events\Invoice\InvoiceWasCancelled; -use App\Jobs\Ninja\TransactionLog; -use App\Models\Client; use App\Models\Invoice; -use App\Models\TransactionEvent; use App\Services\AbstractService; use App\Utils\Ninja; use App\Utils\Traits\GeneratesCounter; @@ -25,9 +22,7 @@ class HandleCancellation extends AbstractService { use GeneratesCounter; - private $invoice; - - public function __construct(Invoice $invoice) + public function __construct(private Invoice $invoice) { $this->invoice = $invoice; } diff --git a/app/Services/Invoice/HandleRestore.php b/app/Services/Invoice/HandleRestore.php index b2878a38b56b..18502189f485 100644 --- a/app/Services/Invoice/HandleRestore.php +++ b/app/Services/Invoice/HandleRestore.php @@ -23,17 +23,14 @@ class HandleRestore extends AbstractService { use GeneratesCounter; - private $invoice; - private $payment_total = 0; private $total_payments = 0; private $adjustment_amount = 0; - public function __construct(Invoice $invoice) + public function __construct(private Invoice $invoice) { - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/HandleReversal.php b/app/Services/Invoice/HandleReversal.php index 008fd44534af..58d566e51ce0 100644 --- a/app/Services/Invoice/HandleReversal.php +++ b/app/Services/Invoice/HandleReversal.php @@ -23,11 +23,8 @@ class HandleReversal extends AbstractService { use GeneratesCounter; - private $invoice; - - public function __construct(Invoice $invoice) + public function __construct(private Invoice $invoice) { - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/MarkInvoiceDeleted.php b/app/Services/Invoice/MarkInvoiceDeleted.php index d3ed85a2808e..27291123d56e 100644 --- a/app/Services/Invoice/MarkInvoiceDeleted.php +++ b/app/Services/Invoice/MarkInvoiceDeleted.php @@ -21,17 +21,14 @@ class MarkInvoiceDeleted extends AbstractService { use GeneratesCounter; - public $invoice; - private $adjustment_amount = 0; private $total_payments = 0; private $balance_adjustment = 0; - public function __construct(Invoice $invoice) + public function __construct(public Invoice $invoice) { - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/SendEmail.php b/app/Services/Invoice/SendEmail.php index b71677457307..5cf05dd6a3d9 100644 --- a/app/Services/Invoice/SendEmail.php +++ b/app/Services/Invoice/SendEmail.php @@ -18,19 +18,8 @@ use App\Services\AbstractService; class SendEmail extends AbstractService { - protected $invoice; - - protected $reminder_template; - - protected $contact; - - public function __construct(Invoice $invoice, $reminder_template = null, ClientContact $contact = null) + public function __construct(protected Invoice $invoice, protected $reminder_template = null, protected ?ClientContact $contact = null) { - $this->invoice = $invoice; - - $this->reminder_template = $reminder_template; - - $this->contact = $contact; } /** diff --git a/app/Services/Invoice/TriggeredActions.php b/app/Services/Invoice/TriggeredActions.php index 4fb1342391ae..7c6e7c4f6ad9 100644 --- a/app/Services/Invoice/TriggeredActions.php +++ b/app/Services/Invoice/TriggeredActions.php @@ -23,17 +23,10 @@ class TriggeredActions extends AbstractService { use GeneratesCounter; - private $request; - - private $invoice; - private bool $updated = false; - public function __construct(Invoice $invoice, Request $request) + public function __construct(private Invoice $invoice, private Request $request) { - $this->request = $request; - - $this->invoice = $invoice; } public function run() diff --git a/app/Services/Invoice/UpdateReminder.php b/app/Services/Invoice/UpdateReminder.php index cba87bacdf84..f552fb141e85 100644 --- a/app/Services/Invoice/UpdateReminder.php +++ b/app/Services/Invoice/UpdateReminder.php @@ -18,14 +18,9 @@ use Carbon\Carbon; class UpdateReminder extends AbstractService { - public $invoice; - public $settings; - - public function __construct(Invoice $invoice, $settings = null) + public function __construct(public Invoice $invoice, public mixed $settings = null) { - $this->invoice = $invoice; - $this->settings = $settings; } /* We only support setting reminders based on the due date, not the partial due date */ diff --git a/app/Services/Pdf/PdfMock.php b/app/Services/Pdf/PdfMock.php index bd03fef32571..8c569ed0323f 100644 --- a/app/Services/Pdf/PdfMock.php +++ b/app/Services/Pdf/PdfMock.php @@ -811,7 +811,7 @@ class PdfMock '$purchase_order.due_date' => '02-12-2021', '$vendor.billing_address1' => '589', '$vendor.billing_address2' => '761 Odessa Centers Suite 673', - '$invoiceninja.whitelabel' => 'https://raw.githubusercontent.com/invoiceninja/invoiceninja/v5-develop/public/images/new_logo.png', + '$invoiceninja.whitelabel' => 'https://invoicing.co/images/new_logo.png', '$purchase_order.custom1' => 'Custom 1', '$purchase_order.custom2' => 'Custom 2', '$purchase_order.custom3' => 'Custom 3', diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index 4152fa1988ff..0d6241ca8c17 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -201,6 +201,8 @@ class CompanyTransformer extends EntityTransformer 'tax_data' => $company->tax_data ?: new \stdClass, 'has_e_invoice_certificate' => $company->e_invoice_certificate ? true : false, 'has_e_invoice_certificate_passphrase' => $company->e_invoice_certificate_passphrase ? true : false, + 'invoice_task_project_header' => (bool) $company->invoice_task_project_header, + 'invoice_task_item_description' => (bool) $company->invoice_task_item_description, ]; } diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index c9524bfe01a3..f0784c2a75bf 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -606,7 +606,7 @@ class HtmlEngine $data['$secondary_font_name'] = ['value' => Helpers::resolveFont($this->settings->secondary_font)['name'], 'label' => '']; $data['$secondary_font_url'] = ['value' => Helpers::resolveFont($this->settings->secondary_font)['url'], 'label' => '']; - $data['$invoiceninja.whitelabel'] = ['value' => 'https://raw.githubusercontent.com/invoiceninja/invoiceninja/v5-develop/public/images/new_logo.png', 'label' => '']; + $data['$invoiceninja.whitelabel'] = ['value' => 'https://invoicing.co/images/new_logo.png', 'label' => '']; $data['$primary_color'] = ['value' => $this->settings->primary_color, 'label' => '']; $data['$secondary_color'] = ['value' => $this->settings->secondary_color, 'label' => '']; diff --git a/app/Utils/VendorHtmlEngine.php b/app/Utils/VendorHtmlEngine.php index 67bd20d7bf25..bd5183bf33f9 100644 --- a/app/Utils/VendorHtmlEngine.php +++ b/app/Utils/VendorHtmlEngine.php @@ -384,7 +384,7 @@ class VendorHtmlEngine $data['$font_name'] = ['value' => Helpers::resolveFont($this->settings->primary_font)['name'], 'label' => '']; $data['$font_url'] = ['value' => Helpers::resolveFont($this->settings->primary_font)['url'], 'label' => '']; - $data['$invoiceninja.whitelabel'] = ['value' => 'https://raw.githubusercontent.com/invoiceninja/invoiceninja/v5-develop/public/images/new_logo.png', 'label' => '']; + $data['$invoiceninja.whitelabel'] = ['value' => 'https://invoicing.co/images/new_logo.png', 'label' => '']; $data['$primary_color'] = ['value' => $this->settings->primary_color, 'label' => '']; $data['$secondary_color'] = ['value' => $this->settings->secondary_color, 'label' => '']; diff --git a/database/migrations/2023_06_04_064713_project_and_task_columns_for_company_model.php b/database/migrations/2023_06_04_064713_project_and_task_columns_for_company_model.php new file mode 100644 index 000000000000..4f98a9981b9b --- /dev/null +++ b/database/migrations/2023_06_04_064713_project_and_task_columns_for_company_model.php @@ -0,0 +1,32 @@ +boolean('invoice_task_project_header')->default(true); + $table->boolean('invoice_task_item_description')->default(true); + }); + + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}; diff --git a/resources/views/portal/ninja2020/auth/passwords/reset.blade.php b/resources/views/portal/ninja2020/auth/passwords/reset.blade.php index 3ace5553f017..28e36f4b7ce1 100644 --- a/resources/views/portal/ninja2020/auth/passwords/reset.blade.php +++ b/resources/views/portal/ninja2020/auth/passwords/reset.blade.php @@ -41,7 +41,7 @@ + > @error('email')
{{ $message }}
- {{ ctrans('texts.return_to_login') }} + {{ ctrans('texts.return_to_login') }}