Compare commits

..

No commits in common. "master" and "lastFOSS" have entirely different histories.

199 changed files with 5705 additions and 14892 deletions

View file

@ -36,6 +36,6 @@ If applicable, add screenshots to help explain your problem.
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.
<!-- Note: Before posting don't forget to check our "Troubleshooting" category in the [docs](https://invoiceninja.github.io/docs/self-host-troubleshooting/) (https://invoiceninja.github.io/docs/self-host-troubleshooting/) --> Note: Before posting don't forget to check our "Troubleshooting" category in the [docs](https://invoiceninja.github.io/docs/self-host-troubleshooting/) (https://invoiceninja.github.io/docs/self-host-troubleshooting/).
**(v5) Can you replicate the issue on our demo site? https://demo.invoiceninja.com** **(v5) Can you replicate the issue on our demo site? https://demo.invoiceninja.com**

2
.gitignore vendored
View file

@ -17,7 +17,7 @@
/bootstrap/environment.php /bootstrap/environment.php
/vendor /vendor
/node_modules /node_modules
.DS_Store /.DS_Store
Thumbs.db Thumbs.db
/.env /.env
/.env.development.php /.env.development.php

88
LICENSE
View file

@ -1,47 +1,47 @@
Elastic License 2.0 (ELv2) Copyright (c) 2018 by Hillel Coren
Elastic License Invoice Ninja * https://www.invoiceninja.com
"CREATE. SEND. GET PAID"
Acceptance All Rights Reserved
By using the software, you agree to all of the terms and conditions below. ATTRIBUTION ASSURANCE LICENSE (adapted from the original BSD license)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the conditions below are met.
These conditions require a modest attribution to InvoiceNinja.com (the
"Author"), who hopes that its promotional value may help justify the
thousands of dollars in otherwise billable time invested in writing
this and other freely available, open-source software.
Copyright License 1. Redistributions of source code, in whole or part and with or without
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below modification (the "Code"), must prominently display this GPG-signed
text in verifiable form.
2. Redistributions of the Code in binary form must be accompanied by
this GPG-signed text in any documentation and, each time the resulting
executable program or a program dependent thereon is launched, a
prominent display (e.g., splash screen or banner text) of the Author's
attribution information, which includes:
(a) Name ("Hillel Coren"),
(b) Professional identification ("Invoice Ninja"), and
(c) URL ("https://www.invoiceninja.com").
3. Neither the name nor any trademark of the Author may be used to
endorse or promote products derived from this software without specific
prior written permission.
4. Users are entirely responsible, to the exclusion of the Author and
any other persons, for compliance with (1) regulations set by owners or
administrators of employed equipment, (2) licensing terms of any other
software, and (3) local regulations regarding use, including those
regarding import, export, and use of encryption software.
Limitations THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND
You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key. FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensors trademarks is subject to applicable law. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Patents EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS;
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
Notices AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software. IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
No Other Rights
These terms do not imply any licenses other than those expressly granted in these terms.
Termination
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
No Liability
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
Definitions
The licensor is the entity offering these terms, and the software is the software the licensor makes available under these terms, including any portion of it.
you refers to the individual or entity agreeing to these terms.
your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
your licenses are all the licenses granted to you for the software under these terms.
use means anything you do with the software requiring one of your licenses.
trademark means trademarks, service marks, and similar rights.
For more information regarding the interpretation of this license please see here: https://invoiceninja.github.io/docs/legal/license/

View file

@ -15,7 +15,7 @@ Just make sure to add the `invoice-ninja` tag to your question.
#### Note: v5 is now tagged Stable! To upgrade from v4 you need to [install v5](https://invoiceninja.github.io/docs/self-host-installation/) as a separate app and then use the migration tool in the latest version of v4 on Settings > Account Management. #### Note: v5 is now tagged Stable! To upgrade from v4 you need to [install v5](https://invoiceninja.github.io/docs/self-host-installation/) as a separate app and then use the migration tool in the latest version of v4 on Settings > Account Management.
All Pro and Enterprise features from the hosted app are included in the open-code. We offer a $30 per year white-label license to remove the Invoice Ninja branding from client facing parts of the app. All Pro and Enterprise features from the hosted app are included in the open-source code. We offer a $30 per year white-label license to remove the Invoice Ninja branding from client facing parts of the app.
The self-host zip includes all third party libraries whereas downloading the code from GitHub requires using Composer to install the dependencies. The self-host zip includes all third party libraries whereas downloading the code from GitHub requires using Composer to install the dependencies.
@ -25,19 +25,17 @@ The self-host zip includes all third party libraries whereas downloading the cod
* [Support Forum](https://www.invoiceninja.com/forums/forum/support/) * [Support Forum](https://www.invoiceninja.com/forums/forum/support/)
* [StackOverflow](https://stackoverflow.com/tags/invoice-ninja/) * [StackOverflow](https://stackoverflow.com/tags/invoice-ninja/)
## Mobile App ## Referral Program
* [iPhone](https://apps.apple.com/us/app/invoice-ninja-v5/id1503970375#?platform=iphone) * Earn 50% of Pro & Enterprise Plans up to 4 years - [Learn more](https://www.invoiceninja.com/referral-program/)
* [Android](https://play.google.com/store/apps/details?id=com.invoiceninja.app)
* [Linux](https://github.com/invoiceninja/flutter-mobile)
## Desktop App ## Mobile App
* [MacOS](https://apps.apple.com/app/id1503970375) * [iPhone](https://itunes.apple.com/us/app/invoice-ninja/id1435514417?ls=1&mt=8)
* [Windows](https://microsoft.com/en-us/p/invoice-ninja/9n3f2bbcfdr6) * [Android](https://play.google.com/store/apps/details?id=com.invoiceninja.flutter)
* [MacOS Desktop](https://snapcraft.io/invoiceninja) * [Source Code](https://github.com/invoiceninja/flutter-mobile)
## Installation Options ## Installation Options
* [Ansible](https://github.com/invoiceninja/ansible-installer) * [Ansible](https://github.com/invoiceninja/ansible-installer)
* [Self-Host Zip](https://invoice-ninja.readthedocs.io/en/latest/install.html) * [Self-Host Zip](https://docs.invoiceninja.com/install.html)
* [Docker File](https://hub.docker.com/r/invoiceninja/invoiceninja/) * [Docker File](https://hub.docker.com/r/invoiceninja/invoiceninja/)
* [Cloudron](https://cloudron.io/store/com.invoiceninja.cloudronapp.html) * [Cloudron](https://cloudron.io/store/com.invoiceninja.cloudronapp.html)
* [Softaculous](https://www.softaculous.com/apps/ecommerce/Invoice_Ninja) * [Softaculous](https://www.softaculous.com/apps/ecommerce/Invoice_Ninja)
@ -51,7 +49,7 @@ The self-host zip includes all third party libraries whereas downloading the cod
## Development ## Development
* [API Documentation](https://invoice-ninja.readthedocs.io/en/latest/api.html) * [API Documentation](https://invoice-ninja.readthedocs.io/en/latest/api.html)
* [PHP SDK](https://github.com/invoiceninja/sdk-php) * [PHP SDK](https://github.com/invoiceninja/sdk-php)
* [Laminas Framework](https://github.com/alexz707/InvoiceNinjaModule) * [Zend Framework](https://github.com/alexz707/InvoiceNinjaModule)
* [Custom Module](https://invoice-ninja.readthedocs.io/en/latest/custom_modules.html) | [Watch Video](https://www.youtube.com/watch?v=8jJ-PYuq85k) * [Custom Module](https://invoice-ninja.readthedocs.io/en/latest/custom_modules.html) | [Watch Video](https://www.youtube.com/watch?v=8jJ-PYuq85k)
## Third Party Modules ## Third Party Modules
@ -94,5 +92,5 @@ For information on how contribute to Invoice Ninja, please see our [contributing
* [Mike Skaggs](https://github.com/titan-fail) * [Mike Skaggs](https://github.com/titan-fail)
## License ## License
Invoice Ninja is released under the Elastic License 2.0 Invoice Ninja is released under the Attribution Assurance License.
See [LICENSE](LICENSE) for details. See [LICENSE](LICENSE) for details.

View file

@ -1,3 +0,0 @@
## Reporting a Vulnerability
If you discover any security related issues, please email contact@invoiceninja.com instead of using the issue tracker.

View file

@ -78,7 +78,7 @@ class CheckData extends Command
$this->checkContacts(); $this->checkContacts();
if (! $this->option('client_id')) { if (! $this->option('client_id')) {
//$this->checkBlankInvoiceHistory(); $this->checkBlankInvoiceHistory();
$this->checkPaidToDate(); $this->checkPaidToDate();
$this->checkDraftSentInvoices(); $this->checkDraftSentInvoices();
} }
@ -92,12 +92,12 @@ class CheckData extends Command
if (! $this->option('client_id')) { if (! $this->option('client_id')) {
$this->checkOAuth(); $this->checkOAuth();
//$this->checkInvitations(); //$this->checkInvitations();
//$this->checkAccountData(); $this->checkAccountData();
$this->checkLookupData(); $this->checkLookupData();
$this->checkFailedJobs(); $this->checkFailedJobs();
} }
//$this->checkTranslations(); $this->checkTranslations();
$this->logMessage('Done: ' . strtoupper($this->isValid ? RESULT_SUCCESS : RESULT_FAILURE)); $this->logMessage('Done: ' . strtoupper($this->isValid ? RESULT_SUCCESS : RESULT_FAILURE));
$errorEmail = env('ERROR_EMAIL'); $errorEmail = env('ERROR_EMAIL');
@ -160,7 +160,6 @@ class CheckData extends Command
$invoices = Invoice::whereInvoiceStatusId(INVOICE_STATUS_SENT) $invoices = Invoice::whereInvoiceStatusId(INVOICE_STATUS_SENT)
->whereIsPublic(false) ->whereIsPublic(false)
->withTrashed() ->withTrashed()
->where('updated_at', '>', '2022-01-01')
->get(); ->get();
$this->logMessage($invoices->count() . ' draft sent invoices'); $this->logMessage($invoices->count() . ' draft sent invoices');
@ -639,7 +638,7 @@ class CheckData extends Command
->where('payments.payment_status_id', '!=', 3) ->where('payments.payment_status_id', '!=', 3)
->where('payments.is_deleted', '=', 0); ->where('payments.is_deleted', '=', 0);
}) })
->where('invoices.updated_at', '>', '2022-01-01') ->where('invoices.updated_at', '>', '2017-10-01')
->groupBy('invoices.id') ->groupBy('invoices.id')
->havingRaw('(invoices.amount - invoices.balance) != coalesce(sum(payments.amount - payments.refunded), 0)') ->havingRaw('(invoices.amount - invoices.balance) != coalesce(sum(payments.amount - payments.refunded), 0)')
->get(['invoices.id', 'invoices.amount', 'invoices.balance', DB::raw('coalesce(sum(payments.amount - payments.refunded), 0)')]); ->get(['invoices.id', 'invoices.amount', 'invoices.balance', DB::raw('coalesce(sum(payments.amount - payments.refunded), 0)')]);
@ -663,7 +662,6 @@ class CheckData extends Command
->where('invoices.is_public', '=', 1) ->where('invoices.is_public', '=', 1)
->where('invoices.invoice_type_id', '=', INVOICE_TYPE_STANDARD) ->where('invoices.invoice_type_id', '=', INVOICE_TYPE_STANDARD)
->where('invoices.is_recurring', '=', 0) ->where('invoices.is_recurring', '=', 0)
->where('clients.updated_at', '>', '2022-01-01')
->havingRaw('abs(clients.balance - sum(invoices.balance)) > .01 and clients.balance != 999999999.9999'); ->havingRaw('abs(clients.balance - sum(invoices.balance)) > .01 and clients.balance != 999999999.9999');
if ($this->option('client_id')) { if ($this->option('client_id')) {

View file

@ -7,7 +7,6 @@ use App\Models\User;
use App\Traits\GenerateMigrationResources; use App\Traits\GenerateMigrationResources;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
class ExportMigrations extends Command class ExportMigrations extends Command
{ {
@ -18,7 +17,7 @@ class ExportMigrations extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'migrations:export {--user=} {--email=} {--random=}'; protected $signature = 'migrations:export {--user=} {--random=}';
/** /**
* The console command description. * The console command description.
@ -47,36 +46,8 @@ class ExportMigrations extends Command
$this->info('Note: Migrations will be stored inside of (storage/migrations) folder.'); $this->info('Note: Migrations will be stored inside of (storage/migrations) folder.');
if($this->option('user')) { if($this->option('user')) {
$record = User::on(DB_NINJA_1)->find($this->option('user')); $record = User::findOrFail($this->option('user'));
return $this->export($record);
if($record)
return $this->export($record);
$record = User::on(DB_NINJA_2)->find($this->option('user'));
if($record)
return $this->export($record);
$this->info('I could not find that user - sorry');
return;
}
if($this->option('email')) {
$record = User::on(DB_NINJA_1)->where('email', $this->option('email'))->first();
if($record)
return $this->export($record);
$record = User::on(DB_NINJA_2)->where('email', $this->option('email'))->first();
if($record)
return $this->export($record);
$this->info('I could not find that user by email - sorry');
return;
} }
if($this->option('random')){ if($this->option('random')){
@ -99,7 +70,6 @@ class ExportMigrations extends Command
private function export($user) private function export($user)
{ {
$this->account = $user->account; $this->account = $user->account;
Auth::login($user);
$date = date('Y-m-d'); $date = date('Y-m-d');
$accountKey = $this->account->account_key; $accountKey = $this->account->account_key;
@ -122,20 +92,17 @@ class ExportMigrations extends Command
'products' => $this->getProducts(), 'products' => $this->getProducts(),
'credits' => $this->getCreditsNotes(), 'credits' => $this->getCreditsNotes(),
'invoices' => $this->getInvoices(), 'invoices' => $this->getInvoices(),
'recurring_expenses' => $this->getRecurringExpenses(),
'recurring_invoices' => $this->getRecurringInvoices(), 'recurring_invoices' => $this->getRecurringInvoices(),
'quotes' => $this->getQuotes(), 'quotes' => $this->getQuotes(),
'payments' => $this->getPayments(), 'payments' => array_merge($this->getPayments(), $this->getCredits()),
'documents' => $this->getDocuments(), 'documents' => $this->getDocuments(),
'expense_categories' => $this->getExpenseCategories(), 'expense_categories' => $this->getExpenseCategories(),
'task_statuses' => $this->getTaskStatuses(), 'task_statuses' => $this->getTaskStatuses(),
'expenses' => $this->getExpenses(), 'expenses' => $this->getExpenses(),
'tasks' => $this->getTasks(), 'tasks' => $this->getTasks(),
'documents' => $this->getDocuments(), 'documents' => $this->getDocuments(),
'ninja_tokens' => $this->getNinjaToken(),
]; ];
Storage::makeDirectory('migrations');
$file = storage_path("migrations/{$fileName}.zip"); $file = storage_path("migrations/{$fileName}.zip");
$zip = new \ZipArchive(); $zip = new \ZipArchive();

View file

@ -1,154 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Jobs\HostedMigration;
use App\Libraries\Utils;
use App\Models\Company;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Auth;
class ForceMigration extends Command
{
// define('DB_NINJA_1', 'db-ninja-1');
// define('DB_NINJA_2', 'db-ninja-2');
public $db = DB_NINJA_1;
public $force = false;
public $user = false;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ninja:force-migrate-v5 {--email=} {--force=} {--database=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Force migrate accounts to v5 - (Hosted function only)';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if($this->option('database'))
$this->db = $this->option('database');
if($this->option('force'))
$this->force = $this->option('force');
if(!Utils::isNinjaProd())
return;
config(['database.default' => $this->db]);
$company = $this->getCompany();
if(!$company){
$this->logMessage('Could not find a company with that email address');
exit;
}
$this->forceMigrate($company);
}
private function getCompany()
{
if($this->option('email')){
$user = User::on($this->db)
->where('email', $this->option('email'))
->whereNull('public_id')
->orWhere('public_id', 0)
->first();
if(!$user){
$this->logMessage('Could not find an owner user with that email address');
exit;
}
$this->user = $user;
return $user->account->company;
}
// $company = Company::on($this->db)
// ->whereNull('plan')
// ->orWhereIn('plan', ['','free'])
// ->whereHas('accounts', function ($query){
// $query->where('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
// $query->orWhere('account_key', '!=', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx702');
// $query->orWhere('account_key', '!=', 'AsFmBAeLXF0IKf7tmi0eiyZfmWW9hxMT');
// })
// ->with('accounts')
// ->withCount('accounts')
// ->having('accounts_count', '>=', 1)
// ->first();
// return $company;
}
private function logMessage($str)
{
$str = date('Y-m-d h:i:s').' '.$str;
$this->info($str);
$this->log .= $str."\n";
}
private function forceMigrate($company)
{
$data = [];
if(!$this->user)
$this->user = $company->accounts->first()->users()->whereNull('public_id')->orWhere('public_id', 0)->first();
if(!$this->user){
$this->logMessage('Could not find an owner user with that email address');
exit;
}
if($company){
foreach($company->accounts as $key => $account)
{
$data['companies'][$key]['id'] = $account->id;
$data['companies'][$key]['force'] = $this->force;
}
$this->dispatch(new HostedMigration($this->user, $data, $this->db, true));
$company->is_migrated = true;
$company->save();
}
}
}

View file

@ -70,9 +70,7 @@ class SendRecurringInvoices extends Command
->get(); ->get();
foreach ($accounts as $account) { foreach ($accounts as $account) {
$account->checkCounterReset();
if(!$account->account_email_settings->is_disabled)
$account->checkCounterReset();
} }
} }
@ -96,11 +94,6 @@ class SendRecurringInvoices extends Command
$this->info(date('r') . ' Processing Invoice: '. $recurInvoice->id); $this->info(date('r') . ' Processing Invoice: '. $recurInvoice->id);
$account = $recurInvoice->account; $account = $recurInvoice->account;
if($account->account_email_settings->is_disabled){
continue;
}
$account->loadLocalizationSettings($recurInvoice->client); $account->loadLocalizationSettings($recurInvoice->client);
Auth::loginUsingId($recurInvoice->activeUser()->id); Auth::loginUsingId($recurInvoice->activeUser()->id);
@ -134,7 +127,7 @@ class SendRecurringInvoices extends Command
foreach ($expenses as $expense) { foreach ($expenses as $expense) {
$shouldSendToday = $expense->shouldSendToday(); $shouldSendToday = $expense->shouldSendToday();
if (! $shouldSendToday || $expense->account->account_email_settings->is_disabled) { if (! $shouldSendToday) {
continue; continue;
} }

View file

@ -109,7 +109,7 @@ class SendReminders extends Command
/** @var Invoice $invoice */ /** @var Invoice $invoice */
foreach ($delayedAutoBillInvoices as $invoice) { foreach ($delayedAutoBillInvoices as $invoice) {
if ($invoice->isPaid() || $invoice->account->is_deleted) { if ($invoice->isPaid()) {
continue; continue;
} }
@ -128,7 +128,7 @@ class SendReminders extends Command
$this->info(date('r ') . $accounts->count() . ' accounts found with fees enabled'); $this->info(date('r ') . $accounts->count() . ' accounts found with fees enabled');
foreach ($accounts as $account) { foreach ($accounts as $account) {
if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS) || $account->account_email_settings->is_disabled) { if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) {
continue; continue;
} }
@ -155,7 +155,7 @@ class SendReminders extends Command
$this->info(date('r ') . count($accounts) . ' accounts found with reminders enabled'); $this->info(date('r ') . count($accounts) . ' accounts found with reminders enabled');
foreach ($accounts as $account) { foreach ($accounts as $account) {
if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS) || $account->account_email_settings->is_disabled) { if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) {
continue; continue;
} }
@ -201,7 +201,7 @@ class SendReminders extends Command
$account = $scheduledReport->account; $account = $scheduledReport->account;
$account->loadLocalizationSettings(); $account->loadLocalizationSettings();
if (! $account->hasFeature(FEATURE_REPORTS) || $account->account_email_settings->is_disabled) { if (! $account->hasFeature(FEATURE_REPORTS)) {
continue; continue;
} }

View file

@ -1,82 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Libraries\Utils;
use App\Models\Company;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Auth;
class SyncAccounts extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ninja:sync-v5';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Sync accounts to v5 - (Hosted function only)';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if(!Utils::isNinjaProd())
return;
config(['database.default' => DB_NINJA_1]);
$this->updateAccounts();
config(['database.default' => DB_NINJA_2]);
$this->updateAccounts();
}
private function updateAccounts()
{
$data = [];
$a = Company::whereIn('plan', ['pro', 'enterprise'])
->with('accounts')
->cursor()->each(function ($company) use ($data){
$accounts = $company->accounts->pluck('account_key');
$data[] = [
'plan' => $company->plan,
'plan_term' => $company->plan_term,
'plan_started' => $company->plan_started,
'plan_paid' => $company->plan_paid,
'plan_expires' => $company->plan_expires,
'num_users' => $company->num_users,
'accounts' => $accounts
];
});
//post DATA
}
}

View file

@ -32,7 +32,6 @@ class Kernel extends ConsoleKernel
'App\Console\Commands\CalculatePayouts', 'App\Console\Commands\CalculatePayouts',
'App\Console\Commands\UpdateKey', 'App\Console\Commands\UpdateKey',
'App\Console\Commands\ExportMigrations', 'App\Console\Commands\ExportMigrations',
'App\Console\Commands\SyncAccounts',
]; ];
/** /**
@ -56,20 +55,5 @@ class Kernel extends ConsoleKernel
->command('ninja:send-reminders --force') ->command('ninja:send-reminders --force')
->sendOutputTo($logFile) ->sendOutputTo($logFile)
->daily(); ->daily();
if(Utils::isNinjaProd())
{
$schedule
->command('ninja:sync-v5')
->withoutOverlapping()
->daily();
// $schedule
// ->command('ninja:force-migrate-v5')
// ->everyMinute()
// ->withoutOverlapping();
}
} }
} }

View file

@ -361,7 +361,7 @@ if (! defined('APP_NAME')) {
define('NINJA_APP_URL', env('NINJA_APP_URL', 'https://app.invoiceninja.com')); define('NINJA_APP_URL', env('NINJA_APP_URL', 'https://app.invoiceninja.com'));
define('NINJA_DOCS_URL', env('NINJA_DOCS_URL', 'https://invoice-ninja.readthedocs.io/en/latest')); define('NINJA_DOCS_URL', env('NINJA_DOCS_URL', 'https://invoice-ninja.readthedocs.io/en/latest'));
define('NINJA_DATE', '2000-01-01'); define('NINJA_DATE', '2000-01-01');
define('NINJA_VERSION', '4.5.50' . env('NINJA_VERSION_SUFFIX')); define('NINJA_VERSION', '4.5.40' . env('NINJA_VERSION_SUFFIX'));
define('NINJA_TERMS_VERSION', '1.0.1'); define('NINJA_TERMS_VERSION', '1.0.1');
define('SOCIAL_LINK_FACEBOOK', env('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja')); define('SOCIAL_LINK_FACEBOOK', env('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja'));
@ -631,8 +631,6 @@ if (! defined('APP_NAME')) {
define('INVOICE_FIELDS_PRODUCT', 'product_fields'); define('INVOICE_FIELDS_PRODUCT', 'product_fields');
define('INVOICE_FIELDS_TASK', 'task_fields'); define('INVOICE_FIELDS_TASK', 'task_fields');
define('NINJA_V5_TOKEN', env('NINJA_V5_TOKEN',false));
$creditCards = [ $creditCards = [
1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'], 1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'],
2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'], 2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'],

View file

@ -2,19 +2,20 @@
namespace App\Exceptions; namespace App\Exceptions;
use App\Http\Requests\Request;
use Exception; use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Exceptions\HttpResponseException; use Illuminate\Foundation\Validation\ValidationException;
use Illuminate\Session\TokenMismatchException; use Illuminate\Http\Exception\HttpResponseException;
use Illuminate\Support\Facades\Response; use Illuminate\Support\Facades\Response;
use Illuminate\Session\TokenMismatchException;
use Redirect; use Redirect;
use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Utils; use Utils;
use Request;
/** /**
* Class Handler. * Class Handler.
@ -29,6 +30,7 @@ class Handler extends ExceptionHandler
protected $dontReport = [ protected $dontReport = [
TokenMismatchException::class, TokenMismatchException::class,
ModelNotFoundException::class, ModelNotFoundException::class,
ValidationException::class,
\Illuminate\Validation\ValidationException::class, \Illuminate\Validation\ValidationException::class,
//AuthorizationException::class, //AuthorizationException::class,
//HttpException::class, //HttpException::class,
@ -101,7 +103,7 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Exception $e) public function render($request, Exception $e)
{ {
$value = \Request::header('X-Ninja-Token'); $value = Request::header('X-Ninja-Token');
if ($e instanceof ModelNotFoundException) { if ($e instanceof ModelNotFoundException) {

View file

@ -35,6 +35,7 @@ use Auth;
use Cache; use Cache;
use File; use File;
use Image; use Image;
use Input;
use Redirect; use Redirect;
use Request; use Request;
use Response; use Response;
@ -108,7 +109,7 @@ class AccountController extends BaseController
{ {
$user = false; $user = false;
$account = false; $account = false;
$guestKey = \Request::input('guest_key'); // local storage key to login until registered $guestKey = Input::get('guest_key'); // local storage key to login until registered
if (Auth::check()) { if (Auth::check()) {
return Redirect::to('invoices/create'); return Redirect::to('invoices/create');
@ -140,13 +141,13 @@ class AccountController extends BaseController
Session::flash('warning', $message); Session::flash('warning', $message);
} }
if ($redirectTo = \Request::input('redirect_to')) { if ($redirectTo = Input::get('redirect_to')) {
$redirectTo = SITE_URL . '/' . ltrim($redirectTo, '/'); $redirectTo = SITE_URL . '/' . ltrim($redirectTo, '/');
} else { } else {
$redirectTo = \Request::input('sign_up') ? 'dashboard' : 'invoices/create'; $redirectTo = Input::get('sign_up') ? 'dashboard' : 'invoices/create';
} }
return Redirect::to($redirectTo)->with('sign_up', \Request::input('sign_up')); return Redirect::to($redirectTo)->with('sign_up', Input::get('sign_up'));
} }
/** /**
@ -158,9 +159,9 @@ class AccountController extends BaseController
$account = $user->account; $account = $user->account;
$company = $account->company; $company = $account->company;
$plan = \Request::input('plan'); $plan = Input::get('plan');
$term = \Request::input('plan_term'); $term = Input::get('plan_term');
$numUsers = \Request::input('num_users'); $numUsers = Input::get('num_users');
if ($plan != PLAN_ENTERPRISE) { if ($plan != PLAN_ENTERPRISE) {
$numUsers = 1; $numUsers = 1;
@ -763,11 +764,11 @@ class AccountController extends BaseController
{ {
$user = Auth::user(); $user = Auth::user();
$account = $user->account; $account = $user->account;
$modules = \Request::input('modules'); $modules = Input::get('modules');
if (Utils::isSelfHost()) { if (Utils::isSelfHost()) {
// get all custom modules, including disabled // get all custom modules, including disabled
$custom_modules = collect(\Request::input('custom_modules'))->each(function ($item, $key) { $custom_modules = collect(Input::get('custom_modules'))->each(function ($item, $key) {
$module = Module::find($item); $module = Module::find($item);
if ($module && $module->disabled()) { if ($module && $module->disabled()) {
$module->enable(); $module->enable();
@ -781,10 +782,10 @@ class AccountController extends BaseController
}); });
} }
$user->force_pdfjs = \Request::input('force_pdfjs') ? true : false; $user->force_pdfjs = Input::get('force_pdfjs') ? true : false;
$user->save(); $user->save();
$account->live_preview = \Request::input('live_preview') ? true : false; $account->live_preview = Input::get('live_preview') ? true : false;
// Automatically disable live preview when using a large font // Automatically disable live preview when using a large font
$fonts = Cache::get('fonts')->filter(function ($font) use ($account) { $fonts = Cache::get('fonts')->filter(function ($font) use ($account) {
@ -812,7 +813,7 @@ class AccountController extends BaseController
*/ */
private function saveCustomizeDesign() private function saveCustomizeDesign()
{ {
$designId = intval(\Request::input('design_id')) ?: CUSTOM_DESIGN1; $designId = intval(Input::get('design_id')) ?: CUSTOM_DESIGN1;
$field = 'custom_design' . ($designId - 10); $field = 'custom_design' . ($designId - 10);
if (Auth::user()->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN)) { if (Auth::user()->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN)) {
@ -820,7 +821,7 @@ class AccountController extends BaseController
if (! $account->custom_design1) { if (! $account->custom_design1) {
$account->invoice_design_id = CUSTOM_DESIGN1; $account->invoice_design_id = CUSTOM_DESIGN1;
} }
$account->$field = \Request::input('custom_design'); $account->$field = Input::get('custom_design');
$account->save(); $account->save();
Session::flash('message', trans('texts.updated_settings')); Session::flash('message', trans('texts.updated_settings'));
@ -896,28 +897,28 @@ class AccountController extends BaseController
foreach (AccountEmailSettings::$templates as $type) { foreach (AccountEmailSettings::$templates as $type) {
$subjectField = "email_subject_{$type}"; $subjectField = "email_subject_{$type}";
$subject = \Request::input($subjectField, $account->getEmailSubject($type)); $subject = Input::get($subjectField, $account->getEmailSubject($type));
$account->account_email_settings->$subjectField = ($subject == $account->getDefaultEmailSubject($type) ? null : $subject); $account->account_email_settings->$subjectField = ($subject == $account->getDefaultEmailSubject($type) ? null : $subject);
$bodyField = "email_template_{$type}"; $bodyField = "email_template_{$type}";
$body = \Request::input($bodyField, $account->getEmailTemplate($type)); $body = Input::get($bodyField, $account->getEmailTemplate($type));
$account->account_email_settings->$bodyField = ($body == $account->getDefaultEmailTemplate($type) ? null : $body); $account->account_email_settings->$bodyField = ($body == $account->getDefaultEmailTemplate($type) ? null : $body);
} }
foreach ([TEMPLATE_REMINDER1, TEMPLATE_REMINDER2, TEMPLATE_REMINDER3] as $type) { foreach ([TEMPLATE_REMINDER1, TEMPLATE_REMINDER2, TEMPLATE_REMINDER3] as $type) {
$enableField = "enable_{$type}"; $enableField = "enable_{$type}";
$account->$enableField = \Request::input($enableField) ? true : false; $account->$enableField = Input::get($enableField) ? true : false;
$account->{"num_days_{$type}"} = \Request::input("num_days_{$type}"); $account->{"num_days_{$type}"} = Input::get("num_days_{$type}");
$account->{"field_{$type}"} = \Request::input("field_{$type}"); $account->{"field_{$type}"} = Input::get("field_{$type}");
$account->{"direction_{$type}"} = \Request::input("field_{$type}") == REMINDER_FIELD_INVOICE_DATE ? REMINDER_DIRECTION_AFTER : \Request::input("direction_{$type}"); $account->{"direction_{$type}"} = Input::get("field_{$type}") == REMINDER_FIELD_INVOICE_DATE ? REMINDER_DIRECTION_AFTER : Input::get("direction_{$type}");
$number = preg_replace('/[^0-9]/', '', $type); $number = preg_replace('/[^0-9]/', '', $type);
$account->account_email_settings->{"late_fee{$number}_amount"} = \Request::input("late_fee{$number}_amount"); $account->account_email_settings->{"late_fee{$number}_amount"} = Input::get("late_fee{$number}_amount");
$account->account_email_settings->{"late_fee{$number}_percent"} = \Request::input("late_fee{$number}_percent"); $account->account_email_settings->{"late_fee{$number}_percent"} = Input::get("late_fee{$number}_percent");
} }
$account->enable_reminder4 = \Request::input('enable_reminder4') ? true : false; $account->enable_reminder4 = Input::get('enable_reminder4') ? true : false;
$account->account_email_settings->frequency_id_reminder4 = \Request::input('frequency_id_reminder4'); $account->account_email_settings->frequency_id_reminder4 = Input::get('frequency_id_reminder4');
$account->save(); $account->save();
$account->account_email_settings->save(); $account->account_email_settings->save();
@ -934,7 +935,7 @@ class AccountController extends BaseController
private function saveTaxRates() private function saveTaxRates()
{ {
$account = Auth::user()->account; $account = Auth::user()->account;
$account->fill(Request::all()); $account->fill(Input::all());
$account->save(); $account->save();
Session::flash('message', trans('texts.updated_settings')); Session::flash('message', trans('texts.updated_settings'));
@ -949,10 +950,10 @@ class AccountController extends BaseController
{ {
$account = Auth::user()->account; $account = Auth::user()->account;
$account->show_product_notes = \Request::input('show_product_notes') ? true : false; $account->show_product_notes = Input::get('show_product_notes') ? true : false;
$account->fill_products = \Request::input('fill_products') ? true : false; $account->fill_products = Input::get('fill_products') ? true : false;
$account->update_products = \Request::input('update_products') ? true : false; $account->update_products = Input::get('update_products') ? true : false;
$account->convert_products = \Request::input('convert_products') ? true : false; $account->convert_products = Input::get('convert_products') ? true : false;
$account->save(); $account->save();
Session::flash('message', trans('texts.updated_settings')); Session::flash('message', trans('texts.updated_settings'));
@ -968,15 +969,15 @@ class AccountController extends BaseController
if (Auth::user()->account->hasFeature(FEATURE_INVOICE_SETTINGS)) { if (Auth::user()->account->hasFeature(FEATURE_INVOICE_SETTINGS)) {
$rules = []; $rules = [];
foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_CLIENT] as $entityType) { foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_CLIENT] as $entityType) {
if (\Request::input("{$entityType}_number_type") == 'pattern') { if (Input::get("{$entityType}_number_type") == 'pattern') {
$rules["{$entityType}_number_pattern"] = 'has_counter'; $rules["{$entityType}_number_pattern"] = 'has_counter';
} }
} }
if (\Request::input('credit_number_enabled')) { if (Input::get('credit_number_enabled')) {
$rules['credit_number_prefix'] = 'required_without:credit_number_pattern'; $rules['credit_number_prefix'] = 'required_without:credit_number_pattern';
$rules['credit_number_pattern'] = 'required_without:credit_number_prefix'; $rules['credit_number_pattern'] = 'required_without:credit_number_prefix';
} }
$validator = Validator::make(Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to('settings/'.ACCOUNT_INVOICE_SETTINGS) return Redirect::to('settings/'.ACCOUNT_INVOICE_SETTINGS)
@ -984,47 +985,47 @@ class AccountController extends BaseController
->withInput(); ->withInput();
} else { } else {
$account = Auth::user()->account; $account = Auth::user()->account;
$account->custom_value1 = \Request::input('custom_value1'); $account->custom_value1 = Input::get('custom_value1');
$account->custom_value2 = \Request::input('custom_value2'); $account->custom_value2 = Input::get('custom_value2');
$account->custom_invoice_taxes1 = \Request::input('custom_invoice_taxes1') ? true : false; $account->custom_invoice_taxes1 = Input::get('custom_invoice_taxes1') ? true : false;
$account->custom_invoice_taxes2 = \Request::input('custom_invoice_taxes2') ? true : false; $account->custom_invoice_taxes2 = Input::get('custom_invoice_taxes2') ? true : false;
$account->custom_fields = request()->custom_fields; $account->custom_fields = request()->custom_fields;
$account->invoice_number_padding = \Request::input('invoice_number_padding'); $account->invoice_number_padding = Input::get('invoice_number_padding');
$account->invoice_number_counter = \Request::input('invoice_number_counter'); $account->invoice_number_counter = Input::get('invoice_number_counter');
$account->quote_number_prefix = \Request::input('quote_number_prefix'); $account->quote_number_prefix = Input::get('quote_number_prefix');
$account->share_counter = \Request::input('share_counter') ? true : false; $account->share_counter = Input::get('share_counter') ? true : false;
$account->invoice_terms = \Request::input('invoice_terms'); $account->invoice_terms = Input::get('invoice_terms');
$account->invoice_footer = \Request::input('invoice_footer'); $account->invoice_footer = Input::get('invoice_footer');
$account->quote_terms = \Request::input('quote_terms'); $account->quote_terms = Input::get('quote_terms');
$account->auto_convert_quote = \Request::input('auto_convert_quote'); $account->auto_convert_quote = Input::get('auto_convert_quote');
$account->auto_archive_quote = \Request::input('auto_archive_quote'); $account->auto_archive_quote = Input::get('auto_archive_quote');
$account->auto_archive_invoice = \Request::input('auto_archive_invoice'); $account->auto_archive_invoice = Input::get('auto_archive_invoice');
$account->auto_email_invoice = \Request::input('auto_email_invoice'); $account->auto_email_invoice = Input::get('auto_email_invoice');
$account->recurring_invoice_number_prefix = \Request::input('recurring_invoice_number_prefix'); $account->recurring_invoice_number_prefix = Input::get('recurring_invoice_number_prefix');
$account->client_number_prefix = trim(\Request::input('client_number_prefix')); $account->client_number_prefix = trim(Input::get('client_number_prefix'));
$account->client_number_pattern = trim(\Request::input('client_number_pattern')); $account->client_number_pattern = trim(Input::get('client_number_pattern'));
$account->client_number_counter = \Request::input('client_number_counter'); $account->client_number_counter = Input::get('client_number_counter');
$account->credit_number_counter = \Request::input('credit_number_counter'); $account->credit_number_counter = Input::get('credit_number_counter');
$account->credit_number_prefix = trim(\Request::input('credit_number_prefix')); $account->credit_number_prefix = trim(Input::get('credit_number_prefix'));
$account->credit_number_pattern = trim(\Request::input('credit_number_pattern')); $account->credit_number_pattern = trim(Input::get('credit_number_pattern'));
$account->reset_counter_frequency_id = \Request::input('reset_counter_frequency_id'); $account->reset_counter_frequency_id = Input::get('reset_counter_frequency_id');
$account->reset_counter_date = $account->reset_counter_frequency_id ? Utils::toSqlDate(\Request::input('reset_counter_date')) : null; $account->reset_counter_date = $account->reset_counter_frequency_id ? Utils::toSqlDate(Input::get('reset_counter_date')) : null;
if (Request::has('recurring_hour')) { if (Input::has('recurring_hour')) {
$account->recurring_hour = \Request::input('recurring_hour'); $account->recurring_hour = Input::get('recurring_hour');
} }
if (! $account->share_counter) { if (! $account->share_counter) {
$account->quote_number_counter = \Request::input('quote_number_counter'); $account->quote_number_counter = Input::get('quote_number_counter');
} }
foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_CLIENT] as $entityType) { foreach ([ENTITY_INVOICE, ENTITY_QUOTE, ENTITY_CLIENT] as $entityType) {
if (\Request::input("{$entityType}_number_type") == 'prefix') { if (Input::get("{$entityType}_number_type") == 'prefix') {
$account->{"{$entityType}_number_prefix"} = trim(\Request::input("{$entityType}_number_prefix")); $account->{"{$entityType}_number_prefix"} = trim(Input::get("{$entityType}_number_prefix"));
$account->{"{$entityType}_number_pattern"} = null; $account->{"{$entityType}_number_pattern"} = null;
} else { } else {
$account->{"{$entityType}_number_pattern"} = trim(\Request::input("{$entityType}_number_pattern")); $account->{"{$entityType}_number_pattern"} = trim(Input::get("{$entityType}_number_pattern"));
$account->{"{$entityType}_number_prefix"} = null; $account->{"{$entityType}_number_prefix"} = null;
} }
} }
@ -1052,27 +1053,27 @@ class AccountController extends BaseController
{ {
if (Auth::user()->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN)) { if (Auth::user()->account->hasFeature(FEATURE_CUSTOMIZE_INVOICE_DESIGN)) {
$account = Auth::user()->account; $account = Auth::user()->account;
$account->hide_quantity = \Request::input('hide_quantity') ? true : false; $account->hide_quantity = Input::get('hide_quantity') ? true : false;
$account->hide_paid_to_date = \Request::input('hide_paid_to_date') ? true : false; $account->hide_paid_to_date = Input::get('hide_paid_to_date') ? true : false;
$account->all_pages_header = \Request::input('all_pages_header') ? true : false; $account->all_pages_header = Input::get('all_pages_header') ? true : false;
$account->all_pages_footer = \Request::input('all_pages_footer') ? true : false; $account->all_pages_footer = Input::get('all_pages_footer') ? true : false;
$account->invoice_embed_documents = \Request::input('invoice_embed_documents') ? true : false; $account->invoice_embed_documents = Input::get('invoice_embed_documents') ? true : false;
$account->header_font_id = \Request::input('header_font_id'); $account->header_font_id = Input::get('header_font_id');
$account->body_font_id = \Request::input('body_font_id'); $account->body_font_id = Input::get('body_font_id');
$account->primary_color = \Request::input('primary_color'); $account->primary_color = Input::get('primary_color');
$account->secondary_color = \Request::input('secondary_color'); $account->secondary_color = Input::get('secondary_color');
$account->invoice_design_id = \Request::input('invoice_design_id'); $account->invoice_design_id = Input::get('invoice_design_id');
$account->quote_design_id = \Request::input('quote_design_id'); $account->quote_design_id = Input::get('quote_design_id');
$account->font_size = intval(\Request::input('font_size')); $account->font_size = intval(Input::get('font_size'));
$account->page_size = \Request::input('page_size'); $account->page_size = Input::get('page_size');
$account->background_image_id = Document::getPrivateId(request()->background_image_id); $account->background_image_id = Document::getPrivateId(request()->background_image_id);
$labels = []; $labels = [];
foreach (Account::$customLabels as $field) { foreach (Account::$customLabels as $field) {
$labels[$field] = \Request::input("labels_{$field}"); $labels[$field] = Input::get("labels_{$field}");
} }
$account->invoice_labels = json_encode($labels); $account->invoice_labels = json_encode($labels);
$account->invoice_fields = \Request::input('invoice_fields_json'); $account->invoice_fields = Input::get('invoice_fields_json');
$account->save(); $account->save();
@ -1088,12 +1089,12 @@ class AccountController extends BaseController
private function saveNotifications() private function saveNotifications()
{ {
$user = Auth::user(); $user = Auth::user();
$user->notify_sent = \Request::input('notify_sent'); $user->notify_sent = Input::get('notify_sent');
$user->notify_viewed = \Request::input('notify_viewed'); $user->notify_viewed = Input::get('notify_viewed');
$user->notify_paid = \Request::input('notify_paid'); $user->notify_paid = Input::get('notify_paid');
$user->notify_approved = \Request::input('notify_approved'); $user->notify_approved = Input::get('notify_approved');
$user->only_notify_owned = \Request::input('only_notify_owned'); $user->only_notify_owned = Input::get('only_notify_owned');
$user->slack_webhook_url = \Request::input('slack_webhook_url'); $user->slack_webhook_url = Input::get('slack_webhook_url');
$user->save(); $user->save();
$account = $user->account; $account = $user->account;
@ -1116,8 +1117,8 @@ class AccountController extends BaseController
$this->accountRepo->save($request->input(), $account); $this->accountRepo->save($request->input(), $account);
/* Logo image file */ /* Logo image file */
if ($uploaded = Request::file('logo')) { if ($uploaded = Input::file('logo')) {
$path = Request::file('logo')->getRealPath(); $path = Input::file('logo')->getRealPath();
$disk = $account->getLogoDisk(); $disk = $account->getLogoDisk();
$extension = strtolower($uploaded->getClientOriginalExtension()); $extension = strtolower($uploaded->getClientOriginalExtension());
@ -1203,7 +1204,7 @@ class AccountController extends BaseController
{ {
/** @var \App\Models\User $user */ /** @var \App\Models\User $user */
$user = Auth::user(); $user = Auth::user();
$email = trim(strtolower(\Request::input('email'))); $email = trim(strtolower(Input::get('email')));
if (! \App\Models\LookupUser::validateField('email', $email, $user)) { if (! \App\Models\LookupUser::validateField('email', $email, $user)) {
return Redirect::to('settings/' . ACCOUNT_USER_DETAILS) return Redirect::to('settings/' . ACCOUNT_USER_DETAILS)
@ -1217,34 +1218,34 @@ class AccountController extends BaseController
$rules['phone'] = 'required'; $rules['phone'] = 'required';
} }
$validator = Validator::make(Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to('settings/'.ACCOUNT_USER_DETAILS) return Redirect::to('settings/'.ACCOUNT_USER_DETAILS)
->withErrors($validator) ->withErrors($validator)
->withInput(); ->withInput();
} else { } else {
$user->first_name = trim(\Request::input('first_name')); $user->first_name = trim(Input::get('first_name'));
$user->last_name = trim(\Request::input('last_name')); $user->last_name = trim(Input::get('last_name'));
$user->username = $email; $user->username = $email;
$user->email = $email; $user->email = $email;
$user->phone = trim(\Request::input('phone')); $user->phone = trim(Input::get('phone'));
$user->dark_mode = \Request::input('dark_mode'); $user->dark_mode = Input::get('dark_mode');
if (! Auth::user()->is_admin) { if (! Auth::user()->is_admin) {
$user->notify_sent = \Request::input('notify_sent'); $user->notify_sent = Input::get('notify_sent');
$user->notify_viewed = \Request::input('notify_viewed'); $user->notify_viewed = Input::get('notify_viewed');
$user->notify_paid = \Request::input('notify_paid'); $user->notify_paid = Input::get('notify_paid');
$user->notify_approved = \Request::input('notify_approved'); $user->notify_approved = Input::get('notify_approved');
$user->only_notify_owned = \Request::input('only_notify_owned'); $user->only_notify_owned = Input::get('only_notify_owned');
} }
if ($user->google_2fa_secret && ! \Request::input('enable_two_factor')) { if ($user->google_2fa_secret && ! Input::get('enable_two_factor')) {
$user->google_2fa_secret = null; $user->google_2fa_secret = null;
} }
if (Utils::isNinja()) { if (Utils::isNinja()) {
if (\Request::input('referral_code') && ! $user->referral_code) { if (Input::get('referral_code') && ! $user->referral_code) {
$user->referral_code = strtolower(str_random(RANDOM_KEY_LENGTH)); $user->referral_code = strtolower(str_random(RANDOM_KEY_LENGTH));
} }
} }
@ -1266,15 +1267,15 @@ class AccountController extends BaseController
/** @var \App\Models\Account $account */ /** @var \App\Models\Account $account */
$account = Auth::user()->account; $account = Auth::user()->account;
$account->timezone_id = \Request::input('timezone_id') ? \Request::input('timezone_id') : null; $account->timezone_id = Input::get('timezone_id') ? Input::get('timezone_id') : null;
$account->date_format_id = \Request::input('date_format_id') ? \Request::input('date_format_id') : null; $account->date_format_id = Input::get('date_format_id') ? Input::get('date_format_id') : null;
$account->datetime_format_id = \Request::input('datetime_format_id') ? \Request::input('datetime_format_id') : null; $account->datetime_format_id = Input::get('datetime_format_id') ? Input::get('datetime_format_id') : null;
$account->currency_id = \Request::input('currency_id') ? \Request::input('currency_id') : 1; // US Dollar $account->currency_id = Input::get('currency_id') ? Input::get('currency_id') : 1; // US Dollar
$account->language_id = \Request::input('language_id') ? \Request::input('language_id') : 1; // English $account->language_id = Input::get('language_id') ? Input::get('language_id') : 1; // English
$account->military_time = \Request::input('military_time') ? true : false; $account->military_time = Input::get('military_time') ? true : false;
$account->show_currency_code = \Request::input('show_currency_code') ? true : false; $account->show_currency_code = Input::get('show_currency_code') ? true : false;
$account->start_of_week = \Request::input('start_of_week') ? \Request::input('start_of_week') : 0; $account->start_of_week = Input::get('start_of_week') ? Input::get('start_of_week') : 0;
$account->financial_year_start = \Request::input('financial_year_start') ? \Request::input('financial_year_start') : null; $account->financial_year_start = Input::get('financial_year_start') ? Input::get('financial_year_start') : null;
$account->save(); $account->save();
event(new UserSettingsChanged()); event(new UserSettingsChanged());
@ -1290,10 +1291,10 @@ class AccountController extends BaseController
private function saveOnlinePayments() private function saveOnlinePayments()
{ {
$account = Auth::user()->account; $account = Auth::user()->account;
$account->token_billing_type_id = \Request::input('token_billing_type_id'); $account->token_billing_type_id = Input::get('token_billing_type_id');
$account->auto_bill_on_due_date = boolval(\Request::input('auto_bill_on_due_date')); $account->auto_bill_on_due_date = boolval(Input::get('auto_bill_on_due_date'));
$account->gateway_fee_enabled = boolval(\Request::input('gateway_fee_enabled')); $account->gateway_fee_enabled = boolval(Input::get('gateway_fee_enabled'));
$account->send_item_details = boolval(\Request::input('send_item_details')); $account->send_item_details = boolval(Input::get('send_item_details'));
$account->save(); $account->save();
@ -1331,7 +1332,7 @@ class AccountController extends BaseController
*/ */
public function checkEmail() public function checkEmail()
{ {
$email = trim(strtolower(\Request::input('email'))); $email = trim(strtolower(Input::get('email')));
$user = Auth::user(); $user = Auth::user();
if (! \App\Models\LookupUser::validateField('email', $email, $user)) { if (! \App\Models\LookupUser::validateField('email', $email, $user)) {
@ -1369,16 +1370,16 @@ class AccountController extends BaseController
$rules['new_email'] .= ',' . Auth::user()->id . ',id'; $rules['new_email'] .= ',' . Auth::user()->id . ',id';
} }
$validator = Validator::make(Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return ''; return '';
} }
$firstName = trim(\Request::input('new_first_name')); $firstName = trim(Input::get('new_first_name'));
$lastName = trim(\Request::input('new_last_name')); $lastName = trim(Input::get('new_last_name'));
$email = trim(strtolower(\Request::input('new_email'))); $email = trim(strtolower(Input::get('new_email')));
$password = trim(\Request::input('new_password')); $password = trim(Input::get('new_password'));
if (! \App\Models\LookupUser::validateField('email', $email, $user)) { if (! \App\Models\LookupUser::validateField('email', $email, $user)) {
return ''; return '';
@ -1407,7 +1408,7 @@ class AccountController extends BaseController
$user->account->startTrial(PLAN_PRO); $user->account->startTrial(PLAN_PRO);
if (\Request::input('go_pro') == 'true') { if (Input::get('go_pro') == 'true') {
session([REQUESTED_PRO_PLAN => true]); session([REQUESTED_PRO_PLAN => true]);
} }
@ -1421,15 +1422,15 @@ class AccountController extends BaseController
public function doRegister() public function doRegister()
{ {
$affiliate = Affiliate::where('affiliate_key', '=', SELF_HOST_AFFILIATE_KEY)->first(); $affiliate = Affiliate::where('affiliate_key', '=', SELF_HOST_AFFILIATE_KEY)->first();
$email = trim(\Request::input('email')); $email = trim(Input::get('email'));
if (! $email || $email == TEST_USERNAME) { if (! $email || $email == TEST_USERNAME) {
return RESULT_FAILURE; return RESULT_FAILURE;
} }
$license = new License(); $license = new License();
$license->first_name = \Request::input('first_name'); $license->first_name = Input::get('first_name');
$license->last_name = \Request::input('last_name'); $license->last_name = Input::get('last_name');
$license->email = $email; $license->email = $email;
$license->transaction_reference = Request::getClientIp(); $license->transaction_reference = Request::getClientIp();
$license->license_key = Utils::generateLicense(); $license->license_key = Utils::generateLicense();
@ -1456,7 +1457,7 @@ class AccountController extends BaseController
*/ */
public function cancelAccount() public function cancelAccount()
{ {
if ($reason = trim(\Request::input('reason'))) { if ($reason = trim(Input::get('reason'))) {
$email = Auth::user()->email; $email = Auth::user()->email;
$name = Auth::user()->getDisplayName(); $name = Auth::user()->getDisplayName();
@ -1549,7 +1550,7 @@ class AccountController extends BaseController
*/ */
public function previewEmail(TemplateService $templateService) public function previewEmail(TemplateService $templateService)
{ {
$template = \Request::input('template'); $template = Input::get('template');
$invitation = \App\Models\Invitation::scope() $invitation = \App\Models\Invitation::scope()
->with('invoice.client.contacts') ->with('invoice.client.contacts')
->first(); ->first();

View file

@ -8,8 +8,8 @@ use App\Models\AccountGateway;
use App\Models\Gateway; use App\Models\Gateway;
use App\Services\AccountGatewayService; use App\Services\AccountGatewayService;
use Auth; use Auth;
use Input;
use Redirect; use Redirect;
use Request;
use Session; use Session;
use stdClass; use stdClass;
use URL; use URL;
@ -88,9 +88,9 @@ class AccountGatewayController extends BaseController
Session::now('warning', trans('texts.enable_https')); Session::now('warning', trans('texts.enable_https'));
} }
$account = Auth::user()->account; $account = Auth::user()->account;
$accountGatewaysIds = $account->gatewayIds(); $accountGatewaysIds = $account->gatewayIds();
$wepay = \Request::input('wepay'); $wepay = Input::get('wepay');
$data = self::getViewModel(); $data = self::getViewModel();
$data['url'] = 'gateways'; $data['url'] = 'gateways';
@ -158,9 +158,9 @@ class AccountGatewayController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action'); $action = Input::get('bulk_action');
$ids = \Request::input('bulk_public_id'); $ids = Input::get('bulk_public_id');
$count = $this->accountGatewayService->bulk($ids, $action); $count = $this->accountGatewayService->bulk($ids, $action);
Session::flash('message', trans("texts.{$action}d_account_gateway")); Session::flash('message', trans("texts.{$action}d_account_gateway"));
@ -174,8 +174,8 @@ class AccountGatewayController extends BaseController
*/ */
public function save($accountGatewayPublicId = false) public function save($accountGatewayPublicId = false)
{ {
$gatewayId = \Request::input('primary_gateway_id') ?: \Request::input('secondary_gateway_id'); $gatewayId = Input::get('primary_gateway_id') ?: Input::get('secondary_gateway_id');
$gateway = Gateway::findOrFail($gatewayId); $gateway = Gateway::findOrFail($gatewayId);
$rules = []; $rules = [];
$fields = $gateway->getFields(); $fields = $gateway->getFields();
@ -208,16 +208,16 @@ class AccountGatewayController extends BaseController
} }
} }
$creditcards = \Request::input('creditCardTypes'); $creditcards = Input::get('creditCardTypes');
$validator = Validator::make(Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
$url = $accountGatewayPublicId ? "/gateways/{$accountGatewayPublicId}/edit" : 'gateways/create?other_providers=' . ($gatewayId == GATEWAY_WEPAY ? 'false' : 'true'); $url = $accountGatewayPublicId ? "/gateways/{$accountGatewayPublicId}/edit" : 'gateways/create?other_providers=' . ($gatewayId == GATEWAY_WEPAY ? 'false' : 'true');
return Redirect::to($url) return Redirect::to($url)
->withErrors($validator) ->withErrors($validator)
->withInput(); ->withInput();
} else { } else {
$account = Account::with('account_gateways')->findOrFail(Auth::user()->account_id); $account = Account::with('account_gateways')->findOrFail(Auth::user()->account_id);
$oldConfig = null; $oldConfig = null;
if ($accountGatewayPublicId) { if ($accountGatewayPublicId) {
@ -250,7 +250,7 @@ class AccountGatewayController extends BaseController
if ($gatewayId != GATEWAY_WEPAY) { if ($gatewayId != GATEWAY_WEPAY) {
foreach ($fields as $field => $details) { foreach ($fields as $field => $details) {
$value = trim(\Request::input($gateway->id . '_' . $field)); $value = trim(Input::get($gateway->id . '_' . $field));
// if the new value is masked use the original value // if the new value is masked use the original value
if ($oldConfig && $value && $value === str_repeat('*', strlen($value))) { if ($oldConfig && $value && $value === str_repeat('*', strlen($value))) {
$value = $oldConfig->$field; $value = $oldConfig->$field;
@ -265,28 +265,28 @@ class AccountGatewayController extends BaseController
$config = clone $oldConfig; $config = clone $oldConfig;
} }
$publishableKey = trim(\Request::input('publishable_key')); $publishableKey = trim(Input::get('publishable_key'));
if ($publishableKey = str_replace('*', '', $publishableKey)) { if ($publishableKey = str_replace('*', '', $publishableKey)) {
$config->publishableKey = $publishableKey; $config->publishableKey = $publishableKey;
} elseif ($oldConfig && property_exists($oldConfig, 'publishableKey')) { } elseif ($oldConfig && property_exists($oldConfig, 'publishableKey')) {
$config->publishableKey = $oldConfig->publishableKey; $config->publishableKey = $oldConfig->publishableKey;
} }
$plaidClientId = trim(\Request::input('plaid_client_id')); $plaidClientId = trim(Input::get('plaid_client_id'));
if (! $plaidClientId || $plaidClientId = str_replace('*', '', $plaidClientId)) { if (! $plaidClientId || $plaidClientId = str_replace('*', '', $plaidClientId)) {
$config->plaidClientId = $plaidClientId; $config->plaidClientId = $plaidClientId;
} elseif ($oldConfig && property_exists($oldConfig, 'plaidClientId')) { } elseif ($oldConfig && property_exists($oldConfig, 'plaidClientId')) {
$config->plaidClientId = $oldConfig->plaidClientId; $config->plaidClientId = $oldConfig->plaidClientId;
} }
$plaidSecret = trim(\Request::input('plaid_secret')); $plaidSecret = trim(Input::get('plaid_secret'));
if (! $plaidSecret || $plaidSecret = str_replace('*', '', $plaidSecret)) { if (! $plaidSecret || $plaidSecret = str_replace('*', '', $plaidSecret)) {
$config->plaidSecret = $plaidSecret; $config->plaidSecret = $plaidSecret;
} elseif ($oldConfig && property_exists($oldConfig, 'plaidSecret')) { } elseif ($oldConfig && property_exists($oldConfig, 'plaidSecret')) {
$config->plaidSecret = $oldConfig->plaidSecret; $config->plaidSecret = $oldConfig->plaidSecret;
} }
$plaidPublicKey = trim(\Request::input('plaid_public_key')); $plaidPublicKey = trim(Input::get('plaid_public_key'));
if (! $plaidPublicKey || $plaidPublicKey = str_replace('*', '', $plaidPublicKey)) { if (! $plaidPublicKey || $plaidPublicKey = str_replace('*', '', $plaidPublicKey)) {
$config->plaidPublicKey = $plaidPublicKey; $config->plaidPublicKey = $plaidPublicKey;
} elseif ($oldConfig && property_exists($oldConfig, 'plaidPublicKey')) { } elseif ($oldConfig && property_exists($oldConfig, 'plaidPublicKey')) {
@ -294,11 +294,11 @@ class AccountGatewayController extends BaseController
} }
if ($gatewayId == GATEWAY_STRIPE) { if ($gatewayId == GATEWAY_STRIPE) {
$config->enableAlipay = boolval(\Request::input('enable_alipay')); $config->enableAlipay = boolval(Input::get('enable_alipay'));
$config->enableSofort = boolval(\Request::input('enable_sofort')); $config->enableSofort = boolval(Input::get('enable_sofort'));
$config->enableSepa = boolval(\Request::input('enable_sepa')); $config->enableSepa = boolval(Input::get('enable_sepa'));
$config->enableBitcoin = boolval(\Request::input('enable_bitcoin')); $config->enableBitcoin = boolval(Input::get('enable_bitcoin'));
$config->enableApplePay = boolval(\Request::input('enable_apple_pay')); $config->enableApplePay = boolval(Input::get('enable_apple_pay'));
if ($config->enableApplePay && $uploadedFile = request()->file('apple_merchant_id')) { if ($config->enableApplePay && $uploadedFile = request()->file('apple_merchant_id')) {
$config->appleMerchantId = File::get($uploadedFile); $config->appleMerchantId = File::get($uploadedFile);
@ -308,11 +308,11 @@ class AccountGatewayController extends BaseController
} }
if ($gatewayId == GATEWAY_STRIPE || $gatewayId == GATEWAY_WEPAY) { if ($gatewayId == GATEWAY_STRIPE || $gatewayId == GATEWAY_WEPAY) {
$config->enableAch = boolval(\Request::input('enable_ach')); $config->enableAch = boolval(Input::get('enable_ach'));
} }
if ($gatewayId == GATEWAY_BRAINTREE) { if ($gatewayId == GATEWAY_BRAINTREE) {
$config->enablePayPal = boolval(\Request::input('enable_paypal')); $config->enablePayPal = boolval(Input::get('enable_paypal'));
} }
$cardCount = 0; $cardCount = 0;
@ -323,9 +323,9 @@ class AccountGatewayController extends BaseController
} }
$accountGateway->accepted_credit_cards = $cardCount; $accountGateway->accepted_credit_cards = $cardCount;
$accountGateway->show_address = \Request::input('show_address') ? true : false; $accountGateway->show_address = Input::get('show_address') ? true : false;
$accountGateway->show_shipping_address = \Request::input('show_shipping_address') ? true : false; $accountGateway->show_shipping_address = Input::get('show_shipping_address') ? true : false;
$accountGateway->update_address = \Request::input('update_address') ? true : false; $accountGateway->update_address = Input::get('update_address') ? true : false;
$accountGateway->setConfig($config); $accountGateway->setConfig($config);
if ($accountGatewayPublicId) { if ($accountGatewayPublicId) {
@ -395,7 +395,7 @@ class AccountGatewayController extends BaseController
'country' => 'required|in:US,CA,GB', 'country' => 'required|in:US,CA,GB',
]; ];
$validator = Validator::make(Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to('gateways/create') return Redirect::to('gateways/create')
@ -404,9 +404,9 @@ class AccountGatewayController extends BaseController
} }
if (! $user->email) { if (! $user->email) {
$user->email = trim(\Request::input('email')); $user->email = trim(Input::get('email'));
$user->first_name = trim(\Request::input('first_name')); $user->first_name = trim(Input::get('first_name'));
$user->last_name = trim(\Request::input('last_name')); $user->last_name = trim(Input::get('last_name'));
$user->save(); $user->save();
} }
@ -414,16 +414,16 @@ class AccountGatewayController extends BaseController
$wepay = Utils::setupWePay(); $wepay = Utils::setupWePay();
$userDetails = [ $userDetails = [
'client_id' => WEPAY_CLIENT_ID, 'client_id' => WEPAY_CLIENT_ID,
'client_secret' => WEPAY_CLIENT_SECRET, 'client_secret' => WEPAY_CLIENT_SECRET,
'email' => \Request::input('email'), 'email' => Input::get('email'),
'first_name' => \Request::input('first_name'), 'first_name' => Input::get('first_name'),
'last_name' => \Request::input('last_name'), 'last_name' => Input::get('last_name'),
'original_ip' => \Request::getClientIp(true), 'original_ip' => \Request::getClientIp(true),
'original_device' => \Request::server('HTTP_USER_AGENT'), 'original_device' => \Request::server('HTTP_USER_AGENT'),
'tos_acceptance_time' => time(), 'tos_acceptance_time' => time(),
'redirect_uri' => URL::to('gateways'), 'redirect_uri' => URL::to('gateways'),
'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money', 'scope' => 'manage_accounts,collect_payments,view_user,preapprove_payments,send_money',
]; ];
$wepayUser = $wepay->request('user/register/', $userDetails); $wepayUser = $wepay->request('user/register/', $userDetails);
@ -434,18 +434,18 @@ class AccountGatewayController extends BaseController
$wepay = new WePay($accessToken); $wepay = new WePay($accessToken);
$accountDetails = [ $accountDetails = [
'name' => \Request::input('company_name'), 'name' => Input::get('company_name'),
'description' => trans('texts.wepay_account_description'), 'description' => trans('texts.wepay_account_description'),
'theme_object' => json_decode(WEPAY_THEME), 'theme_object' => json_decode(WEPAY_THEME),
'callback_uri' => $accountGateway->getWebhookUrl(), 'callback_uri' => $accountGateway->getWebhookUrl(),
'rbits' => $account->present()->rBits, 'rbits' => $account->present()->rBits,
'country' => \Request::input('country'), 'country' => Input::get('country'),
]; ];
if (\Request::input('country') == 'CA') { if (Input::get('country') == 'CA') {
$accountDetails['currencies'] = ['CAD']; $accountDetails['currencies'] = ['CAD'];
$accountDetails['country_options'] = ['debit_opt_in' => boolval(\Request::input('debit_cards'))]; $accountDetails['country_options'] = ['debit_opt_in' => boolval(Input::get('debit_cards'))];
} elseif (\Request::input('country') == 'GB') { } elseif (Input::get('country') == 'GB') {
$accountDetails['currencies'] = ['GBP']; $accountDetails['currencies'] = ['GBP'];
} }
@ -464,14 +464,14 @@ class AccountGatewayController extends BaseController
$accountGateway->gateway_id = GATEWAY_WEPAY; $accountGateway->gateway_id = GATEWAY_WEPAY;
$accountGateway->setConfig([ $accountGateway->setConfig([
'userId' => $wepayUser->user_id, 'userId' => $wepayUser->user_id,
'accessToken' => $accessToken, 'accessToken' => $accessToken,
'tokenType' => $wepayUser->token_type, 'tokenType' => $wepayUser->token_type,
'tokenExpires' => $accessTokenExpires, 'tokenExpires' => $accessTokenExpires,
'accountId' => $wepayAccount->account_id, 'accountId' => $wepayAccount->account_id,
'state' => $wepayAccount->state, 'state' => $wepayAccount->state,
'testMode' => WEPAY_ENVIRONMENT == WEPAY_STAGE, 'testMode' => WEPAY_ENVIRONMENT == WEPAY_STAGE,
'country' => \Request::input('country'), 'country' => Input::get('country'),
]); ]);
if ($confirmationRequired) { if ($confirmationRequired) {
@ -522,22 +522,22 @@ class AccountGatewayController extends BaseController
*/ */
public function savePaymentGatewayLimits() public function savePaymentGatewayLimits()
{ {
$gateway_type_id = intval(\Request::input('gateway_type_id')); $gateway_type_id = intval(Input::get('gateway_type_id'));
$gateway_settings = AccountGatewaySettings::scope()->where('gateway_type_id', '=', $gateway_type_id)->first(); $gateway_settings = AccountGatewaySettings::scope()->where('gateway_type_id', '=', $gateway_type_id)->first();
if ( ! $gateway_settings) { if (! $gateway_settings) {
$gateway_settings = AccountGatewaySettings::createNew(); $gateway_settings = AccountGatewaySettings::createNew();
$gateway_settings->gateway_type_id = $gateway_type_id; $gateway_settings->gateway_type_id = $gateway_type_id;
} }
$gateway_settings->min_limit = \Request::input('limit_min_enable') ? intval(\Request::input('limit_min')) : null; $gateway_settings->min_limit = Input::get('limit_min_enable') ? intval(Input::get('limit_min')) : null;
$gateway_settings->max_limit = \Request::input('limit_max_enable') ? intval(\Request::input('limit_max')) : null; $gateway_settings->max_limit = Input::get('limit_max_enable') ? intval(Input::get('limit_max')) : null;
if ($gateway_settings->max_limit !== null && $gateway_settings->min_limit > $gateway_settings->max_limit) { if ($gateway_settings->max_limit !== null && $gateway_settings->min_limit > $gateway_settings->max_limit) {
$gateway_settings->max_limit = $gateway_settings->min_limit; $gateway_settings->max_limit = $gateway_settings->min_limit;
} }
$gateway_settings->fill(Request::all()); $gateway_settings->fill(Input::all());
$gateway_settings->save(); $gateway_settings->save();
Session::flash('message', trans('texts.updated_settings')); Session::flash('message', trans('texts.updated_settings'));

View file

@ -16,6 +16,7 @@ use Config;
use DB; use DB;
use Event; use Event;
use Exception; use Exception;
use Input;
use Redirect; use Redirect;
use Response; use Response;
use Session; use Session;
@ -57,17 +58,17 @@ class AppController extends BaseController
} }
$valid = false; $valid = false;
$test = \Request::input('test'); $test = Input::get('test');
$app = \Request::input('app'); $app = Input::get('app');
$app['key'] = env('APP_KEY') ?: strtolower(str_random(RANDOM_KEY_LENGTH)); $app['key'] = env('APP_KEY') ?: strtolower(str_random(RANDOM_KEY_LENGTH));
$app['debug'] = \Request::input('debug') ? 'true' : 'false'; $app['debug'] = Input::get('debug') ? 'true' : 'false';
$app['https'] = \Request::input('https') ? 'true' : 'false'; $app['https'] = Input::get('https') ? 'true' : 'false';
$database = \Request::input('database'); $database = Input::get('database');
$dbType = 'mysql'; // $database['default']; $dbType = 'mysql'; // $database['default'];
$database['connections'] = [$dbType => $database['type']]; $database['connections'] = [$dbType => $database['type']];
$mail = \Request::input('mail'); $mail = Input::get('mail');
if ($test == 'mail') { if ($test == 'mail') {
return self::testMail($mail); return self::testMail($mail);
@ -136,10 +137,10 @@ class AppController extends BaseController
Artisan::call('db:seed', ['--force' => true, '--class' => 'UpdateSeeder']); Artisan::call('db:seed', ['--force' => true, '--class' => 'UpdateSeeder']);
if (! Account::count()) { if (! Account::count()) {
$firstName = trim(\Request::input('first_name')); $firstName = trim(Input::get('first_name'));
$lastName = trim(\Request::input('last_name')); $lastName = trim(Input::get('last_name'));
$email = trim(strtolower(\Request::input('email'))); $email = trim(strtolower(Input::get('email')));
$password = trim(\Request::input('password')); $password = trim(Input::get('password'));
$account = $this->accountRepo->create($firstName, $lastName, $email, $password); $account = $this->accountRepo->create($firstName, $lastName, $email, $password);
$user = $account->users()->first(); $user = $account->users()->first();
@ -166,13 +167,13 @@ class AppController extends BaseController
return Redirect::to('/settings/system_settings'); return Redirect::to('/settings/system_settings');
} }
$app = \Request::input('app'); $app = Input::get('app');
$db = \Request::input('database'); $db = Input::get('database');
$mail = \Request::input('mail'); $mail = Input::get('mail');
$_ENV['APP_URL'] = $app['url']; $_ENV['APP_URL'] = $app['url'];
$_ENV['APP_DEBUG'] = \Request::input('debug') ? 'true' : 'false'; $_ENV['APP_DEBUG'] = Input::get('debug') ? 'true' : 'false';
$_ENV['REQUIRE_HTTPS'] = \Request::input('https') ? 'true' : 'false'; $_ENV['REQUIRE_HTTPS'] = Input::get('https') ? 'true' : 'false';
$_ENV['DB_TYPE'] = 'mysql'; // $db['default']; $_ENV['DB_TYPE'] = 'mysql'; // $db['default'];
$_ENV['DB_HOST'] = $db['type']['host']; $_ENV['DB_HOST'] = $db['type']['host'];
@ -313,7 +314,7 @@ class AppController extends BaseController
Session::flush(); Session::flush();
Artisan::call('migrate', ['--force' => true]); Artisan::call('migrate', ['--force' => true]);
Artisan::call('db:seed', ['--force' => true, '--class' => 'UpdateSeeder']); Artisan::call('db:seed', ['--force' => true, '--class' => 'UpdateSeeder']);
Event::dispatch(new UserSettingsChanged()); Event::fire(new UserSettingsChanged());
// legacy fix: check cipher is in .env file // legacy fix: check cipher is in .env file
if (! env('APP_CIPHER')) { if (! env('APP_CIPHER')) {
@ -345,12 +346,7 @@ class AppController extends BaseController
FROM information_schema.TABLES FROM information_schema.TABLES
WHERE TABLE_NAME='clients' AND TABLE_SCHEMA='ninja'"); WHERE TABLE_NAME='clients' AND TABLE_SCHEMA='ninja'");
if(property_exists($result[0], 'engine')) if (count($result) && $result[0]->engine == 'InnoDB') {
$engine = $result[0]->engine;
else
$engine = $result[0]->ENGINE;
if (count($result) && $engine == 'InnoDB') {
return; return;
} }
@ -367,15 +363,15 @@ class AppController extends BaseController
public function emailBounced() public function emailBounced()
{ {
$messageId = \Request::input('MessageID'); $messageId = Input::get('MessageID');
$error = \Request::input('Name') . ': ' . \Request::input('Description'); $error = Input::get('Name') . ': ' . Input::get('Description');
return $this->emailService->markBounced($messageId, $error) ? RESULT_SUCCESS : RESULT_FAILURE; return $this->emailService->markBounced($messageId, $error) ? RESULT_SUCCESS : RESULT_FAILURE;
} }
public function emailOpened() public function emailOpened()
{ {
$messageId = \Request::input('MessageID'); $messageId = Input::get('MessageID');
return $this->emailService->markOpened($messageId) ? RESULT_SUCCESS : RESULT_FAILURE; return $this->emailService->markOpened($messageId) ? RESULT_SUCCESS : RESULT_FAILURE;
@ -413,7 +409,7 @@ class AppController extends BaseController
public function stats() public function stats()
{ {
if (! hash_equals(\Request::input('password') ?: '', env('RESELLER_PASSWORD'))) { if (! hash_equals(Input::get('password') ?: '', env('RESELLER_PASSWORD'))) {
sleep(3); sleep(3);
return ''; return '';

View file

@ -158,7 +158,7 @@ class LoginController extends Controller
} }
} }
Event::dispatch(new UserLoggedIn()); Event::fire(new UserLoggedIn());
return redirect()->intended($this->redirectTo); return redirect()->intended($this->redirectTo);
} }
@ -188,11 +188,11 @@ class LoginController extends Controller
$key = $userId . ':' . $request->totp; $key = $userId . ':' . $request->totp;
//use cache to store token to blacklist //use cache to store token to blacklist
Cache::add($key, true, 4 * 60); Cache::add($key, true, 4);
//login and redirect user //login and redirect user
auth()->loginUsingId($userId); auth()->loginUsingId($userId);
Event::dispatch(new UserLoggedIn()); Event::fire(new UserLoggedIn());
if ($trust = request()->trust) { if ($trust = request()->trust) {
$user = auth()->user(); $user = auth()->user();

View file

@ -42,7 +42,7 @@ class ResetPasswordController extends Controller
$this->middleware('guest'); $this->middleware('guest');
} }
protected function sendResetResponse(Request $request, $response) protected function sendResetResponse($response)
{ {
$user = auth()->user(); $user = auth()->user();
@ -51,8 +51,8 @@ class ResetPasswordController extends Controller
session(['2fa:user:id' => $user->id]); session(['2fa:user:id' => $user->id]);
return redirect('/validate_two_factor/' . $user->account->account_key); return redirect('/validate_two_factor/' . $user->account->account_key);
} else { } else {
Event::dispatch(new UserLoggedIn()); Event::fire(new UserLoggedIn());
return $this->traitSendResetResponse($request, $response); return $this->traitSendResetResponse($response);
} }
} }

View file

@ -12,6 +12,7 @@ use Cache;
use Crypt; use Crypt;
use File; use File;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use Utils; use Utils;
@ -73,8 +74,8 @@ class BankAccountController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action'); $action = Input::get('bulk_action');
$ids = \Request::input('bulk_public_id'); $ids = Input::get('bulk_public_id');
$count = $this->bankAccountService->bulk($ids, $action); $count = $this->bankAccountService->bulk($ids, $action);
Session::flash('message', trans('texts.archived_bank_account')); Session::flash('message', trans('texts.archived_bank_account'));
@ -84,9 +85,9 @@ class BankAccountController extends BaseController
public function validateAccount() public function validateAccount()
{ {
$publicId = \Request::input('public_id'); $publicId = Input::get('public_id');
$username = trim(\Request::input('bank_username')); $username = trim(Input::get('bank_username'));
$password = trim(\Request::input('bank_password')); $password = trim(Input::get('bank_password'));
if ($publicId) { if ($publicId) {
$bankAccount = BankAccount::scope($publicId)->firstOrFail(); $bankAccount = BankAccount::scope($publicId)->firstOrFail();
@ -99,11 +100,11 @@ class BankAccountController extends BaseController
$bankId = $bankAccount->bank_id; $bankId = $bankAccount->bank_id;
} else { } else {
$bankAccount = new BankAccount; $bankAccount = new BankAccount;
$bankAccount->bank_id = \Request::input('bank_id'); $bankAccount->bank_id = Input::get('bank_id');
} }
$bankAccount->app_version = \Request::input('app_version'); $bankAccount->app_version = Input::get('app_version');
$bankAccount->ofx_version = \Request::input('ofx_version'); $bankAccount->ofx_version = Input::get('ofx_version');
if ($publicId) { if ($publicId) {
$bankAccount->save(); $bankAccount->save();
@ -114,18 +115,18 @@ class BankAccountController extends BaseController
public function store(CreateBankAccountRequest $request) public function store(CreateBankAccountRequest $request)
{ {
$bankAccount = $this->bankAccountRepo->save(Request::all()); $bankAccount = $this->bankAccountRepo->save(Input::all());
$bankId = \Request::input('bank_id'); $bankId = Input::get('bank_id');
$username = trim(\Request::input('bank_username')); $username = trim(Input::get('bank_username'));
$password = trim(\Request::input('bank_password')); $password = trim(Input::get('bank_password'));
return json_encode($this->bankAccountService->loadBankAccounts($bankAccount, $username, $password, true)); return json_encode($this->bankAccountService->loadBankAccounts($bankAccount, $username, $password, true));
} }
public function importExpenses($bankId) public function importExpenses($bankId)
{ {
return $this->bankAccountService->importExpenses($bankId, Request::all()); return $this->bankAccountService->importExpenses($bankId, Input::all());
} }
public function showImportOFX() public function showImportOFX()

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Models\EntityModel; use App\Models\EntityModel;
use App\Ninja\Serializers\ArraySerializer; use App\Ninja\Serializers\ArraySerializer;
use Auth; use Auth;
use Input;
use League\Fractal\Manager; use League\Fractal\Manager;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection; use League\Fractal\Resource\Collection;
@ -23,7 +24,7 @@ use Utils;
* @SWG\Info( * @SWG\Info(
* version="1.0.0", * version="1.0.0",
* title="Invoice Ninja API", * title="Invoice Ninja API",
* description="A source-available invoicing and time-tracking app built with Laravel", * description="An open-source invoicing and time-tracking app built with Laravel",
* termsOfService="", * termsOfService="",
* @SWG\Contact( * @SWG\Contact(
* email="contact@invoiceninja.com" * email="contact@invoiceninja.com"
@ -55,11 +56,11 @@ class BaseAPIController extends Controller
{ {
$this->manager = new Manager(); $this->manager = new Manager();
if ($include = \Request::get('include')) { if ($include = Request::get('include')) {
$this->manager->parseIncludes($include); $this->manager->parseIncludes($include);
} }
$this->serializer = \Request::get('serializer') ?: API_SERIALIZER_ARRAY; $this->serializer = Request::get('serializer') ?: API_SERIALIZER_ARRAY;
if ($this->serializer === API_SERIALIZER_JSON) { if ($this->serializer === API_SERIALIZER_JSON) {
$this->manager->setSerializer(new JsonApiSerializer()); $this->manager->setSerializer(new JsonApiSerializer());
@ -91,24 +92,24 @@ class BaseAPIController extends Controller
protected function listResponse($query) protected function listResponse($query)
{ {
$transformerClass = EntityModel::getTransformerName($this->entityType); $transformerClass = EntityModel::getTransformerName($this->entityType);
$transformer = new $transformerClass(Auth::user()->account, \Request::input('serializer')); $transformer = new $transformerClass(Auth::user()->account, Input::get('serializer'));
$includes = $transformer->getDefaultIncludes(); $includes = $transformer->getDefaultIncludes();
$includes = $this->getRequestIncludes($includes); $includes = $this->getRequestIncludes($includes);
$query->with($includes); $query->with($includes);
if (\Request::input('filter_active')) { if (Input::get('filter_active')) {
$query->whereNull('deleted_at'); $query->whereNull('deleted_at');
} }
if (\Request::input('updated_at') > 0) { if (Input::get('updated_at') > 0) {
$updatedAt = intval(\Request::input('updated_at')); $updatedAt = intval(Input::get('updated_at'));
$query->where('updated_at', '>=', date('Y-m-d H:i:s', $updatedAt)); $query->where('updated_at', '>=', date('Y-m-d H:i:s', $updatedAt));
} }
if (\Request::input('client_id') > 0) { if (Input::get('client_id') > 0) {
$clientPublicId = \Request::input('client_id'); $clientPublicId = Input::get('client_id');
$filter = function ($query) use ($clientPublicId) { $filter = function ($query) use ($clientPublicId) {
$query->where('public_id', '=', $clientPublicId); $query->where('public_id', '=', $clientPublicId);
}; };
@ -135,7 +136,7 @@ class BaseAPIController extends Controller
} }
$transformerClass = EntityModel::getTransformerName($this->entityType); $transformerClass = EntityModel::getTransformerName($this->entityType);
$transformer = new $transformerClass(Auth::user()->account, \Request::input('serializer')); $transformer = new $transformerClass(Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($item, $transformer, $this->entityType); $data = $this->createItem($item, $transformer, $this->entityType);
@ -160,7 +161,7 @@ class BaseAPIController extends Controller
} }
if (is_a($query, "Illuminate\Database\Eloquent\Builder")) { if (is_a($query, "Illuminate\Database\Eloquent\Builder")) {
$limit = \Request::input('per_page', DEFAULT_API_PAGE_SIZE); $limit = Input::get('per_page', DEFAULT_API_PAGE_SIZE);
if (Utils::isNinja()) { if (Utils::isNinja()) {
$limit = min(MAX_API_PAGE_SIZE, $limit); $limit = min(MAX_API_PAGE_SIZE, $limit);
} }
@ -177,7 +178,7 @@ class BaseAPIController extends Controller
protected function response($response) protected function response($response)
{ {
$index = \Request::get('index') ?: 'data'; $index = Request::get('index') ?: 'data';
if ($index == 'none') { if ($index == 'none') {
unset($response['meta']); unset($response['meta']);

View file

@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Auth; use Auth;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -14,24 +15,24 @@ class BlueVineController extends BaseController
$user = Auth::user(); $user = Auth::user();
$data = [ $data = [
'personal_user_full_name' => \Request::input('name'), 'personal_user_full_name' => Input::get('name'),
'business_phone_number' => \Request::input('phone'), 'business_phone_number' => Input::get('phone'),
'email' => \Request::input('email'), 'email' => Input::get('email'),
'personal_fico_score' => intval(\Request::input('fico_score')), 'personal_fico_score' => intval(Input::get('fico_score')),
'business_annual_revenue' => intval(\Request::input('annual_revenue')), 'business_annual_revenue' => intval(Input::get('annual_revenue')),
'business_monthly_average_bank_balance' => intval(\Request::input('average_bank_balance')), 'business_monthly_average_bank_balance' => intval(Input::get('average_bank_balance')),
'business_inception_date' => date('Y-m-d', strtotime(\Request::input('business_inception'))), 'business_inception_date' => date('Y-m-d', strtotime(Input::get('business_inception'))),
'partner_internal_business_id' => 'ninja_account_' . $user->account_id, 'partner_internal_business_id' => 'ninja_account_' . $user->account_id,
]; ];
if (! empty(\Request::input('quote_type_factoring'))) { if (! empty(Input::get('quote_type_factoring'))) {
$data['invoice_factoring_offer'] = true; $data['invoice_factoring_offer'] = true;
$data['desired_credit_line'] = intval(\Request::input('desired_credit_limit')['invoice_factoring']); $data['desired_credit_line'] = intval(Input::get('desired_credit_limit')['invoice_factoring']);
} }
if (! empty(\Request::input('quote_type_loc'))) { if (! empty(Input::get('quote_type_loc'))) {
$data['line_of_credit_offer'] = true; $data['line_of_credit_offer'] = true;
$data['desired_credit_line_for_loc'] = intval(\Request::input('desired_credit_limit')['line_of_credit']); $data['desired_credit_line_for_loc'] = intval(Input::get('desired_credit_limit')['line_of_credit']);
} }
$api_client = new \GuzzleHttp\Client(); $api_client = new \GuzzleHttp\Client();

View file

@ -12,6 +12,7 @@ use Auth;
use Cache; use Cache;
use DB; use DB;
use Exception; use Exception;
use Input;
use Utils; use Utils;
class BotController extends Controller class BotController extends Controller
@ -27,7 +28,7 @@ class BotController extends Controller
{ {
abort(404); abort(404);
$input = \Request::all(); $input = Input::all();
$botUserId = $input['from']['id']; $botUserId = $input['from']['id'];
if (! $token = $this->authenticate($input)) { if (! $token = $this->authenticate($input)) {

View file

@ -7,6 +7,7 @@ use App\Http\Requests\CreateClientRequest;
use App\Http\Requests\UpdateClientRequest; use App\Http\Requests\UpdateClientRequest;
use App\Models\Client; use App\Models\Client;
use App\Ninja\Repositories\ClientRepository; use App\Ninja\Repositories\ClientRepository;
use Input;
use Response; use Response;
class ClientApiController extends BaseAPIController class ClientApiController extends BaseAPIController
@ -45,11 +46,11 @@ class ClientApiController extends BaseAPIController
->orderBy('updated_at', 'desc') ->orderBy('updated_at', 'desc')
->withTrashed(); ->withTrashed();
if ($email = \Request::input('email')) { if ($email = Input::get('email')) {
$clients = $clients->whereHas('contacts', function ($query) use ($email) { $clients = $clients->whereHas('contacts', function ($query) use ($email) {
$query->where('email', $email); $query->where('email', $email);
}); });
} elseif ($idNumber = \Request::input('id_number')) { } elseif ($idNumber = Input::get('id_number')) {
$clients = $clients->whereIdNumber($idNumber); $clients = $clients->whereIdNumber($idNumber);
} }

View file

@ -2,7 +2,6 @@
namespace App\Http\Controllers\ClientAuth; namespace App\Http\Controllers\ClientAuth;
use Illuminate\Mail\Message;
use Password; use Password;
use Config; use Config;
use Utils; use Utils;
@ -40,7 +39,7 @@ class ForgotPasswordController extends Controller
} }
/** /**
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Foundation\Application|\Illuminate\Http\RedirectResponse|\Illuminate\View\View * @return \Illuminate\Http\RedirectResponse
*/ */
public function showLinkRequestForm() public function showLinkRequestForm()
{ {
@ -56,7 +55,7 @@ class ForgotPasswordController extends Controller
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* *
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function sendResetLinkEmail(Request $request) public function sendResetLinkEmail(Request $request)
{ {
@ -92,7 +91,7 @@ class ForgotPasswordController extends Controller
}); });
return $response == Password::RESET_LINK_SENT return $response == Password::RESET_LINK_SENT
? $this->sendResetLinkResponse($request, $response) ? $this->sendResetLinkResponse($response)
: $this->sendResetLinkFailedResponse($request, $response); : $this->sendResetLinkFailedResponse($request, $response);
} }

View file

@ -19,6 +19,7 @@ use App\Ninja\Repositories\ClientRepository;
use App\Services\ClientService; use App\Services\ClientService;
use Auth; use Auth;
use Cache; use Cache;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -56,7 +57,7 @@ class ClientController extends BaseController
public function getDatatable() public function getDatatable()
{ {
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
$userId = Auth::user()->filterIdByEntity(ENTITY_CLIENT); $userId = Auth::user()->filterIdByEntity(ENTITY_CLIENT);
return $this->clientService->getDatatable($search, $userId); return $this->clientService->getDatatable($search, $userId);
@ -200,7 +201,7 @@ class ClientController extends BaseController
private static function getViewModel() private static function getViewModel()
{ {
return [ return [
'data' => \Request::old('data'), 'data' => Input::old('data'),
'account' => Auth::user()->account, 'account' => Auth::user()->account,
'sizes' => Cache::get('sizes'), 'sizes' => Cache::get('sizes'),
'customLabel1' => Auth::user()->account->customLabel('client1'), 'customLabel1' => Auth::user()->account->customLabel('client1'),
@ -226,8 +227,8 @@ class ClientController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
if ($action == 'purge' && ! auth()->user()->is_admin) { if ($action == 'purge' && ! auth()->user()->is_admin) {
return redirect('dashboard')->withError(trans('texts.not_authorized')); return redirect('dashboard')->withError(trans('texts.not_authorized'));

View file

@ -67,17 +67,6 @@ class ClientPortalController extends BaseController
$client = $invoice->client; $client = $invoice->client;
$account = $invoice->account; $account = $invoice->account;
/* Forward requests from V4 to V5 if the domain is set */
if(strlen($account->account_email_settings->forward_url_for_v5) >1){
if ($invoice->isType(INVOICE_TYPE_QUOTE))
$entity = 'quote';
else
$entity = 'invoice';
return redirect($account->account_email_settings->forward_url_for_v5."/client/".$entity."/".$invitationKey);
}
if (request()->silent) { if (request()->silent) {
session(['silent:' . $client->id => true]); session(['silent:' . $client->id => true]);
return redirect(request()->url() . (request()->borderless ? '?borderless=true' : '')); return redirect(request()->url() . (request()->borderless ? '?borderless=true' : ''));
@ -89,7 +78,7 @@ class ClientPortalController extends BaseController
]); ]);
} }
if (! Request::has('phantomjs') && ! session('silent:' . $client->id) && ! Session::has($invitation->invitation_key) if (! Input::has('phantomjs') && ! session('silent:' . $client->id) && ! Session::has($invitation->invitation_key)
&& (! Auth::check() || Auth::user()->account_id != $invoice->account_id)) { && (! Auth::check() || Auth::user()->account_id != $invoice->account_id)) {
if ($invoice->isType(INVOICE_TYPE_QUOTE)) { if ($invoice->isType(INVOICE_TYPE_QUOTE)) {
event(new QuoteInvitationWasViewed($invoice, $invitation)); event(new QuoteInvitationWasViewed($invoice, $invitation));
@ -140,14 +129,14 @@ class ClientPortalController extends BaseController
$paymentURL = ''; $paymentURL = '';
if (count($paymentTypes) == 1) { if (count($paymentTypes) == 1) {
$paymentURL = $paymentTypes[0]['url']; $paymentURL = $paymentTypes[0]['url'];
if (array_key_exists('gatewayTypeId', $paymentTypes[0]) && in_array($paymentTypes[0]['gatewayTypeId'], [GATEWAY_TYPE_CUSTOM1, GATEWAY_TYPE_CUSTOM2, GATEWAY_TYPE_CUSTOM3])) { if (in_array($paymentTypes[0]['gatewayTypeId'], [GATEWAY_TYPE_CUSTOM1, GATEWAY_TYPE_CUSTOM2, GATEWAY_TYPE_CUSTOM3])) {
// do nothing // do nothing
} elseif (! $account->isGatewayConfigured(GATEWAY_PAYPAL_EXPRESS)) { } elseif (! $account->isGatewayConfigured(GATEWAY_PAYPAL_EXPRESS)) {
$paymentURL = URL::to($paymentURL); $paymentURL = URL::to($paymentURL);
} }
} }
if (! Request::has('phantomjs')) { if (! Input::has('phantomjs')) {
if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)) { if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)) {
$data['enableWePayACH'] = $wepayGateway->getAchEnabled(); $data['enableWePayACH'] = $wepayGateway->getAchEnabled();
} }
@ -162,11 +151,6 @@ class ClientPortalController extends BaseController
$showApprove = false; $showApprove = false;
} }
$gatewayTypeIdCast = false;
if(count($paymentTypes) >= 1 && array_key_exists('gatewayTypeId', $paymentTypes[0]))
$gatewayTypeIdCast = $paymentTypes[0]['gatewayTypeId'];
$data += [ $data += [
'account' => $account, 'account' => $account,
'showApprove' => $showApprove, 'showApprove' => $showApprove,
@ -177,8 +161,8 @@ class ClientPortalController extends BaseController
'contact' => $contact, 'contact' => $contact,
'paymentTypes' => $paymentTypes, 'paymentTypes' => $paymentTypes,
'paymentURL' => $paymentURL, 'paymentURL' => $paymentURL,
'phantomjs' => Request::has('phantomjs'), 'phantomjs' => Input::has('phantomjs'),
'gatewayTypeId' => count($paymentTypes) == 1 ? $gatewayTypeIdCast : false, 'gatewayTypeId' => count($paymentTypes) == 1 ? $paymentTypes[0]['gatewayTypeId'] : false,
]; ];
if ($invoice->canBePaid()) { if ($invoice->canBePaid()) {
@ -244,7 +228,7 @@ class ClientPortalController extends BaseController
return RESULT_FAILURE; return RESULT_FAILURE;
} }
if ($signature = \Request::input('signature')) { if ($signature = Input::get('signature')) {
$invitation->signature_base64 = $signature; $invitation->signature_base64 = $signature;
$invitation->signature_date = date_create(); $invitation->signature_date = date_create();
$invitation->save(); $invitation->save();
@ -405,7 +389,7 @@ class ClientPortalController extends BaseController
return ''; return '';
} }
return $this->invoiceRepo->getClientDatatable($contact->id, ENTITY_INVOICE, \Request::input('sSearch')); return $this->invoiceRepo->getClientDatatable($contact->id, ENTITY_INVOICE, Input::get('sSearch'));
} }
public function recurringInvoiceDatatable() public function recurringInvoiceDatatable()
@ -448,7 +432,7 @@ class ClientPortalController extends BaseController
if (! $contact = $this->getContact()) { if (! $contact = $this->getContact()) {
return $this->returnError(); return $this->returnError();
} }
$payments = $this->paymentRepo->findForContact($contact->id, \Request::input('sSearch')); $payments = $this->paymentRepo->findForContact($contact->id, Input::get('sSearch'));
return Datatable::query($payments) return Datatable::query($payments)
->addColumn('invoice_number', function ($model) { ->addColumn('invoice_number', function ($model) {
@ -533,7 +517,7 @@ class ClientPortalController extends BaseController
return false; return false;
} }
return $this->invoiceRepo->getClientDatatable($contact->id, ENTITY_QUOTE, \Request::input('sSearch')); return $this->invoiceRepo->getClientDatatable($contact->id, ENTITY_QUOTE, Input::get('sSearch'));
} }
public function creditIndex() public function creditIndex()
@ -642,7 +626,7 @@ class ClientPortalController extends BaseController
return false; return false;
} }
return $this->documentRepo->getClientDatatable($contact->id, ENTITY_DOCUMENT, \Request::input('sSearch')); return $this->documentRepo->getClientDatatable($contact->id, ENTITY_DOCUMENT, Input::get('sSearch'));
} }
private function returnError($error = false) private function returnError($error = false)
@ -855,9 +839,9 @@ class ClientPortalController extends BaseController
public function verifyPaymentMethod() public function verifyPaymentMethod()
{ {
$publicId = \Request::input('source_id'); $publicId = Input::get('source_id');
$amount1 = \Request::input('verification1'); $amount1 = Input::get('verification1');
$amount2 = \Request::input('verification2'); $amount2 = Input::get('verification2');
if (! $contact = $this->getContact()) { if (! $contact = $this->getContact()) {
return $this->returnError(); return $this->returnError();
@ -911,14 +895,14 @@ class ClientPortalController extends BaseController
$client = $contact->client; $client = $contact->client;
$account = $client->account; $account = $client->account;
$validator = Validator::make(Request::all(), ['source' => 'required']); $validator = Validator::make(Input::all(), ['source' => 'required']);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to($client->account->enable_client_portal_dashboard ? '/client/dashboard' : '/client/payment_methods/'); return Redirect::to($client->account->enable_client_portal_dashboard ? '/client/dashboard' : '/client/payment_methods/');
} }
$paymentDriver = $account->paymentDriver(false, GATEWAY_TYPE_TOKEN); $paymentDriver = $account->paymentDriver(false, GATEWAY_TYPE_TOKEN);
$paymentMethod = PaymentMethod::clientId($client->id) $paymentMethod = PaymentMethod::clientId($client->id)
->wherePublicId(\Request::input('source')) ->wherePublicId(Input::get('source'))
->firstOrFail(); ->firstOrFail();
$customer = $paymentDriver->customer($client->id); $customer = $paymentDriver->customer($client->id);
@ -950,14 +934,14 @@ class ClientPortalController extends BaseController
$client = $contact->client; $client = $contact->client;
$validator = Validator::make(Request::all(), ['public_id' => 'required']); $validator = Validator::make(Input::all(), ['public_id' => 'required']);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to('client/invoices/recurring'); return Redirect::to('client/invoices/recurring');
} }
$publicId = \Request::input('public_id'); $publicId = Input::get('public_id');
$enable = \Request::input('enable'); $enable = Input::get('enable');
$invoice = $client->invoices()->where('public_id', intval($publicId))->first(); $invoice = $client->invoices()->where('public_id', intval($publicId))->first();
if ($invoice && $invoice->is_recurring && ($invoice->auto_bill == AUTO_BILL_OPT_IN || $invoice->auto_bill == AUTO_BILL_OPT_OUT)) { if ($invoice && $invoice->is_recurring && ($invoice->auto_bill == AUTO_BILL_OPT_IN || $invoice->auto_bill == AUTO_BILL_OPT_OUT)) {

View file

@ -7,6 +7,7 @@ use App\Http\Requests\CreateContactRequest;
use App\Http\Requests\UpdateContactRequest; use App\Http\Requests\UpdateContactRequest;
use App\Models\Contact; use App\Models\Contact;
use App\Ninja\Repositories\ContactRepository; use App\Ninja\Repositories\ContactRepository;
use Input;
use Response; use Response;
use Utils; use Utils;
use App\Services\ContactService; use App\Services\ContactService;

View file

@ -8,6 +8,7 @@ use App\Http\Requests\UpdateCreditRequest;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Credit; use App\Models\Credit;
use App\Ninja\Repositories\CreditRepository; use App\Ninja\Repositories\CreditRepository;
use Input;
use Response; use Response;
class CreditApiController extends BaseAPIController class CreditApiController extends BaseAPIController

View file

@ -10,6 +10,7 @@ use App\Models\Credit;
use App\Ninja\Datatables\CreditDatatable; use App\Ninja\Datatables\CreditDatatable;
use App\Ninja\Repositories\CreditRepository; use App\Ninja\Repositories\CreditRepository;
use App\Services\CreditService; use App\Services\CreditService;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -46,13 +47,13 @@ class CreditController extends BaseController
public function getDatatable($clientPublicId = null) public function getDatatable($clientPublicId = null)
{ {
return $this->creditService->getDatatable($clientPublicId, \Request::input('sSearch')); return $this->creditService->getDatatable($clientPublicId, Input::get('sSearch'));
} }
public function create(CreditRequest $request) public function create(CreditRequest $request)
{ {
$data = [ $data = [
'clientPublicId' => \Request::old('client') ? \Request::old('client') : ($request->client_id ?: 0), 'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0),
'credit' => null, 'credit' => null,
'method' => 'POST', 'method' => 'POST',
'url' => 'credits', 'url' => 'credits',
@ -110,7 +111,7 @@ class CreditController extends BaseController
private function save($credit = null) private function save($credit = null)
{ {
$credit = $this->creditService->save(\Request::all(), $credit); $credit = $this->creditService->save(Input::all(), $credit);
$message = $credit->wasRecentlyCreated ? trans('texts.created_credit') : trans('texts.updated_credit'); $message = $credit->wasRecentlyCreated ? trans('texts.created_credit') : trans('texts.updated_credit');
Session::flash('message', $message); Session::flash('message', $message);
@ -120,8 +121,8 @@ class CreditController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->creditService->bulk($ids, $action); $count = $this->creditService->bulk($ids, $action);
if ($count > 0) { if ($count > 0) {

View file

@ -8,6 +8,7 @@ use App\Http\Requests\UpdateExpenseCategoryRequest;
use App\Models\ExpenseCategory; use App\Models\ExpenseCategory;
use App\Ninja\Repositories\ExpenseCategoryRepository; use App\Ninja\Repositories\ExpenseCategoryRepository;
use App\Services\ExpenseCategoryService; use App\Services\ExpenseCategoryService;
use Input;
class ExpenseCategoryApiController extends BaseAPIController class ExpenseCategoryApiController extends BaseAPIController
{ {

View file

@ -8,6 +8,7 @@ use App\Http\Requests\UpdateExpenseCategoryRequest;
use App\Ninja\Datatables\ExpenseCategoryDatatable; use App\Ninja\Datatables\ExpenseCategoryDatatable;
use App\Ninja\Repositories\ExpenseCategoryRepository; use App\Ninja\Repositories\ExpenseCategoryRepository;
use App\Services\ExpenseCategoryService; use App\Services\ExpenseCategoryService;
use Input;
use Session; use Session;
use View; use View;
@ -39,7 +40,7 @@ class ExpenseCategoryController extends BaseController
public function getDatatable($expensePublicId = null) public function getDatatable($expensePublicId = null)
{ {
return $this->categoryService->getDatatable(\Request::input('sSearch')); return $this->categoryService->getDatatable(Input::get('sSearch'));
} }
public function create(ExpenseCategoryRequest $request) public function create(ExpenseCategoryRequest $request)
@ -88,8 +89,8 @@ class ExpenseCategoryController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->categoryService->bulk($ids, $action); $count = $this->categoryService->bulk($ids, $action);
if ($count > 0) { if ($count > 0) {

View file

@ -16,6 +16,7 @@ use App\Ninja\Repositories\InvoiceRepository;
use App\Services\ExpenseService; use App\Services\ExpenseService;
use Auth; use Auth;
use Cache; use Cache;
use Input;
use Redirect; use Redirect;
use Request; use Request;
use Session; use Session;
@ -60,7 +61,7 @@ class ExpenseController extends BaseController
public function getDatatable($expensePublicId = null) public function getDatatable($expensePublicId = null)
{ {
return $this->expenseService->getDatatable(\Request::input('sSearch')); return $this->expenseService->getDatatable(Input::get('sSearch'));
} }
public function getDatatableVendor($vendorPublicId = null) public function getDatatableVendor($vendorPublicId = null)
@ -82,7 +83,7 @@ class ExpenseController extends BaseController
} }
$data = [ $data = [
'vendorPublicId' => Request::old('vendor') ? Request::old('vendor') : $request->vendor_id, 'vendorPublicId' => Input::old('vendor') ? Input::old('vendor') : $request->vendor_id,
'expense' => null, 'expense' => null,
'method' => 'POST', 'method' => 'POST',
'url' => 'expenses', 'url' => 'expenses',
@ -189,7 +190,7 @@ class ExpenseController extends BaseController
Session::flash('message', trans('texts.updated_expense')); Session::flash('message', trans('texts.updated_expense'));
$action = \Request::input('action'); $action = Input::get('action');
if (in_array($action, ['archive', 'delete', 'restore', 'invoice', 'add_to_invoice'])) { if (in_array($action, ['archive', 'delete', 'restore', 'invoice', 'add_to_invoice'])) {
return self::bulk(); return self::bulk();
} }
@ -226,8 +227,8 @@ class ExpenseController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$referer = Request::server('HTTP_REFERER'); $referer = Request::server('HTTP_REFERER');
switch ($action) { switch ($action) {
@ -267,7 +268,7 @@ class ExpenseController extends BaseController
->with('expenseCurrencyId', $currencyId) ->with('expenseCurrencyId', $currencyId)
->with('expenses', $ids); ->with('expenses', $ids);
} else { } else {
$invoiceId = \Request::input('invoice_id'); $invoiceId = Input::get('invoice_id');
return Redirect::to("invoices/{$invoiceId}/edit") return Redirect::to("invoices/{$invoiceId}/edit")
->with('expenseCurrencyId', $currencyId) ->with('expenseCurrencyId', $currencyId)
@ -290,7 +291,7 @@ class ExpenseController extends BaseController
private static function getViewModel($expense = false) private static function getViewModel($expense = false)
{ {
return [ return [
'data' => Request::old('data'), 'data' => Input::old('data'),
'account' => Auth::user()->account, 'account' => Auth::user()->account,
'vendors' => Vendor::scope()->withActiveOrSelected($expense ? $expense->vendor_id : false)->with('vendor_contacts')->orderBy('name')->get(), 'vendors' => Vendor::scope()->withActiveOrSelected($expense ? $expense->vendor_id : false)->with('vendor_contacts')->orderBy('name')->get(),
'clients' => Client::scope()->withActiveOrSelected($expense ? $expense->client_id : false)->with('contacts')->orderBy('name')->get(), 'clients' => Client::scope()->withActiveOrSelected($expense ? $expense->client_id : false)->with('contacts')->orderBy('name')->get(),

View file

@ -6,6 +6,7 @@ use App\Libraries\Utils;
use App\Models\Account; use App\Models\Account;
use App\Ninja\Mailers\Mailer; use App\Ninja\Mailers\Mailer;
use Auth; use Auth;
use Input;
use Mail; use Mail;
use Redirect; use Redirect;
use Request; use Request;
@ -64,27 +65,17 @@ class HomeController extends BaseController
*/ */
public function invoiceNow() public function invoiceNow()
{ {
$url = 'https://invoicing.co';
if (Request::has('rc')) {
$url = $url . '?rc=' . \Request::input('rc');
}
return Redirect::to($url);
/*
// Track the referral/campaign code // Track the referral/campaign code
if (Request::has('rc')) { if (Input::has('rc')) {
session([SESSION_REFERRAL_CODE => \Request::input('rc')]); session([SESSION_REFERRAL_CODE => Input::get('rc')]);
} }
if (Auth::check()) { if (Auth::check()) {
$redirectTo = \Request::input('redirect_to') ? SITE_URL . '/' . ltrim(\Request::input('redirect_to'), '/') : 'invoices/create'; $redirectTo = Input::get('redirect_to') ? SITE_URL . '/' . ltrim(Input::get('redirect_to'), '/') : 'invoices/create';
return Redirect::to($redirectTo)->with('sign_up', \Request::input('sign_up')); return Redirect::to($redirectTo)->with('sign_up', Input::get('sign_up'));
} else { } else {
return View::make('public.invoice_now'); return View::make('public.invoice_now');
} }
*/
} }
/** /**
@ -124,7 +115,7 @@ class HomeController extends BaseController
*/ */
public function logError() public function logError()
{ {
return Utils::logError(\Request::input('error'), 'JavaScript'); return Utils::logError(Input::get('error'), 'JavaScript');
} }
/** /**

View file

@ -6,6 +6,7 @@ use Illuminate\Http\Request;
use App\Services\ImportService; use App\Services\ImportService;
use App\Jobs\ImportData; use App\Jobs\ImportData;
use Exception; use Exception;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use Utils; use Utils;
@ -25,7 +26,7 @@ class ImportController extends BaseController
return redirect('/settings/' . ACCOUNT_IMPORT_EXPORT)->withError(trans('texts.confirm_account_to_import')); return redirect('/settings/' . ACCOUNT_IMPORT_EXPORT)->withError(trans('texts.confirm_account_to_import'));
} }
$source = \Request::input('source'); $source = Input::get('source');
$files = []; $files = [];
$timestamp = time(); $timestamp = time();
@ -69,8 +70,8 @@ class ImportController extends BaseController
'timestamp' => $timestamp, 'timestamp' => $timestamp,
]); ]);
} elseif ($source === IMPORT_JSON) { } elseif ($source === IMPORT_JSON) {
$includeData = filter_var(\Request::input('data'), FILTER_VALIDATE_BOOLEAN); $includeData = filter_var(Input::get('data'), FILTER_VALIDATE_BOOLEAN);
$includeSettings = filter_var(\Request::input('settings'), FILTER_VALIDATE_BOOLEAN); $includeSettings = filter_var(Input::get('settings'), FILTER_VALIDATE_BOOLEAN);
if (config('queue.default') === 'sync') { if (config('queue.default') === 'sync') {
$results = $this->importService->importJSON($files[IMPORT_JSON], $includeData, $includeSettings); $results = $this->importService->importJSON($files[IMPORT_JSON], $includeData, $includeSettings);
$message = $this->importService->presentResults($results, $includeSettings); $message = $this->importService->presentResults($results, $includeSettings);
@ -108,9 +109,9 @@ class ImportController extends BaseController
public function doImportCSV() public function doImportCSV()
{ {
try { try {
$map = \Request::input('map'); $map = Input::get('map');
$headers = \Request::input('headers'); $headers = Input::get('headers');
$timestamp = \Request::input('timestamp'); $timestamp = Input::get('timestamp');
if (config('queue.default') === 'sync') { if (config('queue.default') === 'sync') {
$results = $this->importService->importCSV($map, $headers, $timestamp); $results = $this->importService->importCSV($map, $headers, $timestamp);

View file

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Subscription; use App\Models\Subscription;
use Auth; use Auth;
use Input;
use Response; use Response;
use Utils; use Utils;
@ -17,7 +18,7 @@ class IntegrationController extends BaseAPIController
*/ */
public function subscribe() public function subscribe()
{ {
$eventId = Utils::lookupEventId(trim(\Request::input('event'))); $eventId = Utils::lookupEventId(trim(Input::get('event')));
if (! $eventId) { if (! $eventId) {
return Response::json('Event is invalid', 500); return Response::json('Event is invalid', 500);
@ -25,7 +26,7 @@ class IntegrationController extends BaseAPIController
$subscription = Subscription::createNew(); $subscription = Subscription::createNew();
$subscription->event_id = $eventId; $subscription->event_id = $eventId;
$subscription->target_url = trim(\Request::input('target_url')); $subscription->target_url = trim(Input::get('target_url'));
$subscription->save(); $subscription->save();
if (! $subscription->id) { if (! $subscription->id) {

View file

@ -17,6 +17,7 @@ use App\Ninja\Repositories\PaymentRepository;
use App\Services\InvoiceService; use App\Services\InvoiceService;
use App\Services\PaymentService; use App\Services\PaymentService;
use Auth; use Auth;
use Input;
use Response; use Response;
use Utils; use Utils;
use Validator; use Validator;
@ -63,12 +64,12 @@ class InvoiceApiController extends BaseAPIController
->orderBy('updated_at', 'desc'); ->orderBy('updated_at', 'desc');
// Filter by invoice number // Filter by invoice number
if ($invoiceNumber = \Request::input('invoice_number')) { if ($invoiceNumber = Input::get('invoice_number')) {
$invoices->whereInvoiceNumber($invoiceNumber); $invoices->whereInvoiceNumber($invoiceNumber);
} }
// Fllter by status // Fllter by status
if ($statusId = \Request::input('status_id')) { if ($statusId = Input::get('status_id')) {
$invoices->where('invoice_status_id', '>=', $statusId); $invoices->where('invoice_status_id', '>=', $statusId);
} }
@ -133,7 +134,7 @@ class InvoiceApiController extends BaseAPIController
*/ */
public function store(CreateInvoiceAPIRequest $request) public function store(CreateInvoiceAPIRequest $request)
{ {
$data = \Request::all(); $data = Input::all();
$error = null; $error = null;
if (isset($data['email'])) { if (isset($data['email'])) {

View file

@ -25,9 +25,9 @@ use App\Services\RecurringInvoiceService;
use Auth; use Auth;
use Cache; use Cache;
use DB; use DB;
use Illuminate\Support\Facades\Session; use Input;
use Redirect; use Redirect;
use Request; use Session;
use URL; use URL;
use Utils; use Utils;
use View; use View;
@ -68,7 +68,7 @@ class InvoiceController extends BaseController
public function getDatatable($clientPublicId = null) public function getDatatable($clientPublicId = null)
{ {
$accountId = Auth::user()->account_id; $accountId = Auth::user()->account_id;
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
return $this->invoiceService->getDatatable($accountId, $clientPublicId, ENTITY_INVOICE, $search); return $this->invoiceService->getDatatable($accountId, $clientPublicId, ENTITY_INVOICE, $search);
} }
@ -76,7 +76,7 @@ class InvoiceController extends BaseController
public function getRecurringDatatable($clientPublicId = null) public function getRecurringDatatable($clientPublicId = null)
{ {
$accountId = Auth::user()->account_id; $accountId = Auth::user()->account_id;
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
return $this->recurringInvoiceService->getDatatable($accountId, $clientPublicId, ENTITY_RECURRING_INVOICE, $search); return $this->recurringInvoiceService->getDatatable($accountId, $clientPublicId, ENTITY_RECURRING_INVOICE, $search);
} }
@ -219,9 +219,6 @@ class InvoiceController extends BaseController
$clients = $clients->where('clients.user_id', '=', Auth::user()->id); $clients = $clients->where('clients.user_id', '=', Auth::user()->id);
} }
if($clientPublicId != 0)
$clients->where('public_id', $clientPublicId);
$data = [ $data = [
'clients' => $clients->get(), 'clients' => $clients->get(),
'entityType' => $invoice->getEntityType(), 'entityType' => $invoice->getEntityType(),
@ -320,7 +317,7 @@ class InvoiceController extends BaseController
} }
return [ return [
'data' => Request::old('data'), 'data' => Input::old('data'),
'account' => Auth::user()->account->load('country'), 'account' => Auth::user()->account->load('country'),
'products' => Product::scope()->orderBy('product_key')->get(), 'products' => Product::scope()->orderBy('product_key')->get(),
'taxRateOptions' => $taxRateOptions, 'taxRateOptions' => $taxRateOptions,
@ -348,8 +345,8 @@ class InvoiceController extends BaseController
$data = $request->input(); $data = $request->input();
$data['documents'] = $request->file('documents'); $data['documents'] = $request->file('documents');
$action = \Request::input('action'); $action = Input::get('action');
$entityType = \Request::input('entityType'); $entityType = Input::get('entityType');
$invoice = $this->invoiceService->save($data); $invoice = $this->invoiceService->save($data);
$entityType = $invoice->getEntityType(); $entityType = $invoice->getEntityType();
@ -382,8 +379,8 @@ class InvoiceController extends BaseController
$data = $request->input(); $data = $request->input();
$data['documents'] = $request->file('documents'); $data['documents'] = $request->file('documents');
$action = \Request::input('action'); $action = Input::get('action');
$entityType = \Request::input('entityType'); $entityType = Input::get('entityType');
$invoice = $this->invoiceService->save($data, $request->entity()); $invoice = $this->invoiceService->save($data, $request->entity());
$entityType = $invoice->getEntityType(); $entityType = $invoice->getEntityType();
@ -405,14 +402,14 @@ class InvoiceController extends BaseController
private function emailInvoice($invoice) private function emailInvoice($invoice)
{ {
$reminder = \Request::input('reminder'); $reminder = Input::get('reminder');
$template = \Request::input('template'); $template = Input::get('template');
$pdfUpload = Utils::decodePDF(\Request::input('pdfupload')); $pdfUpload = Utils::decodePDF(Input::get('pdfupload'));
$entityType = $invoice->getEntityType(); $entityType = $invoice->getEntityType();
if (filter_var(\Request::input('save_as_default'), FILTER_VALIDATE_BOOLEAN)) { if (filter_var(Input::get('save_as_default'), FILTER_VALIDATE_BOOLEAN)) {
$account = Auth::user()->account; $account = Auth::user()->account;
$account->setTemplateDefaults(\Request::input('template_type'), $template['subject'], $template['body']); $account->setTemplateDefaults(Input::get('template_type'), $template['subject'], $template['body']);
} }
if (! Auth::user()->confirmed) { if (! Auth::user()->confirmed) {
@ -430,7 +427,7 @@ class InvoiceController extends BaseController
$response = $this->emailRecurringInvoice($invoice); $response = $this->emailRecurringInvoice($invoice);
} else { } else {
$userId = Auth::user()->id; $userId = Auth::user()->id;
dispatch(new SendInvoiceEmail($invoice, $userId, $reminder, $template)); $this->dispatch(new SendInvoiceEmail($invoice, $userId, $reminder, $template));
$response = true; $response = true;
} }
@ -493,8 +490,8 @@ class InvoiceController extends BaseController
*/ */
public function bulk($entityType = ENTITY_INVOICE) public function bulk($entityType = ENTITY_INVOICE)
{ {
$action = \Request::input('bulk_action') ?: \Request::input('action'); $action = Input::get('bulk_action') ?: Input::get('action');
$ids = \Request::input('bulk_public_id') ?: (\Request::input('public_id') ?: \Request::input('ids')); $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
$count = $this->invoiceService->bulk($ids, $action); $count = $this->invoiceService->bulk($ids, $action);
if ($count > 0) { if ($count > 0) {

View file

@ -6,22 +6,15 @@ use App\Http\Controllers\BaseController;
use App\Http\Requests\MigrationAuthRequest; use App\Http\Requests\MigrationAuthRequest;
use App\Http\Requests\MigrationCompaniesRequest; use App\Http\Requests\MigrationCompaniesRequest;
use App\Http\Requests\MigrationEndpointRequest; use App\Http\Requests\MigrationEndpointRequest;
use App\Http\Requests\MigrationForwardRequest;
use App\Http\Requests\MigrationTypeRequest; use App\Http\Requests\MigrationTypeRequest;
use App\Jobs\HostedMigration;
use App\Libraries\Utils; use App\Libraries\Utils;
use App\Models\Account; use App\Models\Account;
use App\Models\AccountGatewayToken;
use App\Models\Client;
use App\Services\Migration\AuthService; use App\Services\Migration\AuthService;
use App\Services\Migration\CompanyService; use App\Services\Migration\CompanyService;
use App\Services\Migration\CompleteService; use App\Services\Migration\CompleteService;
use App\Traits\GenerateMigrationResources; use App\Traits\GenerateMigrationResources;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Validator;
use GuzzleHttp\RequestOptions;
class StepsController extends BaseController class StepsController extends BaseController
{ {
@ -52,17 +45,6 @@ class StepsController extends BaseController
*/ */
public function start() public function start()
{ {
if(Utils::isNinja()){
session()->put('MIGRATION_ENDPOINT', 'https://v5-app1.invoicing.co');
// session()->put('MIGRATION_ENDPOINT', 'http://ninja.test:8000');
session()->put('MIGRATION_ACCOUNT_TOKEN','');
session()->put('MIGRAITON_API_SECRET', null);
return $this->companies();
}
return view('migration.start'); return view('migration.start');
} }
@ -83,12 +65,17 @@ class StepsController extends BaseController
{ {
session()->put('MIGRATION_TYPE', $request->option); session()->put('MIGRATION_TYPE', $request->option);
if ($request->option == 0 || $request->option == '0') { if ($request->option == 0) {
session()->put('MIGRATION_ENDPOINT', 'https://invoicing.co');
return redirect( return redirect(
url('/migration/companies?hosted=true') url('/migration/auth')
); );
// return redirect(
// url('/migration/endpoint')
// );
} }
return redirect( return redirect(
@ -96,145 +83,8 @@ class StepsController extends BaseController
); );
} }
public function forwardUrl(Request $request)
{
if(Utils::isNinjaProd())
return $this->autoForwardUrl();
$rules = [
'url' => 'nullable|url',
];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return back()
->withErrors($validator)
->withInput();
}
$account_settings = \Auth::user()->account->account_email_settings;
if(strlen($request->input('url')) == 0) {
$account_settings->is_disabled = false;
}
else {
$account_settings->is_disabled = true;
}
$account_settings->forward_url_for_v5 = rtrim($request->input('url'),'/');
$account_settings->save();
return back();
}
public function disableForwarding()
{
$account = \Auth::user()->account;
$account_settings = $account->account_email_settings;
$account_settings->forward_url_for_v5 = '';
$account_settings->is_disabled = false;
$account_settings->save();
return back();
}
private function autoForwardUrl()
{
$url = 'https://invoicing.co/api/v1/confirm_forwarding';
// $url = 'http://devhosted.test:8000/api/v1/confirm_forwarding';
$headers = [
'X-API-HOSTED-SECRET' => config('ninja.ninja_hosted_secret'),
'X-Requested-With' => 'XMLHttpRequest',
'Content-Type' => 'application/json',
];
$account = \Auth::user()->account;
$gateway_reference = '';
$ninja_client = Client::where('public_id', $account->id)->first();
if($ninja_client){
$agt = AccountGatewayToken::where('client_id', $ninja_client->id)->first();
if($agt)
$gateway_reference = $agt->token;
}
$body = [
'account_key' => $account->account_key,
'email' => $account->getPrimaryUser()->email,
'plan' => $account->company->plan,
'plan_term' =>$account->company->plan_term,
'plan_started' =>$account->company->plan_started,
'plan_paid' =>$account->company->plan_paid,
'plan_expires' =>$account->company->plan_expires,
'trial_started' =>$account->company->trial_started,
'trial_plan' =>$account->company->trial_plan,
'plan_price' =>$account->company->plan_price,
'num_users' =>$account->company->num_users,
'gateway_reference' => $gateway_reference,
];
$client = new \GuzzleHttp\Client([
'headers' => $headers,
]);
$response = $client->post($url,[
RequestOptions::JSON => $body,
RequestOptions::ALLOW_REDIRECTS => false
]);
if($response->getStatusCode() == 401){
info("autoForwardUrl");
info($response->getBody());
} elseif ($response->getStatusCode() == 200) {
$message_body = json_decode($response->getBody(), true);
$forwarding_url = $message_body['forward_url'];
$account_settings = $account->account_email_settings;
if(strlen($forwarding_url) == 0) {
$account_settings->is_disabled = false;
}
else {
$account_settings->is_disabled = true;
}
$account_settings->forward_url_for_v5 = rtrim($forwarding_url,'/');
$account_settings->save();
$billing_transferred = $message_body['billing_transferred'];
if($billing_transferred == 'true'){
$company = $account->company;
$company->plan = null;
$company->plan_expires = null;
$company->save();
}
} else {
info("failed to autoforward");
info(json_decode($response->getBody()->getContents()));
// dd('else');
}
return back();
}
public function endpoint() public function endpoint()
{ {
if ($this->shouldGoBack('endpoint')) { if ($this->shouldGoBack('endpoint')) {
return redirect( return redirect(
url($this->access['endpoint']['redirect']) url($this->access['endpoint']['redirect'])
@ -325,38 +175,23 @@ class StepsController extends BaseController
url($this->access['companies']['redirect']) url($this->access['companies']['redirect'])
); );
} }
$bool = true;
if(Utils::isNinja())
{
$this->dispatch(new HostedMigration(auth()->user(), $request->all(), config('database.default')));
return view('migration.completed');
}
$completeService = (new CompleteService(session('MIGRATION_ACCOUNT_TOKEN')));
try { try {
$migrationData = $this->generateMigrationData($request->all()); $migrationData = $this->generateMigrationData($request->all());
$completeService->data($migrationData) $completeService = (new CompleteService(session('MIGRATION_ACCOUNT_TOKEN')))
->data($migrationData)
->endpoint(session('MIGRATION_ENDPOINT')) ->endpoint(session('MIGRATION_ENDPOINT'))
->start(); ->start();
} }
catch(\Exception $e){ finally {
info($e->getMessage());
return view('migration.completed', ['customMessage' => $e->getMessage()]);
}
if ($completeService->isSuccessful()) { if ($completeService->isSuccessful()) {
return view('migration.completed'); return view('migration.completed');
} }
return view('migration.completed', ['customMessage' => $completeService->getErrors()[0]]); return view('migration.completed', ['customMessage' => $completeService->getErrors()[0]]);
}
} }
public function completed() public function completed()
@ -422,10 +257,9 @@ class StepsController extends BaseController
'products' => $this->getProducts(), 'products' => $this->getProducts(),
'credits' => $this->getCreditsNotes(), 'credits' => $this->getCreditsNotes(),
'invoices' => $this->getInvoices(), 'invoices' => $this->getInvoices(),
'recurring_expenses' => $this->getRecurringExpenses(),
'recurring_invoices' => $this->getRecurringInvoices(), 'recurring_invoices' => $this->getRecurringInvoices(),
'quotes' => $this->getQuotes(), 'quotes' => $this->getQuotes(),
'payments' => $this->getPayments(), 'payments' => array_merge($this->getPayments(), $this->getCredits()),
'documents' => $this->getDocuments(), 'documents' => $this->getDocuments(),
'expense_categories' => $this->getExpenseCategories(), 'expense_categories' => $this->getExpenseCategories(),
'task_statuses' => $this->getTaskStatuses(), 'task_statuses' => $this->getTaskStatuses(),
@ -440,6 +274,8 @@ class StepsController extends BaseController
Storage::makeDirectory('migrations'); Storage::makeDirectory('migrations');
$file = Storage::path("migrations/{$fileName}.zip"); $file = Storage::path("migrations/{$fileName}.zip");
//$file = storage_path("migrations/{$fileName}.zip");
ksort($localMigrationData); ksort($localMigrationData);
$zip = new \ZipArchive(); $zip = new \ZipArchive();

View file

@ -11,13 +11,13 @@ use App\Libraries\CurlUtils;
use Auth; use Auth;
use Cache; use Cache;
use CreditCard; use CreditCard;
use Input;
use Omnipay; use Omnipay;
use Session; use Session;
use URL; use URL;
use Utils; use Utils;
use Validator; use Validator;
use View; use View;
use Request;
class NinjaController extends BaseController class NinjaController extends BaseController
{ {
@ -91,18 +91,18 @@ class NinjaController extends BaseController
*/ */
public function show_license_payment() public function show_license_payment()
{ {
if (\Request::has('return_url')) { if (Input::has('return_url')) {
session(['return_url' => \Request::input('return_url')]); session(['return_url' => Input::get('return_url')]);
} }
if (\Request::has('affiliate_key')) { if (Input::has('affiliate_key')) {
if ($affiliate = Affiliate::where('affiliate_key', '=', \Request::input('affiliate_key'))->first()) { if ($affiliate = Affiliate::where('affiliate_key', '=', Input::get('affiliate_key'))->first()) {
session(['affiliate_id' => $affiliate->id]); session(['affiliate_id' => $affiliate->id]);
} }
} }
if (\Request::has('product_id')) { if (Input::has('product_id')) {
session(['product_id' => \Request::input('product_id')]); session(['product_id' => Input::get('product_id')]);
} elseif (! Session::has('product_id')) { } elseif (! Session::has('product_id')) {
session(['product_id' => PRODUCT_ONE_CLICK_INSTALL]); session(['product_id' => PRODUCT_ONE_CLICK_INSTALL]);
} }
@ -111,8 +111,8 @@ class NinjaController extends BaseController
return Utils::fatalError(); return Utils::fatalError();
} }
if (Utils::isNinjaDev() && \Request::has('test_mode')) { if (Utils::isNinjaDev() && Input::has('test_mode')) {
session(['test_mode' => \Request::input('test_mode')]); session(['test_mode' => Input::get('test_mode')]);
} }
$account = $this->accountRepo->getNinjaAccount(); $account = $this->accountRepo->getNinjaAccount();
@ -167,7 +167,7 @@ class NinjaController extends BaseController
'country_id' => 'required', 'country_id' => 'required',
]; ];
$validator = Validator::make(Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return redirect()->to('license') return redirect()->to('license')
@ -185,7 +185,7 @@ class NinjaController extends BaseController
if ($testMode) { if ($testMode) {
$ref = 'TEST_MODE'; $ref = 'TEST_MODE';
} else { } else {
$details = self::getLicensePaymentDetails(Request::all(), $affiliate); $details = self::getLicensePaymentDetails(Input::all(), $affiliate);
$gateway = Omnipay::create($accountGateway->gateway->provider); $gateway = Omnipay::create($accountGateway->gateway->provider);
$gateway->initialize((array) $accountGateway->getConfig()); $gateway->initialize((array) $accountGateway->getConfig());
@ -203,9 +203,9 @@ class NinjaController extends BaseController
$licenseKey = Utils::generateLicense(); $licenseKey = Utils::generateLicense();
$license = new License(); $license = new License();
$license->first_name = \Request::input('first_name'); $license->first_name = Input::get('first_name');
$license->last_name = \Request::input('last_name'); $license->last_name = Input::get('last_name');
$license->email = \Request::input('email'); $license->email = Input::get('email');
$license->transaction_reference = $ref; $license->transaction_reference = $ref;
$license->license_key = $licenseKey; $license->license_key = $licenseKey;
$license->affiliate_id = Session::get('affiliate_id'); $license->affiliate_id = Session::get('affiliate_id');
@ -241,8 +241,8 @@ class NinjaController extends BaseController
*/ */
public function claim_license() public function claim_license()
{ {
$licenseKey = \Request::input('license_key'); $licenseKey = Input::get('license_key');
$productId = \Request::input('product_id', PRODUCT_ONE_CLICK_INSTALL); $productId = Input::get('product_id', PRODUCT_ONE_CLICK_INSTALL);
// add in dashes // add in dashes
if (strlen($licenseKey) == 20) { if (strlen($licenseKey) == 20) {

View file

@ -19,12 +19,12 @@ use App\Services\PaymentService;
use Auth; use Auth;
use Crawler; use Crawler;
use Exception; use Exception;
use Input;
use Session; use Session;
use URL; use URL;
use Utils; use Utils;
use Validator; use Validator;
use View; use View;
use Request;
/** /**
* Class OnlinePaymentController. * Class OnlinePaymentController.
@ -114,7 +114,7 @@ class OnlinePaymentController extends BaseController
} }
try { try {
return $paymentDriver->startPurchase(Request::all(), $sourceId); return $paymentDriver->startPurchase(Input::all(), $sourceId);
} catch (Exception $exception) { } catch (Exception $exception) {
return $this->error($paymentDriver, $exception); return $this->error($paymentDriver, $exception);
} }
@ -202,12 +202,12 @@ class OnlinePaymentController extends BaseController
$paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId); $paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId);
if ($error = \Request::input('error_description') ?: \Request::input('error')) { if ($error = Input::get('error_description') ?: Input::get('error')) {
return $this->error($paymentDriver, $error); return $this->error($paymentDriver, $error);
} }
try { try {
if ($paymentDriver->completeOffsitePurchase(Request::all())) { if ($paymentDriver->completeOffsitePurchase(Input::all())) {
Session::flash('message', trans('texts.applied_payment')); Session::flash('message', trans('texts.applied_payment'));
} }
@ -332,7 +332,7 @@ class OnlinePaymentController extends BaseController
$paymentDriver = $accountGateway->paymentDriver(); $paymentDriver = $accountGateway->paymentDriver();
try { try {
$result = $paymentDriver->handleWebHook(Request::all()); $result = $paymentDriver->handleWebHook(Input::all());
return response()->json(['message' => $result]); return response()->json(['message' => $result]);
} catch (Exception $exception) { } catch (Exception $exception) {
@ -350,8 +350,8 @@ class OnlinePaymentController extends BaseController
return redirect()->to(NINJA_WEB_URL, 301); return redirect()->to(NINJA_WEB_URL, 301);
} }
$account = Account::whereAccountKey(\Request::input('account_key'))->first(); $account = Account::whereAccountKey(Input::get('account_key'))->first();
$redirectUrl = \Request::input('redirect_url'); $redirectUrl = Input::get('redirect_url');
$failureUrl = URL::previous(); $failureUrl = URL::previous();
if (! $account || ! $account->enable_buy_now_buttons || ! $account->hasFeature(FEATURE_BUY_NOW_BUTTONS)) { if (! $account || ! $account->enable_buy_now_buttons || ! $account->hasFeature(FEATURE_BUY_NOW_BUTTONS)) {
@ -360,7 +360,7 @@ class OnlinePaymentController extends BaseController
Auth::onceUsingId($account->users[0]->id); Auth::onceUsingId($account->users[0]->id);
$account->loadLocalizationSettings(); $account->loadLocalizationSettings();
$product = Product::scope(\Request::input('product_id'))->first(); $product = Product::scope(Input::get('product_id'))->first();
if (! $product) { if (! $product) {
return redirect()->to("{$failureUrl}/?error=invalid product"); return redirect()->to("{$failureUrl}/?error=invalid product");
@ -368,7 +368,7 @@ class OnlinePaymentController extends BaseController
// check for existing client using contact_key // check for existing client using contact_key
$client = false; $client = false;
if ($contactKey = \Request::input('contact_key')) { if ($contactKey = Input::get('contact_key')) {
$client = Client::scope()->whereHas('contacts', function ($query) use ($contactKey) { $client = Client::scope()->whereHas('contacts', function ($query) use ($contactKey) {
$query->where('contact_key', $contactKey); $query->where('contact_key', $contactKey);
})->first(); })->first();
@ -380,7 +380,7 @@ class OnlinePaymentController extends BaseController
'email' => 'email|string|max:100', 'email' => 'email|string|max:100',
]; ];
$validator = Validator::make(Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return redirect()->to("{$failureUrl}/?error=" . $validator->errors()->first()); return redirect()->to("{$failureUrl}/?error=" . $validator->errors()->first());
} }
@ -404,17 +404,17 @@ class OnlinePaymentController extends BaseController
$data = [ $data = [
'client_id' => $client->id, 'client_id' => $client->id,
'is_recurring' => filter_var(\Request::input('is_recurring'), FILTER_VALIDATE_BOOLEAN), 'is_recurring' => filter_var(Input::get('is_recurring'), FILTER_VALIDATE_BOOLEAN),
'is_public' => filter_var(\Request::input('is_recurring'), FILTER_VALIDATE_BOOLEAN), 'is_public' => filter_var(Input::get('is_recurring'), FILTER_VALIDATE_BOOLEAN),
'frequency_id' => \Request::input('frequency_id'), 'frequency_id' => Input::get('frequency_id'),
'auto_bill_id' => \Request::input('auto_bill_id'), 'auto_bill_id' => Input::get('auto_bill_id'),
'start_date' => \Request::input('start_date', date('Y-m-d')), 'start_date' => Input::get('start_date', date('Y-m-d')),
'tax_rate1' => $account->tax_rate1, 'tax_rate1' => $account->tax_rate1,
'tax_name1' => $account->tax_name1 ?: '', 'tax_name1' => $account->tax_name1 ?: '',
'tax_rate2' => $account->tax_rate2, 'tax_rate2' => $account->tax_rate2,
'tax_name2' => $account->tax_name2 ?: '', 'tax_name2' => $account->tax_name2 ?: '',
'custom_text_value1' => \Request::input('custom_invoice1'), 'custom_text_value1' => Input::get('custom_invoice1'),
'custom_text_value2' => \Request::input('custom_invoice2'), 'custom_text_value2' => Input::get('custom_invoice2'),
'invoice_items' => [[ 'invoice_items' => [[
'product_key' => $product->product_key, 'product_key' => $product->product_key,
'notes' => $product->notes, 'notes' => $product->notes,
@ -424,8 +424,8 @@ class OnlinePaymentController extends BaseController
'tax_name1' => $product->tax_name1 ?: '', 'tax_name1' => $product->tax_name1 ?: '',
'tax_rate2' => $product->tax_rate2, 'tax_rate2' => $product->tax_rate2,
'tax_name2' => $product->tax_name2 ?: '', 'tax_name2' => $product->tax_name2 ?: '',
'custom_value1' => \Request::input('custom_product1') ?: $product->custom_value1, 'custom_value1' => Input::get('custom_product1') ?: $product->custom_value1,
'custom_value2' => \Request::input('custom_product2') ?: $product->custom_value2, 'custom_value2' => Input::get('custom_product2') ?: $product->custom_value2,
]], ]],
]; ];
$invoice = $invoiceService->save($data); $invoice = $invoiceService->save($data);
@ -445,7 +445,7 @@ class OnlinePaymentController extends BaseController
$link = $invitation->getLink(); $link = $invitation->getLink();
} }
if (filter_var(\Request::input('return_link'), FILTER_VALIDATE_BOOLEAN)) { if (filter_var(Input::get('return_link'), FILTER_VALIDATE_BOOLEAN)) {
return $link; return $link;
} else { } else {
return redirect()->to($link); return redirect()->to($link);

View file

@ -10,6 +10,7 @@ use App\Models\Payment;
use App\Ninja\Mailers\ContactMailer; use App\Ninja\Mailers\ContactMailer;
use App\Ninja\Repositories\PaymentRepository; use App\Ninja\Repositories\PaymentRepository;
use App\Services\PaymentService; use App\Services\PaymentService;
use Input;
use Response; use Response;
class PaymentApiController extends BaseAPIController class PaymentApiController extends BaseAPIController
@ -112,7 +113,7 @@ class PaymentApiController extends BaseAPIController
$payment = $this->paymentService->save($request->input(), null, $request->invoice); $payment = $this->paymentService->save($request->input(), null, $request->invoice);
if (\Request::input('email_receipt')) { if (Input::get('email_receipt')) {
$this->contactMailer->sendPaymentConfirmation($payment); $this->contactMailer->sendPaymentConfirmation($payment);
} }
@ -159,7 +160,7 @@ class PaymentApiController extends BaseAPIController
$data['public_id'] = $publicId; $data['public_id'] = $publicId;
$payment = $this->paymentRepo->save($data, $request->entity()); $payment = $this->paymentRepo->save($data, $request->entity());
if (\Request::input('email_receipt')) { if (Input::get('email_receipt')) {
$this->contactMailer->sendPaymentConfirmation($payment); $this->contactMailer->sendPaymentConfirmation($payment);
} }

View file

@ -16,10 +16,10 @@ use App\Services\PaymentService;
use Auth; use Auth;
use Cache; use Cache;
use DropdownButton; use DropdownButton;
use Input;
use Session; use Session;
use Utils; use Utils;
use View; use View;
use Request;
class PaymentController extends BaseController class PaymentController extends BaseController
{ {
@ -79,7 +79,7 @@ class PaymentController extends BaseController
*/ */
public function getDatatable($clientPublicId = null) public function getDatatable($clientPublicId = null)
{ {
return $this->paymentService->getDatatable($clientPublicId, \Request::input('sSearch')); return $this->paymentService->getDatatable($clientPublicId, Input::get('sSearch'));
} }
/** /**
@ -98,8 +98,8 @@ class PaymentController extends BaseController
->with('client', 'invoice_status') ->with('client', 'invoice_status')
->orderBy('invoice_number')->get(); ->orderBy('invoice_number')->get();
$clientPublicId = Request::old('client') ? Request::old('client') : ($request->client_id ?: 0); $clientPublicId = Input::old('client') ? Input::old('client') : ($request->client_id ?: 0);
$invoicePublicId = Request::old('invoice') ? Request::old('invoice') : ($request->invoice_id ?: 0); $invoicePublicId = Input::old('invoice') ? Input::old('invoice') : ($request->invoice_id ?: 0);
$totalCredit = false; $totalCredit = false;
if ($clientPublicId && $client = Client::scope($clientPublicId)->first()) { if ($clientPublicId && $client = Client::scope($clientPublicId)->first()) {
@ -118,7 +118,7 @@ class PaymentController extends BaseController
'method' => 'POST', 'method' => 'POST',
'url' => 'payments', 'url' => 'payments',
'title' => trans('texts.new_payment'), 'title' => trans('texts.new_payment'),
'paymentTypeId' => \Request::input('paymentTypeId'), 'paymentTypeId' => Input::get('paymentTypeId'),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get(),
'totalCredit' => $totalCredit, 'totalCredit' => $totalCredit,
]; ];
@ -211,7 +211,7 @@ class PaymentController extends BaseController
$payment = $this->paymentService->save($input, null, $request->invoice); $payment = $this->paymentService->save($input, null, $request->invoice);
if (\Request::input('email_receipt')) { if (Input::get('email_receipt')) {
$this->contactMailer->sendPaymentConfirmation($payment); $this->contactMailer->sendPaymentConfirmation($payment);
Session::flash('message', trans($credit ? 'texts.created_payment_and_credit_emailed_client' : 'texts.created_payment_emailed_client')); Session::flash('message', trans($credit ? 'texts.created_payment_and_credit_emailed_client' : 'texts.created_payment_emailed_client'));
} else { } else {
@ -244,8 +244,8 @@ class PaymentController extends BaseController
*/ */
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
if ($action === 'email') { if ($action === 'email') {
$payment = Payment::scope($ids)->withArchived()->first(); $payment = Payment::scope($ids)->withArchived()->first();
@ -253,8 +253,8 @@ class PaymentController extends BaseController
Session::flash('message', trans('texts.emailed_payment')); Session::flash('message', trans('texts.emailed_payment'));
} else { } else {
$count = $this->paymentService->bulk($ids, $action, [ $count = $this->paymentService->bulk($ids, $action, [
'refund_amount' => \Request::input('refund_amount'), 'refund_amount' => Input::get('refund_amount'),
'refund_email' => \Request::input('refund_email'), 'refund_email' => Input::get('refund_email'),
]); ]);
if ($count > 0) { if ($count > 0) {
$message = Utils::pluralize($action == 'refund' ? 'refunded_payment' : $action.'d_payment', $count); $message = Utils::pluralize($action == 'refund' ? 'refunded_payment' : $action.'d_payment', $count);

View file

@ -115,7 +115,7 @@ class PaymentTermApiController extends BaseAPIController
$paymentTerm = PaymentTerm::createNew(); $paymentTerm = PaymentTerm::createNew();
$paymentTerm->num_days = Utils::parseInt(\Request::input('num_days')); $paymentTerm->num_days = Utils::parseInt(Input::get('num_days'));
$paymentTerm->name = 'Net ' . $paymentTerm->num_days; $paymentTerm->name = 'Net ' . $paymentTerm->num_days;
$paymentTerm->save(); $paymentTerm->save();

View file

@ -7,6 +7,7 @@ use App\Http\Requests\UpdatePaymentTermRequest;
use App\Models\PaymentTerm; use App\Models\PaymentTerm;
use App\Services\PaymentTermService; use App\Services\PaymentTermService;
use Auth; use Auth;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -113,7 +114,7 @@ class PaymentTermController extends BaseController
$paymentTerm = PaymentTerm::createNew(); $paymentTerm = PaymentTerm::createNew();
} }
$paymentTerm->num_days = Utils::parseInt(\Request::input('num_days')); $paymentTerm->num_days = Utils::parseInt(Input::get('num_days'));
$paymentTerm->name = 'Net ' . $paymentTerm->num_days; $paymentTerm->name = 'Net ' . $paymentTerm->num_days;
$paymentTerm->save(); $paymentTerm->save();
@ -128,8 +129,8 @@ class PaymentTermController extends BaseController
*/ */
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action'); $action = Input::get('bulk_action');
$ids = \Request::input('bulk_public_id'); $ids = Input::get('bulk_public_id');
$count = $this->paymentTermService->bulk($ids, $action); $count = $this->paymentTermService->bulk($ids, $action);
Session::flash('message', trans('texts.archived_payment_term')); Session::flash('message', trans('texts.archived_payment_term'));

View file

@ -12,6 +12,7 @@ use App\Ninja\Repositories\ProductRepository;
use App\Services\ProductService; use App\Services\ProductService;
use Auth; use Auth;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -71,7 +72,7 @@ class ProductController extends BaseController
*/ */
public function getDatatable() public function getDatatable()
{ {
return $this->productService->getDatatable(Auth::user()->account_id, \Request::input('sSearch')); return $this->productService->getDatatable(Auth::user()->account_id, Input::get('sSearch'));
} }
public function cloneProduct(ProductRequest $request, $publicId) public function cloneProduct(ProductRequest $request, $publicId)
@ -166,7 +167,7 @@ class ProductController extends BaseController
$product = Product::createNew(); $product = Product::createNew();
} }
$this->productRepo->save(\Request::all(), $product); $this->productRepo->save(Input::all(), $product);
$message = $productPublicId ? trans('texts.updated_product') : trans('texts.created_product'); $message = $productPublicId ? trans('texts.updated_product') : trans('texts.created_product');
Session::flash('message', $message); Session::flash('message', $message);
@ -188,8 +189,8 @@ class ProductController extends BaseController
*/ */
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
if ($action == 'invoice') { if ($action == 'invoice') {
$products = Product::scope($ids)->get(); $products = Product::scope($ids)->get();

View file

@ -9,6 +9,7 @@ use App\Models\Project;
use App\Ninja\Repositories\ProjectRepository; use App\Ninja\Repositories\ProjectRepository;
use App\Services\ProjectService; use App\Services\ProjectService;
use Auth; use Auth;
use Input;
use Session; use Session;
use View; use View;

View file

@ -12,6 +12,7 @@ use App\Ninja\Datatables\ProjectDatatable;
use App\Ninja\Repositories\ProjectRepository; use App\Ninja\Repositories\ProjectRepository;
use App\Services\ProjectService; use App\Services\ProjectService;
use Auth; use Auth;
use Input;
use Session; use Session;
use View; use View;
@ -43,7 +44,7 @@ class ProjectController extends BaseController
public function getDatatable($expensePublicId = null) public function getDatatable($expensePublicId = null)
{ {
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
$userId = Auth::user()->filterIdByEntity(ENTITY_PROJECT); $userId = Auth::user()->filterIdByEntity(ENTITY_PROJECT);
return $this->projectService->getDatatable($search, $userId); return $this->projectService->getDatatable($search, $userId);
@ -113,7 +114,7 @@ class ProjectController extends BaseController
Session::flash('message', trans('texts.updated_project')); Session::flash('message', trans('texts.updated_project'));
$action = \Request::input('action'); $action = Input::get('action');
if (in_array($action, ['archive', 'delete', 'restore', 'invoice'])) { if (in_array($action, ['archive', 'delete', 'restore', 'invoice'])) {
return self::bulk(); return self::bulk();
} }
@ -123,8 +124,8 @@ class ProjectController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
if ($action == 'invoice') { if ($action == 'invoice') {
$data = []; $data = [];

View file

@ -11,6 +11,7 @@ use App\Ninja\Datatables\ProposalCategoryDatatable;
use App\Ninja\Repositories\ProposalCategoryRepository; use App\Ninja\Repositories\ProposalCategoryRepository;
use App\Services\ProposalCategoryService; use App\Services\ProposalCategoryService;
use Auth; use Auth;
use Input;
use Session; use Session;
use View; use View;
@ -42,7 +43,7 @@ class ProposalCategoryController extends BaseController
public function getDatatable($expensePublicId = null) public function getDatatable($expensePublicId = null)
{ {
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
$userId = Auth::user()->filterId(); $userId = Auth::user()->filterId();
return $this->proposalCategoryService->getDatatable($search, $userId); return $this->proposalCategoryService->getDatatable($search, $userId);
@ -101,7 +102,7 @@ class ProposalCategoryController extends BaseController
Session::flash('message', trans('texts.updated_proposal_category')); Session::flash('message', trans('texts.updated_proposal_category'));
$action = \Request::input('action'); $action = Input::get('action');
if (in_array($action, ['archive', 'delete', 'restore'])) { if (in_array($action, ['archive', 'delete', 'restore'])) {
return self::bulk(); return self::bulk();
} }
@ -111,8 +112,8 @@ class ProposalCategoryController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->proposalCategoryService->bulk($ids, $action); $count = $this->proposalCategoryService->bulk($ids, $action);

View file

@ -15,6 +15,7 @@ use App\Ninja\Datatables\ProposalDatatable;
use App\Ninja\Repositories\ProposalRepository; use App\Ninja\Repositories\ProposalRepository;
use App\Services\ProposalService; use App\Services\ProposalService;
use Auth; use Auth;
use Input;
use Session; use Session;
use View; use View;
@ -49,7 +50,7 @@ class ProposalController extends BaseController
public function getDatatable($expensePublicId = null) public function getDatatable($expensePublicId = null)
{ {
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
//$userId = Auth::user()->filterId(); //$userId = Auth::user()->filterId();
$userId = Auth::user()->filterIdByEntity(ENTITY_PROPOSAL); $userId = Auth::user()->filterIdByEntity(ENTITY_PROPOSAL);
@ -116,7 +117,7 @@ class ProposalController extends BaseController
public function store(CreateProposalRequest $request) public function store(CreateProposalRequest $request)
{ {
$proposal = $this->proposalService->save($request->input()); $proposal = $this->proposalService->save($request->input());
$action = \Request::input('action'); $action = Input::get('action');
if ($action == 'email') { if ($action == 'email') {
$this->dispatch(new SendInvoiceEmail($proposal->invoice, auth()->user()->id, false, false, $proposal)); $this->dispatch(new SendInvoiceEmail($proposal->invoice, auth()->user()->id, false, false, $proposal));
@ -131,7 +132,7 @@ class ProposalController extends BaseController
public function update(UpdateProposalRequest $request) public function update(UpdateProposalRequest $request)
{ {
$proposal = $this->proposalService->save($request->input(), $request->entity()); $proposal = $this->proposalService->save($request->input(), $request->entity());
$action = \Request::input('action'); $action = Input::get('action');
if (in_array($action, ['archive', 'delete', 'restore'])) { if (in_array($action, ['archive', 'delete', 'restore'])) {
return self::bulk(); return self::bulk();
@ -149,8 +150,8 @@ class ProposalController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action') ?: \Request::input('action'); $action = Input::get('bulk_action') ?: Input::get('action');
$ids = \Request::input('bulk_public_id') ?: (\Request::input('public_id') ?: \Request::input('ids')); $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
$count = $this->proposalService->bulk($ids, $action); $count = $this->proposalService->bulk($ids, $action);

View file

@ -12,6 +12,7 @@ use App\Ninja\Datatables\ProposalSnippetDatatable;
use App\Ninja\Repositories\ProposalSnippetRepository; use App\Ninja\Repositories\ProposalSnippetRepository;
use App\Services\ProposalSnippetService; use App\Services\ProposalSnippetService;
use Auth; use Auth;
use Input;
use Session; use Session;
use View; use View;
@ -43,7 +44,7 @@ class ProposalSnippetController extends BaseController
public function getDatatable($expensePublicId = null) public function getDatatable($expensePublicId = null)
{ {
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
$userId = Auth::user()->filterId(); $userId = Auth::user()->filterId();
return $this->proposalSnippetService->getDatatable($search, $userId); return $this->proposalSnippetService->getDatatable($search, $userId);
@ -106,7 +107,7 @@ class ProposalSnippetController extends BaseController
Session::flash('message', trans('texts.updated_proposal_snippet')); Session::flash('message', trans('texts.updated_proposal_snippet'));
$action = \Request::input('action'); $action = Input::get('action');
if (in_array($action, ['archive', 'delete', 'restore'])) { if (in_array($action, ['archive', 'delete', 'restore'])) {
return self::bulk(); return self::bulk();
} }
@ -116,8 +117,8 @@ class ProposalSnippetController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->proposalSnippetService->bulk($ids, $action); $count = $this->proposalSnippetService->bulk($ids, $action);

View file

@ -11,6 +11,7 @@ use App\Ninja\Datatables\ProposalTemplateDatatable;
use App\Ninja\Repositories\ProposalTemplateRepository; use App\Ninja\Repositories\ProposalTemplateRepository;
use App\Services\ProposalTemplateService; use App\Services\ProposalTemplateService;
use Auth; use Auth;
use Input;
use Session; use Session;
use View; use View;
@ -42,7 +43,7 @@ class ProposalTemplateController extends BaseController
public function getDatatable($expensePublicId = null) public function getDatatable($expensePublicId = null)
{ {
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
$userId = Auth::user()->filterId(); $userId = Auth::user()->filterId();
return $this->proposalTemplateService->getDatatable($search, $userId); return $this->proposalTemplateService->getDatatable($search, $userId);
@ -146,7 +147,7 @@ class ProposalTemplateController extends BaseController
Session::flash('message', trans('texts.updated_proposal_template')); Session::flash('message', trans('texts.updated_proposal_template'));
$action = \Request::input('action'); $action = Input::get('action');
if (in_array($action, ['archive', 'delete', 'restore'])) { if (in_array($action, ['archive', 'delete', 'restore'])) {
return self::bulk(); return self::bulk();
} }
@ -156,8 +157,8 @@ class ProposalTemplateController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->proposalTemplateService->bulk($ids, $action); $count = $this->proposalTemplateService->bulk($ids, $action);

View file

@ -19,6 +19,7 @@ use App\Ninja\Repositories\InvoiceRepository;
use App\Services\InvoiceService; use App\Services\InvoiceService;
use Auth; use Auth;
use Cache; use Cache;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use Utils; use Utils;
@ -59,7 +60,7 @@ class QuoteController extends BaseController
public function getDatatable($clientPublicId = null) public function getDatatable($clientPublicId = null)
{ {
$accountId = Auth::user()->account_id; $accountId = Auth::user()->account_id;
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
return $this->invoiceService->getDatatable($accountId, $clientPublicId, ENTITY_QUOTE, $search); return $this->invoiceService->getDatatable($accountId, $clientPublicId, ENTITY_QUOTE, $search);
} }
@ -81,7 +82,7 @@ class QuoteController extends BaseController
$data = [ $data = [
'entityType' => $invoice->getEntityType(), 'entityType' => $invoice->getEntityType(),
'invoice' => $invoice, 'invoice' => $invoice,
'data' => \Request::old('data'), 'data' => Input::old('data'),
'method' => 'POST', 'method' => 'POST',
'url' => 'invoices', 'url' => 'invoices',
'title' => trans('texts.new_quote'), 'title' => trans('texts.new_quote'),
@ -114,9 +115,9 @@ class QuoteController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action') ?: \Request::input('action'); $action = Input::get('bulk_action') ?: Input::get('action');
; ;
$ids = \Request::input('bulk_public_id') ?: (\Request::input('public_id') ?: \Request::input('ids')); $ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
if ($action == 'convert') { if ($action == 'convert') {
$invoice = Invoice::with('invoice_items')->scope($ids)->firstOrFail(); $invoice = Invoice::with('invoice_items')->scope($ids)->firstOrFail();

View file

@ -13,10 +13,10 @@ use App\Ninja\Datatables\RecurringExpenseDatatable;
use App\Ninja\Repositories\RecurringExpenseRepository; use App\Ninja\Repositories\RecurringExpenseRepository;
use App\Services\RecurringExpenseService; use App\Services\RecurringExpenseService;
use Auth; use Auth;
use Input;
use Session; use Session;
use View; use View;
use Cache; use Cache;
use Request;
class RecurringExpenseController extends BaseController class RecurringExpenseController extends BaseController
{ {
@ -46,7 +46,7 @@ class RecurringExpenseController extends BaseController
public function getDatatable($expensePublicId = null) public function getDatatable($expensePublicId = null)
{ {
$search = \Request::input('sSearch'); $search = Input::get('sSearch');
$userId = Auth::user()->filterId(); $userId = Auth::user()->filterId();
return $this->recurringExpenseService->getDatatable($search, $userId); return $this->recurringExpenseService->getDatatable($search, $userId);
@ -61,7 +61,7 @@ class RecurringExpenseController extends BaseController
} }
$data = [ $data = [
'vendorPublicId' => Request::old('vendor') ? Request::old('vendor') : $request->vendor_id, 'vendorPublicId' => Input::old('vendor') ? Input::old('vendor') : $request->vendor_id,
'expense' => null, 'expense' => null,
'method' => 'POST', 'method' => 'POST',
'url' => 'recurring_expenses', 'url' => 'recurring_expenses',
@ -113,7 +113,7 @@ class RecurringExpenseController extends BaseController
private static function getViewModel() private static function getViewModel()
{ {
return [ return [
'data' => Request::old('data'), 'data' => Input::old('data'),
'account' => Auth::user()->account, 'account' => Auth::user()->account,
'categories' => ExpenseCategory::whereAccountId(Auth::user()->account_id)->withArchived()->orderBy('name')->get(), 'categories' => ExpenseCategory::whereAccountId(Auth::user()->account_id)->withArchived()->orderBy('name')->get(),
'taxRates' => TaxRate::scope()->whereIsInclusive(false)->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->whereIsInclusive(false)->orderBy('name')->get(),
@ -136,7 +136,7 @@ class RecurringExpenseController extends BaseController
Session::flash('message', trans('texts.updated_recurring_expense')); Session::flash('message', trans('texts.updated_recurring_expense'));
if (in_array(\Request::input('action'), ['archive', 'delete', 'restore'])) { if (in_array(Input::get('action'), ['archive', 'delete', 'restore'])) {
return self::bulk(); return self::bulk();
} }
@ -145,8 +145,8 @@ class RecurringExpenseController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->recurringExpenseService->bulk($ids, $action); $count = $this->recurringExpenseService->bulk($ids, $action);
if ($count > 0) { if ($count > 0) {

View file

@ -8,6 +8,7 @@ use App\Jobs\RunReport;
use App\Models\Account; use App\Models\Account;
use App\Models\ScheduledReport; use App\Models\ScheduledReport;
use Auth; use Auth;
use Input;
use Utils; use Utils;
use View; use View;
use Carbon; use Carbon;
@ -57,14 +58,14 @@ class ReportController extends BaseController
return redirect('/'); return redirect('/');
} }
$action = \Request::input('action'); $action = Input::get('action');
$format = \Request::input('format'); $format = Input::get('format');
if (\Request::input('report_type')) { if (Input::get('report_type')) {
$reportType = \Request::input('report_type'); $reportType = Input::get('report_type');
$dateField = \Request::input('date_field'); $dateField = Input::get('date_field');
$startDate = date_create(\Request::input('start_date')); $startDate = date_create(Input::get('start_date'));
$endDate = date_create(\Request::input('end_date')); $endDate = date_create(Input::get('end_date'));
} else { } else {
$reportType = ENTITY_INVOICE; $reportType = ENTITY_INVOICE;
$dateField = FILTER_INVOICE_DATE; $dateField = FILTER_INVOICE_DATE;

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Models\Subscription; use App\Models\Subscription;
use App\Services\SubscriptionService; use App\Services\SubscriptionService;
use Auth; use Auth;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -106,8 +107,8 @@ class SubscriptionController extends BaseController
*/ */
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action'); $action = Input::get('bulk_action');
$ids = \Request::input('bulk_public_id'); $ids = Input::get('bulk_public_id');
$count = $this->subscriptionService->bulk($ids, $action); $count = $this->subscriptionService->bulk($ids, $action);
@ -136,7 +137,7 @@ class SubscriptionController extends BaseController
$subscriptionPublicId = $subscription->public_id; $subscriptionPublicId = $subscription->public_id;
} }
$validator = Validator::make(\Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to($subscriptionPublicId ? 'subscriptions/edit' : 'subscriptions/create')->withInput()->withErrors($validator); return Redirect::to($subscriptionPublicId ? 'subscriptions/edit' : 'subscriptions/create')->withInput()->withErrors($validator);

View file

@ -8,6 +8,7 @@ use App\Models\Task;
use App\Ninja\Repositories\TaskRepository; use App\Ninja\Repositories\TaskRepository;
use App\Ninja\Transformers\TaskTransformer; use App\Ninja\Transformers\TaskTransformer;
use Auth; use Auth;
use Input;
use Response; use Response;
class TaskApiController extends BaseAPIController class TaskApiController extends BaseAPIController
@ -102,7 +103,7 @@ class TaskApiController extends BaseAPIController
*/ */
public function store() public function store()
{ {
$data = \Request::all(); $data = Input::all();
$taskId = isset($data['id']) ? $data['id'] : false; $taskId = isset($data['id']) ? $data['id'] : false;
if (isset($data['client_id']) && $data['client_id']) { if (isset($data['client_id']) && $data['client_id']) {
@ -142,7 +143,7 @@ class TaskApiController extends BaseAPIController
$task = $this->taskRepo->save($taskId, $data); $task = $this->taskRepo->save($taskId, $data);
$task = Task::scope($task->public_id)->with('client')->first(); $task = Task::scope($task->public_id)->with('client')->first();
$transformer = new TaskTransformer(Auth::user()->account, \Request::input('serializer')); $transformer = new TaskTransformer(Auth::user()->account, Input::get('serializer'));
$data = $this->createItem($task, $transformer, 'task'); $data = $this->createItem($task, $transformer, 'task');
return $this->response($data); return $this->response($data);
@ -184,7 +185,7 @@ class TaskApiController extends BaseAPIController
$task = $request->entity(); $task = $request->entity();
$task = $this->taskRepo->save($task->public_id, \Illuminate\Support\Facades\Request::all()); $task = $this->taskRepo->save($task->public_id, \Illuminate\Support\Facades\Input::all());
return $this->itemResponse($task); return $this->itemResponse($task);
} }

View file

@ -15,6 +15,7 @@ use App\Ninja\Repositories\TaskRepository;
use App\Services\TaskService; use App\Services\TaskService;
use Auth; use Auth;
use DropdownButton; use DropdownButton;
use Input;
use Redirect; use Redirect;
use Request; use Request;
use Session; use Session;
@ -85,7 +86,7 @@ class TaskController extends BaseController
*/ */
public function getDatatable($clientPublicId = null, $projectPublicId = null) public function getDatatable($clientPublicId = null, $projectPublicId = null)
{ {
return $this->taskService->getDatatable($clientPublicId, $projectPublicId, \Request::input('sSearch')); return $this->taskService->getDatatable($clientPublicId, $projectPublicId, Input::get('sSearch'));
} }
/** /**
@ -125,8 +126,8 @@ class TaskController extends BaseController
$data = [ $data = [
'task' => null, 'task' => null,
'clientPublicId' => Request::old('client') ? Request::old('client') : ($request->client_id ?: 0), 'clientPublicId' => Input::old('client') ? Input::old('client') : ($request->client_id ?: 0),
'projectPublicId' => Request::old('project_id') ? Request::old('project_id') : ($request->project_id ?: 0), 'projectPublicId' => Input::old('project_id') ? Input::old('project_id') : ($request->project_id ?: 0),
'method' => 'POST', 'method' => 'POST',
'url' => 'tasks', 'url' => 'tasks',
'title' => trans('texts.new_task'), 'title' => trans('texts.new_task'),
@ -228,7 +229,7 @@ class TaskController extends BaseController
*/ */
private function save($request, $publicId = null) private function save($request, $publicId = null)
{ {
$action = \Request::input('action'); $action = Input::get('action');
if (in_array($action, ['archive', 'delete', 'restore'])) { if (in_array($action, ['archive', 'delete', 'restore'])) {
return self::bulk(); return self::bulk();
@ -259,8 +260,8 @@ class TaskController extends BaseController
*/ */
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ?: (\Request::input('id') ?: \Request::input('ids')); $ids = Input::get('public_id') ?: (Input::get('id') ?: Input::get('ids'));
$referer = Request::server('HTTP_REFERER'); $referer = Request::server('HTTP_REFERER');
if (in_array($action, ['resume', 'stop'])) { if (in_array($action, ['resume', 'stop'])) {
@ -276,7 +277,7 @@ class TaskController extends BaseController
Session::flash('message', trans('texts.updated_task_status')); Session::flash('message', trans('texts.updated_task_status'));
return $this->returnBulk($this->entityType, $action, $ids); return $this->returnBulk($this->entityType, $action, $ids);
} elseif ($action == 'invoice' || $action == 'add_to_invoice') { } elseif ($action == 'invoice' || $action == 'add_to_invoice') {
$tasks = Task::scope($ids)->with('account', 'client', 'project')->orderBy('project_id')->orderBy('id')->get(); $tasks = Task::scope($ids)->with('account', 'client', 'project')->orderBy('project_id', 'id')->get();
$clientPublicId = false; $clientPublicId = false;
$data = []; $data = [];
@ -314,7 +315,7 @@ class TaskController extends BaseController
if ($action == 'invoice') { if ($action == 'invoice') {
return Redirect::to("invoices/create/{$clientPublicId}")->with('tasks', $data); return Redirect::to("invoices/create/{$clientPublicId}")->with('tasks', $data);
} else { } else {
$invoiceId = \Request::input('invoice_id'); $invoiceId = Input::get('invoice_id');
return Redirect::to("invoices/{$invoiceId}/edit")->with('tasks', $data); return Redirect::to("invoices/{$invoiceId}/edit")->with('tasks', $data);
} }

View file

@ -8,6 +8,7 @@ use App\Models\TaxRate;
use App\Ninja\Repositories\TaxRateRepository; use App\Ninja\Repositories\TaxRateRepository;
use App\Services\TaxRateService; use App\Services\TaxRateService;
use Auth; use Auth;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -80,8 +81,8 @@ class TaxRateController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action'); $action = Input::get('bulk_action');
$ids = \Request::input('bulk_public_id'); $ids = Input::get('bulk_public_id');
$count = $this->taxRateService->bulk($ids, $action); $count = $this->taxRateService->bulk($ids, $action);
Session::flash('message', trans('texts.archived_tax_rate')); Session::flash('message', trans('texts.archived_tax_rate'));

View file

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use App\Models\AccountToken; use App\Models\AccountToken;
use App\Services\TokenService; use App\Services\TokenService;
use Auth; use Auth;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -107,8 +108,8 @@ class TokenController extends BaseController
*/ */
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action'); $action = Input::get('bulk_action');
$ids = \Request::input('bulk_public_id'); $ids = Input::get('bulk_public_id');
$count = $this->tokenService->bulk($ids, $action); $count = $this->tokenService->bulk($ids, $action);
Session::flash('message', trans('texts.archived_token')); Session::flash('message', trans('texts.archived_token'));
@ -133,17 +134,17 @@ class TokenController extends BaseController
->where('public_id', '=', $tokenPublicId)->firstOrFail(); ->where('public_id', '=', $tokenPublicId)->firstOrFail();
} }
$validator = Validator::make(\Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to($tokenPublicId ? 'tokens/edit' : 'tokens/create')->withInput()->withErrors($validator); return Redirect::to($tokenPublicId ? 'tokens/edit' : 'tokens/create')->withInput()->withErrors($validator);
} }
if ($tokenPublicId) { if ($tokenPublicId) {
$token->name = trim(\Request::input('name')); $token->name = trim(Input::get('name'));
} else { } else {
$token = AccountToken::createNew(); $token = AccountToken::createNew();
$token->name = trim(\Request::input('name')); $token->name = trim(Input::get('name'));
$token->token = strtolower(str_random(RANDOM_KEY_LENGTH)); $token->token = strtolower(str_random(RANDOM_KEY_LENGTH));
} }

View file

@ -8,6 +8,7 @@ use App\Ninja\Mailers\UserMailer;
use App\Ninja\Repositories\AccountRepository; use App\Ninja\Repositories\AccountRepository;
use App\Services\UserService; use App\Services\UserService;
use Auth; use Auth;
use Input;
use Password; use Password;
use Redirect; use Redirect;
use Request; use Request;
@ -130,8 +131,8 @@ class UserController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('bulk_action'); $action = Input::get('bulk_action');
$id = \Request::input('bulk_public_id'); $id = Input::get('bulk_public_id');
$user = User::where('account_id', '=', Auth::user()->account_id) $user = User::where('account_id', '=', Auth::user()->account_id)
->where('public_id', '=', $id) ->where('public_id', '=', $id)
@ -183,7 +184,7 @@ class UserController extends BaseController
$rules['email'] = 'required|email|unique:users'; $rules['email'] = 'required|email|unique:users';
} }
$validator = Validator::make(Request::all(), $rules); $validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) { if ($validator->fails()) {
return Redirect::to($userPublicId ? 'users/edit' : 'users/create') return Redirect::to($userPublicId ? 'users/edit' : 'users/create')
@ -191,20 +192,20 @@ class UserController extends BaseController
->withInput(); ->withInput();
} }
if (! \App\Models\LookupUser::validateField('email', \Request::input('email'), $user)) { if (! \App\Models\LookupUser::validateField('email', Input::get('email'), $user)) {
return Redirect::to($userPublicId ? 'users/edit' : 'users/create') return Redirect::to($userPublicId ? 'users/edit' : 'users/create')
->withError(trans('texts.email_taken')) ->withError(trans('texts.email_taken'))
->withInput(); ->withInput();
} }
if ($userPublicId) { if ($userPublicId) {
$user->first_name = trim(\Request::input('first_name')); $user->first_name = trim(Input::get('first_name'));
$user->last_name = trim(\Request::input('last_name')); $user->last_name = trim(Input::get('last_name'));
$user->username = trim(\Request::input('email')); $user->username = trim(Input::get('email'));
$user->email = trim(\Request::input('email')); $user->email = trim(Input::get('email'));
if (Auth::user()->hasFeature(FEATURE_USER_PERMISSIONS)) { if (Auth::user()->hasFeature(FEATURE_USER_PERMISSIONS)) {
$user->is_admin = boolval(\Request::input('is_admin')); $user->is_admin = boolval(Input::get('is_admin'));
$user->permissions = self::formatUserPermissions(\Request::input('permissions')); $user->permissions = self::formatUserPermissions(Input::get('permissions'));
} }
} else { } else {
$lastUser = User::withTrashed()->where('account_id', '=', Auth::user()->account_id) $lastUser = User::withTrashed()->where('account_id', '=', Auth::user()->account_id)
@ -212,23 +213,23 @@ class UserController extends BaseController
$user = new User(); $user = new User();
$user->account_id = Auth::user()->account_id; $user->account_id = Auth::user()->account_id;
$user->first_name = trim(\Request::input('first_name')); $user->first_name = trim(Input::get('first_name'));
$user->last_name = trim(\Request::input('last_name')); $user->last_name = trim(Input::get('last_name'));
$user->username = trim(\Request::input('email')); $user->username = trim(Input::get('email'));
$user->email = trim(\Request::input('email')); $user->email = trim(Input::get('email'));
$user->registered = true; $user->registered = true;
$user->password = strtolower(str_random(RANDOM_KEY_LENGTH)); $user->password = strtolower(str_random(RANDOM_KEY_LENGTH));
$user->confirmation_code = strtolower(str_random(RANDOM_KEY_LENGTH)); $user->confirmation_code = strtolower(str_random(RANDOM_KEY_LENGTH));
$user->public_id = $lastUser->public_id + 1; $user->public_id = $lastUser->public_id + 1;
if (Auth::user()->hasFeature(FEATURE_USER_PERMISSIONS)) { if (Auth::user()->hasFeature(FEATURE_USER_PERMISSIONS)) {
$user->is_admin = boolval(\Request::input('is_admin')); $user->is_admin = boolval(Input::get('is_admin'));
$user->permissions = self::formatUserPermissions(\Request::input('permissions')); $user->permissions = self::formatUserPermissions(Input::get('permissions'));
} }
} }
$user->save(); $user->save();
if (! $user->confirmed && \Request::input('action') === 'email') { if (! $user->confirmed && Input::get('action') === 'email') {
$this->userMailer->sendConfirmation($user, Auth::user()); $this->userMailer->sendConfirmation($user, Auth::user());
$message = trans('texts.sent_invite'); $message = trans('texts.sent_invite');
} else { } else {
@ -305,14 +306,14 @@ class UserController extends BaseController
// check the current password is correct // check the current password is correct
if (! Auth::validate([ if (! Auth::validate([
'email' => Auth::user()->email, 'email' => Auth::user()->email,
'password' => \Request::input('current_password'), 'password' => Input::get('current_password'),
])) { ])) {
return trans('texts.password_error_incorrect'); return trans('texts.password_error_incorrect');
} }
// validate the new password // validate the new password
$password = \Request::input('new_password'); $password = Input::get('new_password');
$confirm = \Request::input('confirm_password'); $confirm = Input::get('confirm_password');
if (strlen($password) < 6 || $password != $confirm) { if (strlen($password) < 6 || $password != $confirm) {
return trans('texts.password_error_invalid'); return trans('texts.password_error_invalid');
@ -388,12 +389,12 @@ class UserController extends BaseController
public function saveSidebarState() public function saveSidebarState()
{ {
if (Request::has('show_left')) { if (Input::has('show_left')) {
Session::put(SESSION_LEFT_SIDEBAR, boolval(\Request::input('show_left'))); Session::put(SESSION_LEFT_SIDEBAR, boolval(Input::get('show_left')));
} }
if (Request::has('show_right')) { if (Input::has('show_right')) {
Session::put(SESSION_RIGHT_SIDEBAR, boolval(\Request::input('show_right'))); Session::put(SESSION_RIGHT_SIDEBAR, boolval(Input::get('show_right')));
} }
return RESULT_SUCCESS; return RESULT_SUCCESS;

View file

@ -8,6 +8,7 @@ use App\Http\Requests\CreateVendorRequest;
use App\Http\Requests\UpdateVendorRequest; use App\Http\Requests\UpdateVendorRequest;
use App\Models\Vendor; use App\Models\Vendor;
use App\Ninja\Repositories\VendorRepository; use App\Ninja\Repositories\VendorRepository;
use Input;
use Response; use Response;
use Utils; use Utils;

View file

@ -12,6 +12,7 @@ use App\Ninja\Repositories\VendorRepository;
use App\Services\VendorService; use App\Services\VendorService;
use Auth; use Auth;
use Cache; use Cache;
use Input;
use Redirect; use Redirect;
use Session; use Session;
use URL; use URL;
@ -48,7 +49,7 @@ class VendorController extends BaseController
public function getDatatable() public function getDatatable()
{ {
return $this->vendorService->getDatatable(\Request::input('sSearch')); return $this->vendorService->getDatatable(Input::get('sSearch'));
} }
/** /**
@ -148,7 +149,7 @@ class VendorController extends BaseController
private static function getViewModel() private static function getViewModel()
{ {
return [ return [
'data' => \Request::old('data'), 'data' => Input::old('data'),
'account' => Auth::user()->account, 'account' => Auth::user()->account,
]; ];
} }
@ -171,8 +172,8 @@ class VendorController extends BaseController
public function bulk() public function bulk()
{ {
$action = \Request::input('action'); $action = Input::get('action');
$ids = \Request::input('public_id') ? \Request::input('public_id') : \Request::input('ids'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
$count = $this->vendorService->bulk($ids, $action); $count = $this->vendorService->bulk($ids, $action);
$message = Utils::pluralize($action.'d_vendor', $count); $message = Utils::pluralize($action.'d_vendor', $count);

View file

@ -64,6 +64,5 @@ class Kernel extends HttpKernel
'lookup' => \App\Http\Middleware\DatabaseLookup::class, 'lookup' => \App\Http\Middleware\DatabaseLookup::class,
'permissions.required' => \App\Http\Middleware\PermissionsRequired::class, 'permissions.required' => \App\Http\Middleware\PermissionsRequired::class,
'migration' => \App\Http\Middleware\EligibleForMigration::class, 'migration' => \App\Http\Middleware\EligibleForMigration::class,
'migration_channel' => \App\Http\Middleware\MigrationLookup::class,
]; ];
} }

View file

@ -104,9 +104,8 @@ class ApiCheck
return Response::json("Please wait {$wait} second(s)", 403, $headers); return Response::json("Please wait {$wait} second(s)", 403, $headers);
} }
Cache::put("hour_throttle:{$key}", $new_hour_throttle, 60);
Cache::put("hour_throttle:{$key}", $new_hour_throttle, 60 * 60); Cache::put("last_api_request:{$key}", time(), 60);
Cache::put("last_api_request:{$key}", time(), 60 * 60);
} }
return $next($request); return $next($request);

View file

@ -1,53 +0,0 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Closure;
use App\Models\LookupAccount;
use App\Models\LookupContact;
use App\Models\LookupInvitation;
use App\Models\LookupProposalInvitation;
use App\Models\LookupAccountToken;
use App\Models\LookupUser;
use Auth;
use Illuminate\Support\Carbon;
use Utils;
class MigrationLookup
{
private string $migration_notification = 'The Invoice Ninja v4 platform is now disabled for free users. Please <a class="btn btn-primary btn-sm" href="/migration/start">Migrate Now</a> to the new Invoice Ninja v5 platform to remain as a free account.<br><br>
*Not ready for v5? Upgrade to Pro or Enterprise to remain on v4. *Please note that the v4 platform will be "sunset" in November 2022.';
private string $silo = 'V4 is now disabled for your account. Please migrate. <a class="btn btn-primary btn-sm" href="/migration/start">Migrate Now</a> Upgrade to v5 and take advantage of our <a class="btn btn-danger btn-sm" href="https://invoicing.co/campaign/black_friday_2022">Black friday promo</a>';
public function handle(Request $request, Closure $next, $guard = 'user')
{
if (! env('MULTI_DB_ENABLED')) {
return $next($request);
}
//need to wrap an additional block over this to funnel users in a particular range
if(auth()->user()->id >= config('ninja.migration_user_start') &&
auth()->user()->id <= config('ninja.migration_user_end') &&
(!auth()->user()->account->company->plan_expires || Carbon::parse(auth()->user()->account->company->plan_expires)->lt(now())))
{
if ($guard == 'user') {
if(request()->is('migration/*') || request()->is('settings/*')) {
return $next($request);
}
}
return redirect('/settings/account_management')->with('warning',$this->silo);
}
elseif(!auth()->user()->account->company->plan_expires || Carbon::parse(auth()->user()->account->company->plan_expires)->lt(now())){
session()->flash('warning',$this->migration_notification);
}
return $next($request);
}
}

View file

@ -12,6 +12,7 @@ use Cache;
use Closure; use Closure;
use Event; use Event;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Input;
use Redirect; use Redirect;
use Schema; use Schema;
use Session; use Session;
@ -38,9 +39,9 @@ class StartupCheck
// set TRUSTED_PROXIES=* if you want to trust every proxy. // set TRUSTED_PROXIES=* if you want to trust every proxy.
if (isset($_ENV['TRUSTED_PROXIES'])) { if (isset($_ENV['TRUSTED_PROXIES'])) {
if (env('TRUSTED_PROXIES') == '*') { if (env('TRUSTED_PROXIES') == '*') {
$request->setTrustedProxies(['127.0.0.1', $request->server->get('REMOTE_ADDR')],Request::HEADER_X_FORWARDED_ALL); $request->setTrustedProxies(['127.0.0.1', $request->server->get('REMOTE_ADDR')]);
} else{ } else{
$request->setTrustedProxies(array_map('trim', explode(',', env('TRUSTED_PROXIES'))),Request::HEADER_X_FORWARDED_ALL); $request->setTrustedProxies(array_map('trim', explode(',', env('TRUSTED_PROXIES'))));
} }
} }
@ -150,8 +151,8 @@ class StartupCheck
} }
// Check if we're requesting to change the account's language // Check if we're requesting to change the account's language
if (\Request::has('lang')) { if (Input::has('lang')) {
$locale = \Request::input('lang'); $locale = Input::get('lang');
App::setLocale($locale); App::setLocale($locale);
session([SESSION_LOCALE => $locale]); session([SESSION_LOCALE => $locale]);
@ -171,15 +172,15 @@ class StartupCheck
// Make sure the account/user localization settings are in the session // Make sure the account/user localization settings are in the session
if (Auth::check() && ! Session::has(SESSION_TIMEZONE)) { if (Auth::check() && ! Session::has(SESSION_TIMEZONE)) {
Event::dispatch(new UserLoggedIn()); Event::fire(new UserLoggedIn());
} }
// Check if the user is claiming a license (ie, additional invoices, white label, etc.) // Check if the user is claiming a license (ie, additional invoices, white label, etc.)
if (! Utils::isNinjaProd() && isset($_SERVER['REQUEST_URI'])) { if (! Utils::isNinjaProd() && isset($_SERVER['REQUEST_URI'])) {
$claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license'); $claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
if (! $claimingLicense && \Request::has('license_key') && \Request::has('product_id')) { if (! $claimingLicense && Input::has('license_key') && Input::has('product_id')) {
$licenseKey = \Request::input('license_key'); $licenseKey = Input::get('license_key');
$productId = \Request::input('product_id'); $productId = Input::get('product_id');
$url = (Utils::isNinjaDev() ? SITE_URL : NINJA_APP_URL) . "/claim_license?license_key={$licenseKey}&product_id={$productId}&get_date=true"; $url = (Utils::isNinjaDev() ? SITE_URL : NINJA_APP_URL) . "/claim_license?license_key={$licenseKey}&product_id={$productId}&get_date=true";
$data = trim(CurlUtils::get($url)); $data = trim(CurlUtils::get($url));
@ -207,11 +208,11 @@ class StartupCheck
// Check data has been cached // Check data has been cached
$cachedTables = unserialize(CACHED_TABLES); $cachedTables = unserialize(CACHED_TABLES);
if (\Request::has('clear_cache')) { if (Input::has('clear_cache')) {
Session::flash('message', 'Cache cleared'); Session::flash('message', 'Cache cleared');
} }
foreach ($cachedTables as $name => $class) { foreach ($cachedTables as $name => $class) {
if (\Request::has('clear_cache') || ! Cache::has($name)) { if (Input::has('clear_cache') || ! Cache::has($name)) {
// check that the table exists in case the migration is pending // check that the table exists in case the migration is pending
if (! Schema::hasTable((new $class())->getTable())) { if (! Schema::hasTable((new $class())->getTable())) {
continue; continue;

View file

@ -4,6 +4,7 @@ namespace App\Http\Requests;
use App\Libraries\HistoryUtils; use App\Libraries\HistoryUtils;
use App\Models\EntityModel; use App\Models\EntityModel;
use Input;
use Utils; use Utils;
class EntityRequest extends Request class EntityRequest extends Request
@ -32,7 +33,7 @@ class EntityRequest extends Request
} }
} }
if (! $publicId) { if (! $publicId) {
$publicId = \Request::input('public_id') ?: \Request::input('id'); $publicId = Input::get('public_id') ?: Input::get('id');
} }
if (! $publicId) { if (! $publicId) {

View file

@ -1,30 +0,0 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class MigrationForwardRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'url' => 'nullable|url',
];
}
}

View file

@ -1,191 +0,0 @@
<?php
namespace App\Jobs;
use App\Jobs\Job;
use App\Libraries\Utils;
use App\Models\Account;
use App\Models\User;
use App\Services\Migration\CompleteService;
use App\Traits\GenerateMigrationResources;
use GuzzleHttp\RequestOptions;
use Illuminate\Support\Facades\Storage;
// use Unirest\Request;
class HostedMigration extends Job
{
use GenerateMigrationResources;
public $db;
public $data;
public $user;
private $v4_secret;
public $migration_token;
private $forced;
public $tries = 1;
public $timeout = 0;
public function __construct(User $user, array $data, $db, $forced = false)
{
$this->user = $user;
$this->data = $data;
$this->db = $db;
$this->forced = $forced;
$this->v4_secret = config('ninja.ninja_hosted_secret');
}
/**
* Execute the job.
*/
public function handle()
{
config(['database.default' => $this->db]);
//Create or get a token
$this->getToken();
$completeService = (new CompleteService($this->migration_token));
$migrationData = $this->generateMigrationData($this->data);
$completeService->data($migrationData)
->endpoint('https://v5-app1.invoicing.co')
// ->endpoint('http://devhosted.test:8000')
->start();
}
private function getToken()
{
$url = 'https://invoicing.co/api/v1/get_migration_account';
// $url = 'http://devhosted.test:8000/api/v1/get_migration_account';
$headers = [
'X-API-HOSTED-SECRET' => $this->v4_secret,
'X-Requested-With' => 'XMLHttpRequest',
'Content-Type' => 'application/json',
];
$body = [
'first_name' => $this->user->first_name,
'last_name' => $this->user->last_name,
'email' => $this->user->email,
'privacy_policy' => true,
'terms_of_service' => true,
'password' => '',
];
$client = new \GuzzleHttp\Client([
'headers' => $headers,
]);
$response = $client->post($url,[
RequestOptions::JSON => $body,
RequestOptions::ALLOW_REDIRECTS => false
]);
if($response->getStatusCode() == 401){
info($response->getBody());
} elseif ($response->getStatusCode() == 200) {
$message_body = json_decode($response->getBody(), true);
$this->migration_token = $message_body['token'];
} else {
// info(json_decode($response->getBody()->getContents()));
}
return $this;
}
public function generateMigrationData(array $data): array
{
set_time_limit(0);
$migrationData = [];
foreach ($data['companies'] as $company) {
$account = Account::where('account_key', $company['id'])->firstOrFail();
$this->account = $account;
if($this->forced){
//forced migration - we need to set this v4 account as inactive.
//set activate URL
$account_email_settings = $this->account->account_email_settings;
$account_email_settings->account_email_settings->forward_url_for_v5 = "https://invoiceninja-{$this->account->id}.invoicing.co";
$account_email_settings->save();
$this->account->subdomain = "invoiceninja-{$this->account->id}";
}
$date = date('Y-m-d');
$accountKey = $this->account->account_key;
$output = fopen('php://output', 'w') or Utils::fatalError();
$fileName = "{$accountKey}-{$date}-invoiceninja";
$localMigrationData['data'] = [
'account' => $this->getAccount(),
'company' => $this->getCompany(),
'users' => $this->getUsers(),
'tax_rates' => $this->getTaxRates(),
'payment_terms' => $this->getPaymentTerms(),
'clients' => $this->getClients(),
'company_gateways' => $this->getCompanyGateways(),
'client_gateway_tokens' => $this->getClientGatewayTokens(),
'vendors' => $this->getVendors(),
'projects' => $this->getProjects(),
'products' => $this->getProducts(),
'credits' => $this->getCreditsNotes(),
'invoices' => $this->getInvoices(),
'recurring_expenses' => $this->getRecurringExpenses(),
'recurring_invoices' => $this->getRecurringInvoices(),
'quotes' => $this->getQuotes(),
'payments' => $this->getPayments(),
'documents' => $this->getDocuments(),
'expense_categories' => $this->getExpenseCategories(),
'task_statuses' => $this->getTaskStatuses(),
'expenses' => $this->getExpenses(),
'tasks' => $this->getTasks(),
'documents' => $this->getDocuments(),
'ninja_tokens' => $this->getNinjaToken(),
];
$localMigrationData['force'] = array_key_exists('force', $company);
Storage::makeDirectory('migrations');
$file = Storage::path("app/migrations/{$fileName}.zip");
//$file = storage_path("migrations/{$fileName}.zip");
ksort($localMigrationData);
$zip = new \ZipArchive();
$zip->open($file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
$zip->addFromString('migration.json', json_encode($localMigrationData, JSON_PRETTY_PRINT));
$zip->close();
$localMigrationData['file'] = $file;
$migrationData[] = $localMigrationData;
}
return $migrationData;
}
}

View file

@ -21,7 +21,7 @@ class SendInvoiceEmail extends Job implements ShouldQueue
/** /**
* @var Invoice * @var Invoice
*/ */
public $invoice; protected $invoice;
/** /**
* @var bool * @var bool

View file

@ -2,53 +2,51 @@
namespace App\Jobs; namespace App\Jobs;
use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\Traits\SerialisesDeletedModels;
use App\Models\User;
use App\Ninja\Mailers\UserMailer; use App\Ninja\Mailers\UserMailer;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use App\Models\Traits\SerialisesDeletedModels;
/** /**
* Class SendInvoiceEmail. * Class SendInvoiceEmail.
*/ */
class SendNotificationEmail extends Job implements ShouldQueue class SendNotificationEmail extends Job implements ShouldQueue
{ {
use InteractsWithQueue; use InteractsWithQueue, SerializesModels, SerialisesDeletedModels {
SerialisesDeletedModels::getRestoredPropertyValue insteadof SerializesModels;
public $deleteWhenMissingModels = true; }
/** /**
* @var User * @var User
*/ */
public User $user; protected $user;
/** /**
* @var Invoice * @var Invoice
*/ */
public Invoice $invoice; protected $invoice;
/** /**
* @var string * @var string
*/ */
public $type; protected $type;
/** /**
* @var Payment * @var Payment
*/ */
public ?Payment $payment; protected $payment;
/** /**
* @var string * @var string
*/ */
public $notes; protected $notes;
/** /**
* @var string * @var string
*/ */
public $server; protected $server;
/** /**
* Create a new job instance. * Create a new job instance.
@ -61,7 +59,7 @@ class SendNotificationEmail extends Job implements ShouldQueue
* @param mixed $type * @param mixed $type
* @param mixed $payment * @param mixed $payment
*/ */
public function __construct(User $user, Invoice $invoice, $type, ?Payment $payment, $notes) public function __construct($user, $invoice, $type, $payment, $notes)
{ {
$this->user = $user; $this->user = $user;
$this->invoice = $invoice; $this->invoice = $invoice;

View file

@ -10,6 +10,7 @@ use Carbon;
use DateTime; use DateTime;
use DateTimeZone; use DateTimeZone;
use Exception; use Exception;
use Input;
use Log; use Log;
use Request; use Request;
use Schema; use Schema;
@ -436,7 +437,7 @@ class Utils
]; ];
if (static::isNinja()) { if (static::isNinja()) {
$data['url'] = \Request::input('url', Request::url()); $data['url'] = Input::get('url', Request::url());
$data['previous'] = url()->previous(); $data['previous'] = url()->previous();
} else { } else {
$data['url'] = request()->path(); $data['url'] = request()->path();

View file

@ -17,10 +17,14 @@ class DNSListener
public function addDNSRecord(SubdomainWasUpdated $event) public function addDNSRecord(SubdomainWasUpdated $event)
{ {
if(env("CLOUDFLARE_DNS_ENABLED"))
Cloudflare::addDNSRecord($event->account);
} }
public function removeDNSRecord(SubdomainWasRemoved $event) public function removeDNSRecord(SubdomainWasRemoved $event)
{ {
if(env("CLOUDFLARE_DNS_ENABLED"))
Cloudflare::removeDNSRecord($event->account);
} }
} }

View file

@ -1,20 +1,17 @@
<?php <?php namespace App\Listeners;
namespace App\Listeners; use App\Ninja\Mailers\UserMailer;
use App\Ninja\Mailers\ContactMailer;
use App\Events\InvoiceInvitationWasViewed;
use App\Events\InvoiceWasEmailed; use App\Events\InvoiceWasEmailed;
use App\Events\PaymentWasCreated;
use App\Events\QuoteInvitationWasApproved;
use App\Events\QuoteInvitationWasViewed;
use App\Events\QuoteWasEmailed; use App\Events\QuoteWasEmailed;
use App\Events\InvoiceInvitationWasViewed;
use App\Events\QuoteInvitationWasViewed;
use App\Events\QuoteInvitationWasApproved;
use App\Events\PaymentWasCreated;
use App\Services\PushService;
use App\Jobs\SendNotificationEmail; use App\Jobs\SendNotificationEmail;
use App\Jobs\SendPaymentEmail; use App\Jobs\SendPaymentEmail;
use App\Models\Invoice;
use App\Ninja\Mailers\ContactMailer;
use App\Ninja\Mailers\UserMailer;
use App\Notifications\PaymentCreated; use App\Notifications\PaymentCreated;
use App\Services\PushService;
/** /**
* Class NotificationListener * Class NotificationListener
@ -52,7 +49,7 @@ class NotificationListener
* @param $type * @param $type
* @param null $payment * @param null $payment
*/ */
private function sendNotifications(Invoice $invoice, $type, $payment = null, $notes = false) private function sendNotifications($invoice, $type, $payment = null, $notes = false)
{ {
foreach ($invoice->account->users as $user) foreach ($invoice->account->users as $user)
{ {

View file

@ -1,23 +0,0 @@
<?php
namespace App\Logging;
class CustomizeSingleLogger
{
/**
* Customize the given logger instance.
*
* @param \Illuminate\Log\Logger $logger
*
* @return void
*/
public function __invoke($logger)
{
$logger->pushHandler(new \Monolog\Handler\StreamHandler(storage_path() . '/logs/laravel-info.log',
\Monolog\Logger::INFO, false));
$logger->pushHandler(new \Monolog\Handler\StreamHandler(storage_path() . '/logs/laravel-warning.log',
\Monolog\Logger::WARNING, false));
$logger->pushHandler(new \Monolog\Handler\StreamHandler(storage_path() . '/logs/laravel-error.log',
\Monolog\Logger::ERROR, false));
}
}

View file

@ -1123,13 +1123,7 @@ class Account extends Eloquent
Session::put(SESSION_DATE_FORMAT, $this->date_format ? $this->date_format->format : DEFAULT_DATE_FORMAT); Session::put(SESSION_DATE_FORMAT, $this->date_format ? $this->date_format->format : DEFAULT_DATE_FORMAT);
Session::put(SESSION_DATE_PICKER_FORMAT, $this->date_format ? $this->date_format->picker_format : DEFAULT_DATE_PICKER_FORMAT); Session::put(SESSION_DATE_PICKER_FORMAT, $this->date_format ? $this->date_format->picker_format : DEFAULT_DATE_PICKER_FORMAT);
//php 7.3 $currencyId = ($client && $client->currency_id) ? $client->currency_id : $this->currency_id ?: DEFAULT_CURRENCY;
// $currencyId = ($client && $client->currency_id) ? $client->currency_id : $this->currency_id ?: DEFAULT_CURRENCY;
//php 7.4
$currencyId = ($client && $client->currency_id) ? $client->currency_id : ($this->currency_id ?: DEFAULT_CURRENCY);
// $currencyId = ($client && $client->currency_id) ? $client->currency_id : $this->currency_id ?: DEFAULT_CURRENCY;
$locale = ($client && $client->language_id) ? $client->language->locale : ($this->language_id ? $this->Language->locale : DEFAULT_LOCALE); $locale = ($client && $client->language_id) ? $client->language->locale : ($this->language_id ? $this->Language->locale : DEFAULT_LOCALE);
Session::put(SESSION_CURRENCY, $currencyId); Session::put(SESSION_CURRENCY, $currencyId);
@ -1969,7 +1963,7 @@ Account::updated(function ($account) {
return; return;
} }
Event::dispatch(new UserSettingsChanged()); Event::fire(new UserSettingsChanged());
}); });
Account::deleted(function ($account) Account::deleted(function ($account)

View file

@ -43,7 +43,7 @@ class Document extends EntityModel
'application/msword', 'application/msword',
'application/excel', 'application/vnd.ms-excel', 'application/x-excel', 'application/x-msexcel', 'application/excel', 'application/vnd.ms-excel', 'application/x-excel', 'application/x-msexcel',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/postscript', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/postscript', 'image/svg+xml',
'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.ms-powerpoint',
]; ];
@ -57,6 +57,9 @@ class Document extends EntityModel
'ai' => [ 'ai' => [
'mime' => 'application/postscript', 'mime' => 'application/postscript',
], ],
'svg' => [
'mime' => 'image/svg+xml',
],
'jpeg' => [ 'jpeg' => [
'mime' => 'image/jpeg', 'mime' => 'image/jpeg',
], ],

View file

@ -99,7 +99,7 @@ class LookupModel extends Eloquent
abort(404, "Looked up {$className} not found: {$field} => {$value}"); abort(404, "Looked up {$className} not found: {$field} => {$value}");
} }
Cache::put($key, $server, 120 * 60); Cache::put($key, $server, 120);
} else { } else {
config(['database.default' => $current]); config(['database.default' => $current]);
} }

View file

@ -243,7 +243,7 @@ class Payment extends EntityModel
$this->payment_status_id = $this->refunded == $this->amount ? PAYMENT_STATUS_REFUNDED : PAYMENT_STATUS_PARTIALLY_REFUNDED; $this->payment_status_id = $this->refunded == $this->amount ? PAYMENT_STATUS_REFUNDED : PAYMENT_STATUS_PARTIALLY_REFUNDED;
$this->save(); $this->save();
Event::dispatch(new PaymentWasRefunded($this, $refund_change)); Event::fire(new PaymentWasRefunded($this, $refund_change));
} }
return true; return true;
@ -258,7 +258,7 @@ class Payment extends EntityModel
return false; return false;
} }
Event::dispatch(new PaymentWasVoided($this)); Event::fire(new PaymentWasVoided($this));
$this->refunded = $this->amount; $this->refunded = $this->amount;
$this->payment_status_id = PAYMENT_STATUS_VOIDED; $this->payment_status_id = PAYMENT_STATUS_VOIDED;
@ -271,7 +271,7 @@ class Payment extends EntityModel
{ {
$this->payment_status_id = PAYMENT_STATUS_COMPLETED; $this->payment_status_id = PAYMENT_STATUS_COMPLETED;
$this->save(); $this->save();
Event::dispatch(new PaymentCompleted($this)); Event::fire(new PaymentCompleted($this));
} }
/** /**
@ -282,7 +282,7 @@ class Payment extends EntityModel
$this->payment_status_id = PAYMENT_STATUS_FAILED; $this->payment_status_id = PAYMENT_STATUS_FAILED;
$this->gateway_error = $failureMessage; $this->gateway_error = $failureMessage;
$this->save(); $this->save();
Event::dispatch(new PaymentFailed($this)); Event::fire(new PaymentFailed($this));
} }
/** /**

View file

@ -220,11 +220,11 @@ class PaymentMethod extends EntityModel
} }
if (! empty($data)) { if (! empty($data)) {
Cache::put('bankData:'.$routingNumber, $data, 5 * 60); Cache::put('bankData:'.$routingNumber, $data, 5);
return $data; return $data;
} else { } else {
Cache::put('bankData:'.$routingNumber, false, 5 * 60); Cache::put('bankData:'.$routingNumber, false, 5);
return null; return null;
} }

View file

@ -33,11 +33,6 @@ trait HasRecurrence
} }
$account = $this->account; $account = $this->account;
if (! $account) {
return false;
}
$timezone = $account->getTimezone(); $timezone = $account->getTimezone();
if (! $this->start_date || Carbon::parse($this->start_date, $timezone)->isFuture()) { if (! $this->start_date || Carbon::parse($this->start_date, $timezone)->isFuture()) {

View file

@ -74,10 +74,7 @@ trait Inviteable
} }
} }
return $hasValue ? implode('<br/>', $parts) : false; return $hasValue ? implode($parts, '<br/>') : false;
// return $hasValue ? implode($parts, '<br/>') : false;
} }
/** /**

View file

@ -402,8 +402,8 @@ class ContactMailer extends Mailer
$day_hits_remaining = $day_hits_remaining >= 0 ? $day_hits_remaining : 0; $day_hits_remaining = $day_hits_remaining >= 0 ? $day_hits_remaining : 0;
} }
Cache::put("email_day_throttle:{$key}", $new_day_throttle, 60 * 60); Cache::put("email_day_throttle:{$key}", $new_day_throttle, 60);
Cache::put("last_email_request:{$key}", time(), 60 * 60); Cache::put("last_email_request:{$key}", time(), 60);
if ($new_day_throttle > $day) { if ($new_day_throttle > $day) {
$errorEmail = env('ERROR_EMAIL'); $errorEmail = env('ERROR_EMAIL');
@ -414,7 +414,7 @@ class ContactMailer extends Mailer
->subject("Email throttle triggered for account " . $account->id); ->subject("Email throttle triggered for account " . $account->id);
}); });
} }
Cache::put("throttle_notified:{$key}", true, 60 * 24 * 60); Cache::put("throttle_notified:{$key}", true, 60 * 24);
return true; return true;
} }

View file

@ -73,7 +73,7 @@ class UserMailer extends Mailer
User $user, User $user,
Invoice $invoice, Invoice $invoice,
$notificationType, $notificationType,
?Payment $payment, Payment $payment = null,
$notes = false $notes = false
) { ) {
if (! $user->shouldNotify($invoice)) { if (! $user->shouldNotify($invoice)) {

View file

@ -794,10 +794,9 @@ class BasePaymentDriver
$payment->contact_id = $invitation->contact_id; $payment->contact_id = $invitation->contact_id;
$payment->transaction_reference = $ref; $payment->transaction_reference = $ref;
$payment->payment_date = $account->getDateTime()->format('Y-m-d'); $payment->payment_date = $account->getDateTime()->format('Y-m-d');
$payment->ip = \Request::ip(); $payment->ip = Request::ip();
//Laravel 6 upgrade - uncommented this line as it was causing a failure $payment = $this->creatingPayment($payment, $paymentMethod);
// $payment = $this->creatingPayment($payment, $paymentMethod);
if ($paymentMethod) { if ($paymentMethod) {
$payment->last4 = $paymentMethod->last4; $payment->last4 = $paymentMethod->last4;

View file

@ -228,6 +228,7 @@ class StripePaymentDriver extends BasePaymentDriver
if ( ! empty($data['payment_intent'])) { if ( ! empty($data['payment_intent'])) {
// Find the existing payment intent. // Find the existing payment intent.
$intent = PaymentIntent::retrieve($data['payment_intent']); $intent = PaymentIntent::retrieve($data['payment_intent']);
if ( ! $intent->amount == $data['amount'] * pow(10, $currency['precision'])) { if ( ! $intent->amount == $data['amount'] * pow(10, $currency['precision'])) {
// Make sure that the provided payment intent matches the invoice amount. // Make sure that the provided payment intent matches the invoice amount.
throw new Exception('Incorrect PaymentIntent amount.'); throw new Exception('Incorrect PaymentIntent amount.');
@ -269,8 +270,8 @@ class StripePaymentDriver extends BasePaymentDriver
return $this->doOmnipayOnsitePurchase($data, $paymentMethod); return $this->doOmnipayOnsitePurchase($data, $paymentMethod);
} }
} }
$intent = PaymentIntent::create($params);
$intent = PaymentIntent::create($params);
} }
if (empty($intent)) { if (empty($intent)) {
@ -281,7 +282,6 @@ class StripePaymentDriver extends BasePaymentDriver
throw new PaymentActionRequiredException(['payment_intent' => $intent]); throw new PaymentActionRequiredException(['payment_intent' => $intent]);
} else if ($intent->status == 'succeeded') { } else if ($intent->status == 'succeeded') {
$ref = ! empty($intent->charges->data) ? $intent->charges->data[0]->id : null; $ref = ! empty($intent->charges->data) ? $intent->charges->data[0]->id : null;
$payment = $this->createPayment($ref, $paymentMethod); $payment = $this->createPayment($ref, $paymentMethod);
if ($this->invitation->invoice->account->isNinjaAccount()) { if ($this->invitation->invoice->account->isNinjaAccount()) {
@ -296,6 +296,7 @@ class StripePaymentDriver extends BasePaymentDriver
$this->tokenResponse = $payment_method; $this->tokenResponse = $payment_method;
parent::createToken(); parent::createToken();
} }
return $payment; return $payment;
} else { } else {
throw new Exception('Invalid PaymentIntent status: ' . $intent->status); throw new Exception('Invalid PaymentIntent status: ' . $intent->status);

View file

@ -47,10 +47,6 @@ class InvoiceReport extends AbstractReport
public function run() public function run()
{ {
if (!Auth::user()) {
return;
}
$account = Auth::user()->account; $account = Auth::user()->account;
$statusIds = $this->options['status_ids']; $statusIds = $this->options['status_ids'];
$exportFormat = $this->options['export_format']; $exportFormat = $this->options['export_format'];

View file

@ -18,6 +18,7 @@ use App\Models\User;
use App\Models\UserAccount; use App\Models\UserAccount;
use App\Models\LookupUser; use App\Models\LookupUser;
use Auth; use Auth;
use Input;
use Request; use Request;
use Schema; use Schema;
use Session; use Session;
@ -36,19 +37,19 @@ class AccountRepository
} }
$company = new Company(); $company = new Company();
$company->utm_source = \Request::input('utm_source'); $company->utm_source = Input::get('utm_source');
$company->utm_medium = \Request::input('utm_medium'); $company->utm_medium = Input::get('utm_medium');
$company->utm_campaign = \Request::input('utm_campaign'); $company->utm_campaign = Input::get('utm_campaign');
$company->utm_term = \Request::input('utm_term'); $company->utm_term = Input::get('utm_term');
$company->utm_content = \Request::input('utm_content'); $company->utm_content = Input::get('utm_content');
$company->referral_code = Session::get(SESSION_REFERRAL_CODE); $company->referral_code = Session::get(SESSION_REFERRAL_CODE);
if (\Request::input('utm_campaign')) { if (Input::get('utm_campaign')) {
if (env('PROMO_CAMPAIGN') && hash_equals(\Request::input('utm_campaign'), env('PROMO_CAMPAIGN'))) { if (env('PROMO_CAMPAIGN') && hash_equals(Input::get('utm_campaign'), env('PROMO_CAMPAIGN'))) {
$company->applyDiscount(.75); $company->applyDiscount(.75);
} elseif (env('PARTNER_CAMPAIGN') && hash_equals(\Request::input('utm_campaign'), env('PARTNER_CAMPAIGN'))) { } elseif (env('PARTNER_CAMPAIGN') && hash_equals(Input::get('utm_campaign'), env('PARTNER_CAMPAIGN'))) {
$company->applyFreeYear(); $company->applyFreeYear();
} elseif (env('EDUCATION_CAMPAIGN') && hash_equals(\Request::input('utm_campaign'), env('EDUCATION_CAMPAIGN'))) { } elseif (env('EDUCATION_CAMPAIGN') && hash_equals(Input::get('utm_campaign'), env('EDUCATION_CAMPAIGN'))) {
$company->applyFreeYear(2); $company->applyFreeYear(2);
} }
} else { } else {

View file

@ -33,7 +33,7 @@ class PaymentCreated extends Notification implements ShouldQueue
*/ */
public function via($notifiable) public function via($notifiable)
{ {
return []; return ['slack'];
} }
/** /**

View file

@ -3,7 +3,6 @@
namespace App\Providers; namespace App\Providers;
use Form; use Form;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Request; use Request;
use URL; use URL;
@ -27,7 +26,6 @@ class AppServiceProvider extends ServiceProvider
public function boot() public function boot()
{ {
Route::singularResourceParameters(false); Route::singularResourceParameters(false);
Paginator::useBootstrapThree();
// support selecting job database // support selecting job database
Queue::before(function (JobProcessing $event) { Queue::before(function (JobProcessing $event) {

View file

@ -6,6 +6,7 @@ use App\Events\UserLoggedIn;
use App\Ninja\Repositories\AccountRepository; use App\Ninja\Repositories\AccountRepository;
use App\Models\LookupUser; use App\Models\LookupUser;
use Auth; use Auth;
use Input;
use Session; use Session;
use Socialite; use Socialite;
use Utils; use Utils;
@ -97,7 +98,7 @@ class AuthService
} }
} }
$redirectTo = \Request::input('redirect_to') ? SITE_URL . '/' . ltrim(\Request::input('redirect_to'), '/') : 'dashboard'; $redirectTo = Input::get('redirect_to') ? SITE_URL . '/' . ltrim(Input::get('redirect_to'), '/') : 'dashboard';
return redirect()->to($redirectTo); return redirect()->to($redirectTo);
} }

View file

@ -13,9 +13,8 @@
namespace App\Services\Migration; namespace App\Services\Migration;
use GuzzleHttp\RequestOptions; use Unirest\Request;
// use Unirest\Request; use Unirest\Request\Body;
// use Unirest\Request\Body;
class AuthService class AuthService
{ {
@ -52,57 +51,25 @@ class AuthService
'password' => $this->password, 'password' => $this->password,
]; ];
$client = new \GuzzleHttp\Client([ $body = Body::json($data);
'headers' => $this->getHeaders(),
]);
$response = $client->post($this->getUrl(),[ $response = Request::post($this->getUrl(), $this->getHeaders(), $body);
RequestOptions::JSON => $data,
RequestOptions::ALLOW_REDIRECTS => false
]);
if (in_array($response->code, [401])) {
info($response->raw_body);
if($response->getStatusCode() == 401){
info($response->getBody());
$this->isSuccessful = false; $this->isSuccessful = false;
$this->processErrors($response->getBody()); $this->processErrors($response->body->message);
} elseif ($response->getStatusCode() == 200) { } elseif (in_array($response->code, [200])) {
$message_body = json_decode($response->getBody(), true);
//info(print_r($message_body,1));
$this->isSuccessful = true; $this->isSuccessful = true;
$this->token = $message_body['data'][0]['token']['token']; $this->token = $response->body->data[0]->token->token;
} else { } else {
info(json_decode($response->getBody()->getContents())); info($response->raw_body);
$this->isSuccessful = false; $this->isSuccessful = false;
$this->errors = [trans('texts.migration_went_wrong')]; $this->errors = [trans('texts.migration_went_wrong')];
} }
//return $response->getBody();
// $body = Body::json($data);
// $response = Request::post($this->getUrl(), $this->getHeaders(), $body);
// if (in_array($response->code, [401])) {
// info($response->raw_body);
// $this->isSuccessful = false;
// $this->processErrors($response->body->message);
// } elseif (in_array($response->code, [200])) {
// $this->isSuccessful = true;
// $this->token = $response->body->data[0]->token->token;
// } else {
// info($response->raw_body);
// $this->isSuccessful = false;
// $this->errors = [trans('texts.migration_went_wrong')];
// }
return $this; return $this;
} }

View file

@ -3,6 +3,8 @@
namespace App\Services\Migration; namespace App\Services\Migration;
use App\Models\Account; use App\Models\Account;
use Unirest\Request;
use Unirest\Request\Body;
class CompanyService class CompanyService
{ {

View file

@ -2,9 +2,8 @@
namespace App\Services\Migration; namespace App\Services\Migration;
use GuzzleHttp\RequestOptions;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
// use Unirest\Request; use Unirest\Request;
class CompleteService class CompleteService
{ {
@ -41,53 +40,27 @@ class CompleteService
public function start() public function start()
{ {
$files = []; $files = [];
foreach ($this->data as $companyKey => $companyData) { foreach ($this->data as $companyKey => $companyData) {
$data = [ $data[] = [
'company_index' => $companyKey, 'company_index' => $companyKey,
'company_key' => $companyData['data']['company']['company_key'], 'company_key' => $companyData['data']['company']['company_key'],
'force' => $companyData['force'], 'force' => $companyData['force'],
'contents' => 'name',
'name' => $companyKey,
]; ];
$payload[$companyKey] = [ $files[$companyKey] = $companyData['file'];
'contents' => json_encode($data),
'name' => $companyData['data']['company']['company_key'],
];
$files[] = [
'name' => $companyKey,
'company_index' => $companyKey,
'company_key' => $companyData['data']['company']['company_key'],
'force' => $companyData['force'],
'contents' => file_get_contents($companyData['file']),
'filename' => basename($companyData['file']),
'Content-Type' => 'application/zip'
];
} }
$client = new \GuzzleHttp\Client( $body = \Unirest\Request\Body::multipart(['companies' => json_encode($data)], $files);
[
'headers' => $this->getHeaders(),
]);
$payload_data = [ $response = Request::post($this->getUrl(), $this->getHeaders(), $body);
'multipart'=> array_merge($files, $payload),
];
// info(print_r($payload_data,1));
$response = $client->request("POST", $this->getUrl(),$payload_data);
if($response->getStatusCode() == 200){
if (in_array($response->code, [200])) {
$this->isSuccessful = true; $this->isSuccessful = true;
return json_decode($response->getBody(),true); } else {
}else { info($response->raw_body);
// info($response->raw_body);
$this->isSuccessful = false; $this->isSuccessful = false;
$this->errors = [ $this->errors = [
@ -96,7 +69,6 @@ class CompleteService
} }
return $this; return $this;
} }
public function isSuccessful() public function isSuccessful()

View file

@ -2,7 +2,6 @@
namespace App\Traits; namespace App\Traits;
use App\Libraries\Utils;
use App\Models\AccountGateway; use App\Models\AccountGateway;
use App\Models\AccountGatewaySettings; use App\Models\AccountGatewaySettings;
use App\Models\AccountGatewayToken; use App\Models\AccountGatewayToken;
@ -20,7 +19,6 @@ use App\Models\PaymentMethod;
use App\Models\PaymentTerm; use App\Models\PaymentTerm;
use App\Models\Product; use App\Models\Product;
use App\Models\Project; use App\Models\Project;
use App\Models\RecurringExpense;
use App\Models\Task; use App\Models\Task;
use App\Models\TaskStatus; use App\Models\TaskStatus;
use App\Models\TaxRate; use App\Models\TaxRate;
@ -73,21 +71,11 @@ trait GenerateMigrationResources
protected function getCompany() protected function getCompany()
{ {
info("get company"); info("get company");
$financial_year_start = null;
if($this->account->financial_year_start)
{
//2000-02-01 format
$exploded_date = explode("-", $this->account->financial_year_start);
$financial_year_start = (int)$exploded_date[1];
}
return [ return [
'first_day_of_week' => $this->account->start_of_week, 'first_day_of_week' => $this->account->start_of_week,
'first_month_of_year' => $financial_year_start, 'first_month_of_year' => $this->account->financial_year_start,
'version' => NINJA_VERSION, 'version' => NINJA_VERSION,
'referral_code' => $this->account->referral_code ?: '', 'referral_code' => $this->account->referral_code ?: '',
'account_id' => $this->account->id, 'account_id' => $this->account->id,
@ -102,7 +90,6 @@ trait GenerateMigrationResources
'custom_surcharge_taxes1' => $this->account->custom_invoice_taxes1, 'custom_surcharge_taxes1' => $this->account->custom_invoice_taxes1,
'custom_surcharge_taxes2' => $this->account->custom_invoice_taxes2, 'custom_surcharge_taxes2' => $this->account->custom_invoice_taxes2,
'subdomain' => $this->account->subdomain, 'subdomain' => $this->account->subdomain,
'portal_mode' => 'subdomain',
'size_id' => $this->account->size_id, 'size_id' => $this->account->size_id,
'enable_modules' => $this->account->enabled_modules, 'enable_modules' => $this->account->enabled_modules,
'custom_fields' => $this->account->custom_fields, 'custom_fields' => $this->account->custom_fields,
@ -143,17 +130,10 @@ trait GenerateMigrationResources
{ {
info("get co settings"); info("get co settings");
$timezone_id = $this->account->timezone_id ? $this->account->timezone_id : 15;
if($timezone_id > 57)
$timezone_id = (string)($timezone_id - 1);
return [ return [
'entity_send_time' => 6,
'auto_bill_date' => $this->account->auto_bill_on_due_date ? 'on_due_date' : 'on_send_date',
'auto_bill' => $this->transformAutoBill($this->account->token_billing_id), 'auto_bill' => $this->transformAutoBill($this->account->token_billing_id),
'payment_terms' => $this->account->payment_terms ? (string) $this->account->payment_terms : '', 'payment_terms' => $this->account->payment_terms ? (string) $this->account->payment_terms : '',
'timezone_id' => $timezone_id, 'timezone_id' => $this->account->timezone_id ? (string) $this->account->timezone_id : '15',
'date_format_id' => $this->account->date_format_id ? (string) $this->account->date_format_id : '1', 'date_format_id' => $this->account->date_format_id ? (string) $this->account->date_format_id : '1',
'currency_id' => $this->account->currency_id ? (string) $this->account->currency_id : '1', 'currency_id' => $this->account->currency_id ? (string) $this->account->currency_id : '1',
'name' => $this->account->name ?: trans('texts.untitled'), 'name' => $this->account->name ?: trans('texts.untitled'),
@ -191,7 +171,7 @@ trait GenerateMigrationResources
'all_pages_footer' => $this->account->all_pages_footer ? (bool) $this->account->all_pages_footer : true, 'all_pages_footer' => $this->account->all_pages_footer ? (bool) $this->account->all_pages_footer : true,
'all_pages_header' => $this->account->all_pages_header ? (bool) $this->account->all_pages_header : true, 'all_pages_header' => $this->account->all_pages_header ? (bool) $this->account->all_pages_header : true,
'show_currency_code' => $this->account->show_currency_code ? (bool) $this->account->show_currency_code : false, 'show_currency_code' => $this->account->show_currency_code ? (bool) $this->account->show_currency_code : false,
'enable_client_portal_password' => $this->account->enable_portal_password ? (bool) $this->account->enable_portal_password : false, 'enable_client_portal_password' => $this->account->enable_portal_password ? (bool) $this->account->enable_portal_password : true,
'send_portal_password' => $this->account->send_portal_password ? (bool) $this->account->send_portal_password : false, 'send_portal_password' => $this->account->send_portal_password ? (bool) $this->account->send_portal_password : false,
'recurring_number_prefix' => $this->account->recurring_invoice_number_prefix ? $this->account->recurring_invoice_number_prefix : 'R', 'recurring_number_prefix' => $this->account->recurring_invoice_number_prefix ? $this->account->recurring_invoice_number_prefix : 'R',
'enable_client_portal' => $this->account->enable_client_portal ? (bool) $this->account->enable_client_portal : false, 'enable_client_portal' => $this->account->enable_client_portal ? (bool) $this->account->enable_client_portal : false,
@ -209,9 +189,10 @@ trait GenerateMigrationResources
'client_number_pattern' => $this->account->client_number_pattern ?: '', 'client_number_pattern' => $this->account->client_number_pattern ?: '',
'payment_number_pattern' => '', 'payment_number_pattern' => '',
'payment_number_counter' => 0, 'payment_number_counter' => 0,
'payment_terms' => $this->account->payment_terms ?: '',
'reset_counter_frequency_id' => $this->account->reset_counter_frequency_id ? (string) $this->transformFrequencyId 'reset_counter_frequency_id' => $this->account->reset_counter_frequency_id ? (string) $this->transformFrequencyId
($this->account->reset_counter_frequency_id) : '0', ($this->account->reset_counter_frequency_id) : '0',
'payment_type_id' => $this->account->payment_type_id ? (string) $this->transformPaymentType($this->account->payment_type_id) : '1', 'payment_type_id' => $this->account->payment_type_id ? (string) $this->account->payment_type_id : '1',
'reset_counter_date' => $this->account->reset_counter_date ?: '', 'reset_counter_date' => $this->account->reset_counter_date ?: '',
'tax_name1' => $this->account->tax_name1 ?: '', 'tax_name1' => $this->account->tax_name1 ?: '',
'tax_rate1' => $this->account->tax_rate1 ?: 0, 'tax_rate1' => $this->account->tax_rate1 ?: 0,
@ -230,88 +211,18 @@ trait GenerateMigrationResources
'auto_archive_quote' => $this->account->auto_archive_quote ? (bool) $this->account->auto_archive_quote : false, 'auto_archive_quote' => $this->account->auto_archive_quote ? (bool) $this->account->auto_archive_quote : false,
'auto_email_invoice' => $this->account->auto_email_invoice ? (bool) $this->account->auto_email_invoice : false, 'auto_email_invoice' => $this->account->auto_email_invoice ? (bool) $this->account->auto_email_invoice : false,
'counter_padding' => $this->account->invoice_number_padding ?: 4, 'counter_padding' => $this->account->invoice_number_padding ?: 4,
'reply_to_email' => $this->account->account_email_settings->reply_to_email ?: '',
'bcc_email' => $this->account->account_email_settings->bcc_email ?: '',
'email_subject_invoice' => $this->account->account_email_settings->email_subject_invoice ?: '',
'email_subject_quote' => $this->account->account_email_settings->email_subject_quote ?: '',
'email_subject_payment' => $this->account->account_email_settings->email_subject_payment ?: '',
'email_template_invoice' => $this->account->account_email_settings->email_template_invoice ?: '',
'email_template_quote' => $this->account->account_email_settings->email_template_quote ?: '',
'email_template_payment' => $this->account->account_email_settings->email_template_payment ?: '',
'email_subject_reminder1' => $this->account->account_email_settings->email_subject_reminder1 ?: '',
'email_subject_reminder2' => $this->account->account_email_settings->email_subject_reminder2 ?: '',
'email_subject_reminder3' => $this->account->account_email_settings->email_subject_reminder3 ?: '',
'email_subject_reminder_endless' => $this->account->account_email_settings->email_subject_reminder4 ?: '',
'email_template_reminder1' => $this->account->account_email_settings->email_template_reminder1 ?: '',
'email_template_reminder2' => $this->account->account_email_settings->email_template_reminder2 ?: '',
'email_template_reminder3' => $this->account->account_email_settings->email_template_reminder3 ?: '',
'email_template_reminder_endless' => $this->account->account_email_settings->email_template_reminder4 ?: '',
'late_fee_amount1' => $this->account->account_email_settings->late_fee1_amount ?: 0,
'late_fee_amount2' => $this->account->account_email_settings->late_fee2_amount ?: 0,
'late_fee_amount3' => $this->account->account_email_settings->late_fee3_amount ?: 0,
'late_fee_percent1' => $this->account->account_email_settings->late_fee1_percent ?: 0,
'late_fee_percent2' => $this->account->account_email_settings->late_fee2_percent ?: 0,
'late_fee_percent3' => $this->account->account_email_settings->late_fee3_percent ?: 0,
'enable_reminder1' => $this->account->enable_reminder1 ? true : false,
'enable_reminder2' => $this->account->enable_reminder2 ? true : false,
'enable_reminder3' => $this->account->enable_reminder3 ? true : false,
'enable_reminder_endless' => $this->account->enable_reminder4 ? true : false,
'num_days_reminder1' => $this->account->num_days_reminder1 ?: 0,
'num_days_reminder2' => $this->account->num_days_reminder2 ?: 0,
'num_days_reminder3' => $this->account->num_days_reminder3 ?: 0,
'schedule_reminder1' => $this->buildReminderString($this->account->direction_reminder1, $this->account->field_reminder1),
'schedule_reminder2' => $this->buildReminderString($this->account->direction_reminder2, $this->account->field_reminder2),
'schedule_reminder3' => $this->buildReminderString($this->account->direction_reminder3, $this->account->field_reminder3),
'endless_reminder_frequency_id' => $this->account->account_email_settings->reset_counter_frequency_id ? $this->transformFrequencyId($this->account->account_email_settings->reset_counter_frequency_id) : 0,
'email_signature' => $this->account->email_footer ?: '',
'email_style' => $this->getEmailStyle($this->account->email_design_id),
'custom_message_dashboard' => $this->account->customMessage('dashboard'),
'custom_message_unpaid_invoice' => $this->account->customMessage('unpaid_invoice'),
'custom_message_paid_invoice' => $this->account->customMessage('paid_invoice'),
'custom_message_unapproved_quote' => $this->account->customMessage('unapproved_quote'),
]; ];
} }
private function getEmailStyle($id){
switch ($id) {
case 1:
return 'plain';
break;
case 2:
return 'light';
break;
case 3:
return 'dark';
break;
default:
return 'light';
break;
}
}
private function buildReminderString($direction, $field)
{
$direction_string = $direction == 1 ? "after_" : "before_";
$field_string = $field == 1 ? "due_date" : "invoice_date";
return $direction_string.$field_string;
}
public function getTaxRates() public function getTaxRates()
{ {
info("get tax rates");
$rates = TaxRate::where('account_id', $this->account->id) $rates = TaxRate::where('account_id', $this->account->id)
->withTrashed() ->withTrashed()
->get(); ->get();
info("get tax rates => " . $rates->count());
$transformed = []; $transformed = [];
foreach ($rates as $rate) { foreach ($rates as $rate) {
@ -330,12 +241,10 @@ trait GenerateMigrationResources
} }
protected function getClients() protected function getClients()
{ {info("get clients");
$clients = []; $clients = [];
info("get clients => ". $this->account->clients()->count());
foreach ($this->account->clients()->withTrashed()->get() as $client) { foreach ($this->account->clients()->withTrashed()->get() as $client) {
$number = $client->id_number; $number = $client->id_number;
@ -384,6 +293,8 @@ trait GenerateMigrationResources
private function getClientSettings($client) private function getClientSettings($client)
{ {
info("get client settings");
$settings = new \stdClass(); $settings = new \stdClass();
$settings->currency_id = $client->currency_id ? (string) $client->currency_id : (string) $client->account->currency_id; $settings->currency_id = $client->currency_id ? (string) $client->currency_id : (string) $client->account->currency_id;
@ -400,13 +311,12 @@ trait GenerateMigrationResources
protected function getClientContacts($client) protected function getClientContacts($client)
{ {
info("get client contacts");
$contacts = Contact::where('client_id', $client->id)->withTrashed()->get(); $contacts = Contact::where('client_id', $client->id)->withTrashed()->get();
$transformed = []; $transformed = [];
info("Importing contacts => " . $contacts->count());
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
$transformed[] = [ $transformed[] = [
'id' => $contact->id, 'id' => $contact->id,
@ -440,39 +350,18 @@ trait GenerateMigrationResources
{ {
$transformed = []; $transformed = [];
if(!Utils::isNinja()) $ninja_client = Client::where('public_id', $this->account->id)->first();
return $transformed;
$db = DB_NINJA_1;
$account_id = 20432;
if($this->account->id > 1000000){
$db = DB_NINJA_2;
$account_id = 1000002;
}
$ninja_client = Client::on($db)->where('public_id', $this->account->id)->where('account_id', $account_id)->first();
if(!$ninja_client) if(!$ninja_client)
return $transformed; return $transformed;
$agts = AccountGatewayToken::on($db)->where('client_id', $ninja_client->id)->get(); $agts = AccountGatewayToken::where('client_id', $ninja_client->id)->get();
$is_default = true; $is_default = true;
if(count($agts) == 0) {
$transformed[] = [
'client' => $ninja_client->toArray()
];
}
foreach($agts as $agt) { foreach($agts as $agt) {
$payment_method = $agt->default_payment_method; $payment_method = $agt->default_payment_method;
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
if(!$payment_method)
continue;
$contact = Contact::on($db)->where('id', $payment_method->contact_id)->withTrashed()->first();
$transformed[] = [ $transformed[] = [
'id' => $payment_method->id, 'id' => $payment_method->id,
@ -484,7 +373,7 @@ trait GenerateMigrationResources
'gateway_type_id' => $payment_method->payment_type->gateway_type_id, 'gateway_type_id' => $payment_method->payment_type->gateway_type_id,
'is_default' => $is_default, 'is_default' => $is_default,
'meta' => $this->convertMeta($payment_method), 'meta' => $this->convertMeta($payment_method),
'client' => $ninja_client->toArray(), 'client' => $contact->client->toArray(),
'contacts' => $contact->client->contacts->toArray(), 'contacts' => $contact->client->contacts->toArray(),
]; ];
} }
@ -495,13 +384,12 @@ trait GenerateMigrationResources
protected function getProducts() protected function getProducts()
{ {
info("get products");
$products = Product::where('account_id', $this->account->id) $products = Product::where('account_id', $this->account->id)
->withTrashed() ->withTrashed()
->get(); ->get();
info("get products " . $products->count());
$transformed = []; $transformed = [];
foreach ($products as $product) { foreach ($products as $product) {
@ -530,13 +418,12 @@ trait GenerateMigrationResources
public function getUsers() public function getUsers()
{ {
info("get users");
$users = User::where('account_id', $this->account->id) $users = User::where('account_id', $this->account->id)
->withTrashed() ->withTrashed()
->get(); ->get();
info("get users " . $users->count());
$transformed = []; $transformed = [];
foreach ($users as $user) { foreach ($users as $user) {
@ -545,12 +432,12 @@ trait GenerateMigrationResources
'first_name' => $user->first_name ?: '', 'first_name' => $user->first_name ?: '',
'last_name' => $user->last_name ?: '', 'last_name' => $user->last_name ?: '',
'phone' => $user->phone ?: '', 'phone' => $user->phone ?: '',
'email' => str_contains($user->username, "@") ? $user->username : $user->email, 'email' => $user->username,
'confirmation_code' => $user->confirmation_code, 'confirmation_code' => $user->confirmation_code,
'failed_logins' => $user->failed_logins, 'failed_logins' => $user->failed_logins,
'referral_code' => $user->referral_code, 'referral_code' => $user->referral_code,
// 'oauth_user_id' => $user->oauth_user_id, 'oauth_user_id' => $user->oauth_user_id,
// 'oauth_provider_id' => $user->oauth_provider_id, 'oauth_provider_id' => $user->oauth_provider_id,
'google_2fa_secret' => '', 'google_2fa_secret' => '',
'accepted_terms_version' => $user->accepted_terms_version, 'accepted_terms_version' => $user->accepted_terms_version,
'password' => $user->password, 'password' => $user->password,
@ -567,51 +454,52 @@ trait GenerateMigrationResources
private function getCreditsNotes() private function getCreditsNotes()
{ {
info("get credit notes");
$credits = []; $credits = [];
$export_credits = collect([]);
$export_credits = Credit::where('account_id', $this->account->id)->where('amount', '>', 0)->whereIsDeleted(false) $export_credits = Invoice::where('account_id', $this->account->id)
->where('balance', '<', '0')
->where('invoice_type_id', '=', INVOICE_TYPE_STANDARD)
->where('is_public', true)
->withTrashed() ->withTrashed()
->get(); ->get();
info("get credit notes => " . $export_credits->count());
foreach ($export_credits as $credit) { foreach ($export_credits as $credit) {
$credits[] = [ $credits[] = [
'id' => $credit->id, 'id' => $credit->id,
'client_id' => $credit->client_id, 'client_id' => $credit->client_id,
'user_id' => $credit->user_id, 'user_id' => $credit->user_id,
'company_id' => $credit->account_id, 'company_id' => $credit->account_id,
'status_id' => 2, 'status_id' => $credit->invoice_status_id,
'design_id' => 2, 'design_id' => $this->getDesignId($credit->invoice_design_id),
'number' => $credit->credit_number ?: null, 'number' => $credit->invoice_number,
'discount' => 0, 'discount' => $credit->discount ? $credit->discount*-1: 0,
'is_amount_discount' => 0, 'is_amount_discount' => $credit->is_amount_discount ?: false,
'po_number' => '', 'po_number' => $credit->po_number ?: '',
'date' => $credit->date, 'date' => $credit->invoice_date,
'last_sent_date' => null, 'last_sent_date' => $credit->last_sent_date,
'due_date' => null, 'due_date' => $credit->due_date,
'uses_inclusive_taxes' => $this->account->inclusive_taxes, 'uses_inclusive_taxes' => $this->account->inclusive_taxes,
'is_deleted' => $credit->is_deleted, 'is_deleted' => $credit->is_deleted,
'footer' => '', 'footer' => $credit->invoice_footer ?: '',
'public_notes' => $credit->public_notes, 'public_notes' => $credit->public_notes ?: '',
'private_notes' => $credit->private_notes, 'private_notes' => $credit->private_notes ?: '',
'terms' => '', 'terms' => $credit->terms ?: '',
'tax_name1' => '', 'tax_name1' => $credit->tax_name1,
'tax_name2' => '', 'tax_name2' => $credit->tax_name2,
'tax_rate1' => 0, 'tax_rate1' => $credit->tax_rate1,
'tax_rate2' => 0, 'tax_rate2' => $credit->tax_rate2,
'tax_name3' => '', 'tax_name3' => '',
'tax_rate3' => 0, 'tax_rate3' => 0,
'custom_value1' => '', 'custom_value1' => $credit->custom_value1 ?: '',
'custom_value2' => '', 'custom_value2' => $credit->custom_value2 ?: '',
'next_send_date' => null, 'next_send_date' => null,
'amount' => $credit->amount ? $credit->amount * -1: 0, 'amount' => $credit->amount ? $credit->amount * -1: 0,
'balance' => $credit->balance ? $credit->balance * -1: 0, 'balance' => $credit->balance ? $credit->balance * -1 : 0,
'partial' => 0, 'partial' => $credit->partial ? $credit->partial * -1 : 0,
'partial_due_date' => null, 'partial_due_date' => $credit->partial_due_date,
'line_items' => $this->getCreditItems($credit->balance), 'line_items' => $this->getCreditItems($credit->invoice_items),
'created_at' => $credit->created_at ? Carbon::parse($credit->created_at)->toDateString() : null, 'created_at' => $credit->created_at ? Carbon::parse($credit->created_at)->toDateString() : null,
'updated_at' => $credit->updated_at ? Carbon::parse($credit->updated_at)->toDateString() : null, 'updated_at' => $credit->updated_at ? Carbon::parse($credit->updated_at)->toDateString() : null,
'deleted_at' => $credit->deleted_at ? Carbon::parse($credit->deleted_at)->toDateString() : null, 'deleted_at' => $credit->deleted_at ? Carbon::parse($credit->deleted_at)->toDateString() : null,
@ -623,19 +511,17 @@ trait GenerateMigrationResources
protected function getInvoices() protected function getInvoices()
{ { info("get invoices");
$invoices = []; $invoices = [];
$export_invoices = Invoice::where('account_id', $this->account->id) $export_invoices = Invoice::where('account_id', $this->account->id)
// ->where('amount', '>=', 0) ->where('amount', '>=', 0)
->where('invoice_type_id', INVOICE_TYPE_STANDARD) ->where('invoice_type_id', INVOICE_TYPE_STANDARD)
->where('is_recurring', false) ->where('is_recurring', false)
->withTrashed() ->withTrashed()
->get(); ->get();
info("get invoices -> ". $export_invoices->count());
foreach ($export_invoices as $invoice) { foreach ($export_invoices as $invoice) {
$invoices[] = [ $invoices[] = [
'id' => $invoice->id, 'id' => $invoice->id,
@ -680,7 +566,6 @@ trait GenerateMigrationResources
'deleted_at' => $invoice->deleted_at ? Carbon::parse($invoice->deleted_at)->toDateString() : null, 'deleted_at' => $invoice->deleted_at ? Carbon::parse($invoice->deleted_at)->toDateString() : null,
'invitations' => $this->getResourceInvitations($invoice->invitations, 'invoice_id'), 'invitations' => $this->getResourceInvitations($invoice->invitations, 'invoice_id'),
'auto_bill_enabled' => $invoice->auto_bill, 'auto_bill_enabled' => $invoice->auto_bill,
'recurring_id' => $invoice->recurring_invoice_id,
]; ];
} }
@ -706,59 +591,10 @@ trait GenerateMigrationResources
return $design_id; return $design_id;
} }
protected function getRecurringExpenses()
{
$expenses = [];
$export_expenses = RecurringExpense::where('account_id', $this->account->id)
->withTrashed()
->get();
info("get recurring Expenses => " . $export_expenses->count());
foreach ($export_expenses as $expense) {
$expenses[] = [
'id' => $expense->id,
'amount' => $expense->amount,
'company_id' => $this->account->id,
'client_id' => $expense->client_id,
'user_id' => $expense->user_id,
'custom_value1' => '',
'custom_value2' => '',
'custom_value3' => '',
'custom_value4' => '',
'category_id' => $expense->expense_category_id,
'currency_id' => $expense->expense_currency_id,
'frequency_id' => $this->transformFrequencyId($expense->frequency_id),
'invoice_currency_id' => $expense->invoice_currency_id,
'private_notes' => $expense->private_notes,
'public_notes' => $expense->public_notes,
'should_be_invoiced' => $expense->should_be_invoiced,
'tax_name1' => $expense->tax_name1,
'tax_name2' => $expense->tax_name2,
'tax_name3' => '',
'tax_rate1' => $expense->tax_rate1,
'tax_rate2' => $expense->tax_rate2,
'tax_rate3' => 0,
'vendor_id' => $expense->vendor_id,
'is_deleted' => $expense->is_deleted,
'next_send_date' => $this->getNextSendDateForMigration($expense),
'remaining_cycles' => $this->getRemainingCycles($expense),
'created_at' => $expense->created_at ? Carbon::parse($expense->created_at)->toDateString() : null,
'updated_at' => $expense->updated_at ? Carbon::parse($expense->updated_at)->toDateString() : null,
'deleted_at' => $expense->deleted_at ? Carbon::parse($expense->deleted_at)->toDateString() : null,
];
}
return $expenses;
}
protected function getRecurringInvoices() protected function getRecurringInvoices()
{ {
info("get recurring invoices");
$invoices = []; $invoices = [];
@ -768,8 +604,6 @@ trait GenerateMigrationResources
->withTrashed() ->withTrashed()
->get(); ->get();
info("get recurring invoices => " . $export_invoices->count());
foreach ($export_invoices as $invoice) { foreach ($export_invoices as $invoice) {
$invoices[] = [ $invoices[] = [
'id' => $invoice->id, 'id' => $invoice->id,
@ -814,8 +648,7 @@ trait GenerateMigrationResources
'due_date_days' => $this->transformDueDate($invoice), 'due_date_days' => $this->transformDueDate($invoice),
'remaining_cycles' => $this->getRemainingCycles($invoice), 'remaining_cycles' => $this->getRemainingCycles($invoice),
'invitations' => $this->getResourceInvitations($invoice->invitations, 'recurring_invoice_id'), 'invitations' => $this->getResourceInvitations($invoice->invitations, 'recurring_invoice_id'),
'auto_bill_enabled' => $this->calcAutoBill($invoice), 'auto_bill_enabled' => $invoice->auto_bill,
'auto_bill' => $this->calcAutoBillEnabled($invoice),
]; ];
} }
@ -823,29 +656,6 @@ trait GenerateMigrationResources
} }
private function calcAutoBillEnabled($invoice)
{
if($invoice->auto_bill === 1)
return 'off';
elseif($invoice->auto_bill === 2)
return 'optin';
elseif($invoice->auto_bill === 3)
return 'optout';
elseif($invoice->auto_bill === 4)
return 'always';
else
return 'off';
}
private function calcAutoBill($invoice)
{
if($invoice->auto_bill == 4)
return 1;
return $invoice->client_enable_auto_bill;
}
private function getNextSendDateForMigration($invoice) private function getNextSendDateForMigration($invoice)
{ {
@ -926,13 +736,8 @@ trait GenerateMigrationResources
$due_date_parts = explode("-", $invoice->due_date); $due_date_parts = explode("-", $invoice->due_date);
if(is_array($due_date_parts) && count($due_date_parts) >=3){ if(is_array($due_date_parts) && count($due_date_parts) >=3)
if($due_date_parts[2] == "00")
return "0";
return (string)$due_date_parts[2]; return (string)$due_date_parts[2];
}
return 'terms'; return 'terms';
} }
@ -1029,7 +834,7 @@ trait GenerateMigrationResources
if($invoice->is_public == 0) if($invoice->is_public == 0)
return 1; return 1;
if($invoice->end_date && $invoice->end_date < now()) if($invoice->end_date < now())
return 4; return 4;
return 1; return 1;
@ -1120,7 +925,7 @@ trait GenerateMigrationResources
public function getResourceInvitations($items, $resourceKeyId) public function getResourceInvitations($items, $resourceKeyId)
{ {
// info("get resource {$resourceKeyId} invitations"); info("get resource {$resourceKeyId} invitations");
$transformed = []; $transformed = [];
@ -1150,40 +955,50 @@ trait GenerateMigrationResources
return $transformed; return $transformed;
} }
public function getCreditItems($balance) public function getCreditItems($items)
{ {
info("get credit items"); info("get credit items");
$transformed = []; $transformed = [];
foreach ($items as $item) {
// if($item->cost < 0)
// $item->cost = $item->cost * -1;
$item->qty = $item->qty * -1;
// if($item->discount < 0)
// $item->discount = $item->discount * -1;
$transformed[] = [ $transformed[] = [
'id' => '', 'id' => $item->id,
'quantity' => (float) 1, 'quantity' => (float) $item->qty,
'cost' => (float) $balance, 'cost' => (float) $item->cost,
'product_key' => trans('texts.balance'), 'product_key' => $item->product_key,
'notes' => trans('texts.credit_balance'), 'notes' => $item->notes,
'discount' => 0, 'discount' => (float) $item->discount,
'tax_name1' => '', 'tax_name1' => (string)$item->tax_name1,
'tax_rate1' => 0, 'tax_rate1' => (float) $item->tax_rate1,
'tax_name2' => '', 'tax_name2' => (string) $item->tax_name2,
'tax_rate2' => 0, 'tax_rate2' => (float) $item->tax_rate2,
'tax_name3' => '', 'tax_name3' => (string) '',
'tax_rate3' => 0, 'tax_rate3' => (float) 0,
'date' => '', 'date' => Carbon::parse($item->created_at)->toDateString(),
'custom_value1' => '', 'custom_value1' => $item->custom_value1 ?: '',
'custom_value2' => '', 'custom_value2' => $item->custom_value2 ?: '',
'custom_value3' => '', 'custom_value3' => '',
'custom_value4' => '', 'custom_value4' => '',
'type_id' => '1', 'type_id' => (string)$item->invoice_item_type_id,
]; ];
}
return $transformed; return $transformed;
} }
public function getInvoiceItems($items) public function getInvoiceItems($items)
{ {
// info("get invoice items"); info("get invoice items");
$transformed = []; $transformed = [];
@ -1215,6 +1030,8 @@ trait GenerateMigrationResources
public function getQuotes() public function getQuotes()
{ {
info("get quotes");
$transformed = []; $transformed = [];
@ -1223,8 +1040,6 @@ trait GenerateMigrationResources
->withTrashed() ->withTrashed()
->get(); ->get();
info("get quotes => " . $quotes->count());
foreach ($quotes as $quote) { foreach ($quotes as $quote) {
$transformed[] = [ $transformed[] = [
'id' => $quote->id, 'id' => $quote->id,
@ -1250,7 +1065,7 @@ trait GenerateMigrationResources
'tax_name2' => $quote->tax_name2, 'tax_name2' => $quote->tax_name2,
'tax_rate1' => $quote->tax_rate1, 'tax_rate1' => $quote->tax_rate1,
'tax_rate2' => $quote->tax_rate2, 'tax_rate2' => $quote->tax_rate2,
'invoice_id' => Invoice::getPrivateId($quote->quote_invoice_id), 'invoice_id' => $quote->quote_invoice_id,
'custom_surcharge1' => $quote->custom_value1 ?: '', 'custom_surcharge1' => $quote->custom_value1 ?: '',
'custom_surcharge2' => $quote->custom_value2 ?: '', 'custom_surcharge2' => $quote->custom_value2 ?: '',
'custom_value1' => $quote->custom_text_value1 ?: '', 'custom_value1' => $quote->custom_text_value1 ?: '',
@ -1300,6 +1115,7 @@ trait GenerateMigrationResources
public function getPayments() public function getPayments()
{ {
info("get payments");
$transformed = []; $transformed = [];
@ -1308,9 +1124,6 @@ trait GenerateMigrationResources
->withTrashed() ->withTrashed()
->get(); ->get();
info("get payments => " . $payments->count());
foreach ($payments as $payment) { foreach ($payments as $payment) {
$transformed[] = [ $transformed[] = [
'id' => $payment->id, 'id' => $payment->id,
@ -1331,7 +1144,6 @@ trait GenerateMigrationResources
'refunded' => $payment->refunded ?: 0, 'refunded' => $payment->refunded ?: 0,
'date' => $payment->payment_date, 'date' => $payment->payment_date,
'transaction_reference' => $payment->transaction_reference ?: '', 'transaction_reference' => $payment->transaction_reference ?: '',
'private_notes' => $payment->private_notes ?: '',
'payer_id' => $payment->payer_id, 'payer_id' => $payment->payer_id,
'is_deleted' => (bool)$payment->is_deleted, 'is_deleted' => (bool)$payment->is_deleted,
'exchange_rate' => $payment->exchange_rate ? number_format((float) $payment->exchange_rate, 6) : null, 'exchange_rate' => $payment->exchange_rate ? number_format((float) $payment->exchange_rate, 6) : null,
@ -1371,28 +1183,12 @@ trait GenerateMigrationResources
const SEPA = 29; const SEPA = 29;
const GOCARDLESS = 30; const GOCARDLESS = 30;
const CRYPTO = 31; const CRYPTO = 31;
const MOLLIE_BANK_TRANSFER = 34;
const KBC = 35;
const BANCONTACT = 36;
const IDEAL = 37;
const HOSTED_PAGE = 38;
const GIROPAY = 39;
const PRZELEWY24 = 40;
const EPS = 41;
const DIRECT_DEBIT = 42;
const BECS = 43;
const ACSS = 44;
const INSTANT_BANK_PAY = 45;
const FPX = 46;
*/ */
private function transformPaymentType($payment_type_id) private function transformPaymentType($payment_type_id)
{ {
switch ($payment_type_id) { switch ($payment_type_id) {
case 4:
return 42;
case PAYMENT_TYPE_CREDIT: case PAYMENT_TYPE_CREDIT:
return 32; return 1;
case PAYMENT_TYPE_ACH: case PAYMENT_TYPE_ACH:
return 4; return 4;
case PAYMENT_TYPE_VISA: case PAYMENT_TYPE_VISA:
@ -1413,8 +1209,6 @@ trait GenerateMigrationResources
return 12; return 12;
case PAYMENT_TYPE_PAYPAL: case PAYMENT_TYPE_PAYPAL:
return 13; return 13;
case 16:
return 15;
case PAYMENT_TYPE_CARTE_BLANCHE: case PAYMENT_TYPE_CARTE_BLANCHE:
return 16; return 16;
case PAYMENT_TYPE_UNIONPAY: case PAYMENT_TYPE_UNIONPAY:
@ -1439,10 +1233,6 @@ trait GenerateMigrationResources
return 30; return 30;
case PAYMENT_TYPE_BITCOIN: case PAYMENT_TYPE_BITCOIN:
return 31; return 31;
case 2:
return 1;
case 3:
return 2;
default: default:
return $payment_type_id; return $payment_type_id;
@ -1459,13 +1249,12 @@ trait GenerateMigrationResources
private function getCredits() private function getCredits()
{ {
info("get credits");
$credits = Credit::where('account_id', $this->account->id)->where('balance', '>', 0)->whereIsDeleted(false) $credits = Credit::where('account_id', $this->account->id)->where('balance', '>', 0)->whereIsDeleted(false)
->withTrashed() ->withTrashed()
->get(); ->get();
info("get credits => " . $credits->count());
$transformed = []; $transformed = [];
foreach ($credits as $credit) { foreach ($credits as $credit) {
@ -1490,12 +1279,10 @@ trait GenerateMigrationResources
private function getDocuments() private function getDocuments()
{ {
info("get documents");
$documents = Document::where('account_id', $this->account->id)->get(); $documents = Document::where('account_id', $this->account->id)->get();
info("get documents => " . $documents->count());
$transformed = []; $transformed = [];
foreach ($documents as $document) { foreach ($documents as $document) {
@ -1535,9 +1322,12 @@ trait GenerateMigrationResources
$fees_and_limits = $this->transformFeesAndLimits($gateway_type); $fees_and_limits = $this->transformFeesAndLimits($gateway_type);
info("generated fees and limits = ");
info(print_r($fees_and_limits,1));
$translated_gateway_type = $this->translateGatewayTypeId($gateway_type); $translated_gateway_type = $this->translateGatewayTypeId($gateway_type);
info("translated gateway_type = {$translated_gateway_type}");
$fees->{$translated_gateway_type} = $fees_and_limits; $fees->{$translated_gateway_type} = $fees_and_limits;
} }
@ -1547,11 +1337,10 @@ trait GenerateMigrationResources
private function getCompanyGateways() private function getCompanyGateways()
{ {
info("get get company gateways");
$account_gateways = AccountGateway::where('account_id', $this->account->id)->withTrashed()->get(); $account_gateways = AccountGateway::where('account_id', $this->account->id)->withTrashed()->get();
info("get get company gateways => " . $account_gateways->count());
$transformed = []; $transformed = [];
foreach ($account_gateways as $account_gateway) { foreach ($account_gateways as $account_gateway) {
@ -1568,7 +1357,7 @@ trait GenerateMigrationResources
} }
catch(\Exception $e){ catch(\Exception $e){
// info($config); info($config);
} }
@ -1748,9 +1537,10 @@ trait GenerateMigrationResources
private function getClientGatewayTokens() private function getClientGatewayTokens()
{ {
$payment_methods = PaymentMethod::where('account_id', $this->account->id)->withTrashed()->get(); info("get client gateway tokens");
info("get client gateway tokens => " . $payment_methods->count());
$payment_methods = PaymentMethod::where('account_id', $this->account->id)->withTrashed()->get();
$transformed = []; $transformed = [];
@ -1760,9 +1550,6 @@ trait GenerateMigrationResources
$contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first(); $contact = Contact::where('id', $payment_method->contact_id)->withTrashed()->first();
$agt = AccountGatewayToken::where('id', $payment_method->account_gateway_token_id)->withTrashed()->first(); $agt = AccountGatewayToken::where('id', $payment_method->account_gateway_token_id)->withTrashed()->first();
if(!$contact && !$agt)
continue;
$transformed[] = [ $transformed[] = [
'id' => $payment_method->id, 'id' => $payment_method->id,
'company_id' => $this->account->id, 'company_id' => $this->account->id,
@ -1773,9 +1560,6 @@ trait GenerateMigrationResources
'gateway_type_id' => $payment_method->payment_type->gateway_type_id, 'gateway_type_id' => $payment_method->payment_type->gateway_type_id,
'is_default' => $is_default, 'is_default' => $is_default,
'meta' => $this->convertMeta($payment_method), 'meta' => $this->convertMeta($payment_method),
'created_at' => $payment_method->created_at ? Carbon::parse($payment_method->created_at)->toDateString() : null,
'updated_at' => $payment_method->updated_at ? Carbon::parse($payment_method->updated_at)->toDateString() : null,
'deleted_at' => $payment_method->deleted_at ? Carbon::parse($payment_method->deleted_at)->toDateString() : null,
]; ];
$is_default = false; $is_default = false;
@ -1786,11 +1570,11 @@ trait GenerateMigrationResources
private function getPaymentTerms() private function getPaymentTerms()
{ {
info("get payment terms");
$payment_terms = PaymentTerm::where('account_id', 0)->orWhere('account_id', $this->account->id)->withTrashed()->get(); $payment_terms = PaymentTerm::where('account_id', 0)->orWhere('account_id', $this->account->id)->withTrashed()->get();
info("get payment terms => " . $payment_terms->count());
$transformed = []; $transformed = [];
foreach($payment_terms as $payment_term) foreach($payment_terms as $payment_term)
@ -1817,9 +1601,9 @@ trait GenerateMigrationResources
private function getTaskStatuses() private function getTaskStatuses()
{ {
$task_statuses = TaskStatus::where('account_id', $this->account->id)->withTrashed()->get(); info("get task statuses");
info("get task statuses => " . $task_statuses->count()); $task_statuses = TaskStatus::where('account_id', $this->account->id)->withTrashed()->get();
if($task_statuses->count() == 0) if($task_statuses->count() == 0)
{ {
@ -1863,9 +1647,9 @@ trait GenerateMigrationResources
private function getExpenseCategories() private function getExpenseCategories()
{ {
$expense_categories = ExpenseCategory::where('account_id', $this->account->id)->withTrashed()->get(); info("get expense categories");
info("get expense categories => " . $expense_categories->count()); $expense_categories = ExpenseCategory::where('account_id', $this->account->id)->withTrashed()->get();
$transformed = []; $transformed = [];
@ -1888,9 +1672,9 @@ trait GenerateMigrationResources
private function getExpenses() private function getExpenses()
{ {
$expenses = Expense::where('account_id', $this->account->id)->withTrashed()->get(); info("get expenses");
info("get expenses => " . $expenses->count()); $expenses = Expense::where('account_id', $this->account->id)->withTrashed()->get();
$transformed = []; $transformed = [];
@ -1916,7 +1700,7 @@ trait GenerateMigrationResources
'invoice_documents' => $expense->invoice_documents, 'invoice_documents' => $expense->invoice_documents,
'invoice_id' => $expense->invoice_id, 'invoice_id' => $expense->invoice_id,
'payment_date' => $expense->payment_date, 'payment_date' => $expense->payment_date,
'payment_type_id' => $this->transformPaymentType($expense->payment_type_id), 'payment_type_id' => $expense->payment_type_id,
'private_notes' => $expense->private_notes, 'private_notes' => $expense->private_notes,
'public_notes' => $expense->public_notes, 'public_notes' => $expense->public_notes,
'recurring_expense_id' => $expense->recurring_expense_id, 'recurring_expense_id' => $expense->recurring_expense_id,
@ -1943,13 +1727,13 @@ trait GenerateMigrationResources
private function getTasks() private function getTasks()
{ {
info("get tasks");
$tasks = Task::where('account_id', $this->account->id) $tasks = Task::where('account_id', $this->account->id)
->withTrashed() ->withTrashed()
->get(); ->get();
info("get tasks => " . $tasks->count());
$transformed = []; $transformed = [];
foreach ($tasks as $task) foreach ($tasks as $task)
@ -1986,14 +1770,12 @@ trait GenerateMigrationResources
private function getProjects() private function getProjects()
{ {
info("get projects");
$projects = Project::where('account_id', $this->account->id) $projects = Project::where('account_id', $this->account->id)
->withTrashed() ->withTrashed()
->get(); ->get();
info("get projects => " . $projects);
$transformed = []; $transformed = [];
foreach ($projects as $project) foreach ($projects as $project)
@ -2030,9 +1812,9 @@ trait GenerateMigrationResources
protected function getVendors() protected function getVendors()
{ {
$vendor_query = Vendor::where('account_id', $this->account->id)->withTrashed()->get(); info("get vendors");
info("get vendors => " . $vendor_query->count()); $vendor_query = Vendor::where('account_id', $this->account->id)->withTrashed()->get();
$vendors = []; $vendors = [];
@ -2077,7 +1859,7 @@ trait GenerateMigrationResources
protected function getVendorContacts($contacts) protected function getVendorContacts($contacts)
{ {
info("get vendor contacts => " . $contacts->count()); info("get vendor contacts");
$transformed = []; $transformed = [];
@ -2096,7 +1878,7 @@ trait GenerateMigrationResources
'custom_value4' => '', 'custom_value4' => '',
'email' => $contact->email, 'email' => $contact->email,
'is_primary' => (bool)$contact->is_primary, 'is_primary' => (bool)$contact->is_primary,
'send_email' => (bool)$contact->send_invoice ?: true, 'send_email' => (bool)$contact->send_invoice ?: false,
'confirmed' => $contact->confirmation_token ? true : false, 'confirmed' => $contact->confirmation_token ? true : false,
'email_verified_at' => $contact->created_at->toDateTimeString(), 'email_verified_at' => $contact->created_at->toDateTimeString(),
'last_login' => $contact->last_login, 'last_login' => $contact->last_login,
@ -2152,8 +1934,8 @@ trait GenerateMigrationResources
} }
$fees_and_limits = new \stdClass(); $fees_and_limits = new \stdClass();
$fees_and_limits->min_limit = $ags->min_limit > 0 ? $ags->min_limit : -1; $fees_and_limits->min_limit = $ags->min_limit;
$fees_and_limits->max_limit = $ags->max_limit > 0 ? $ags->max_limit : -1; $fees_and_limits->max_limit = $ags->max_limit;
$fees_and_limits->fee_amount = $ags->fee_amount; $fees_and_limits->fee_amount = $ags->fee_amount;
$fees_and_limits->fee_percent = $ags->fee_percent; $fees_and_limits->fee_percent = $ags->fee_percent;
$fees_and_limits->fee_tax_name1 = $ags->tax_name1; $fees_and_limits->fee_tax_name1 = $ags->tax_name1;

View file

@ -58,6 +58,14 @@ if (strstr($_SERVER['HTTP_USER_AGENT'], 'PhantomJS') && Utils::isNinjaDev()) {
} }
*/ */
$app->configureMonologUsing(function($monolog) {
if (config('app.log') == 'single') {
$monolog->pushHandler(new Monolog\Handler\StreamHandler(storage_path() . '/logs/laravel-info.log', Monolog\Logger::INFO, false));
$monolog->pushHandler(new Monolog\Handler\StreamHandler(storage_path() . '/logs/laravel-warning.log', Monolog\Logger::WARNING, false));
$monolog->pushHandler(new Monolog\Handler\StreamHandler(storage_path() . '/logs/laravel-error.log', Monolog\Logger::ERROR, false));
}
});
// Capture real IP if using cloudflare // Capture real IP if using cloudflare
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];

View file

@ -13,99 +13,96 @@
} }
], ],
"require": { "require": {
"php": ">=7.3.0", "php": ">=7.1.0",
"ext-gd": "*", "ext-gd": "*",
"ext-gmp": "*", "ext-gmp": "*",
"ext-json": "*", "ext-json": "*",
"ext-zip": "*", "ext-zip": "*",
"abdala/omnipay-pagseguro": "0.2",
"agmscode/omnipay-agms": "~1.0",
"anahkiasen/former": "4.*", "anahkiasen/former": "4.*",
"andreas22/omnipay-fasapay": "1.*",
"asgrim/ofxparser": "^1.1", "asgrim/ofxparser": "^1.1",
"bacon/bacon-qr-code": "^1.0", "bacon/bacon-qr-code": "^1.0",
"barracudanetworks/archivestream-php": "^1.0", "barracudanetworks/archivestream-php": "^1.0",
"barryvdh/laravel-cors": "^1.0.6", "barryvdh/laravel-cors": "^0.9.1",
"barryvdh/laravel-debugbar": "~3.6.1", "barryvdh/laravel-debugbar": "~3.0.1",
"barryvdh/laravel-ide-helper": "~2.7", "barryvdh/laravel-ide-helper": "~2.2",
"cerdic/css-tidy": "~v1.5",
"chumper/datatable": "dev-add-back-options",
"cleverit/ubl_invoice": "1.*",
"codedge/laravel-selfupdater": "2.2.0",
"collizo4sky/omnipay-wepay": "dev-address-fix#942f3e0",
"digitickets/omnipay-gocardlessv2": "dev-payment-fix",
"doctrine/dbal": "2.5.x",
"dompdf/dompdf": "0.6.2",
"ezyang/htmlpurifier": "~v4.7",
"fzaninotto/faker": "^1.5",
"google/apiclient": "^2.0",
"guzzlehttp/guzzle": "^6.3",
"intervention/image": "dev-master",
"jaybizzle/laravel-crawler-detect": "1.*",
"jlapp/swaggervel": "master-dev",
"jonnyw/php-phantomjs": "dev-fixes",
"laracasts/presenter": "dev-master",
"turbo124/framework": "5.5.51",
"laravel/legacy-encrypter": "^1.0",
"laravel/socialite": "3.0.x-dev",
"laravel/tinker": "^1.0",
"laravelcollective/html": "5.5.*",
"league/csv": "^9.1",
"league/flysystem-aws-s3-v3": "~1.0",
"league/flysystem-rackspace": "~1.0",
"league/fractal": "0.13.*",
"maatwebsite/excel": "~2.0",
"mashape/unirest-php": "^3.0",
"mpdf/mpdf": "7.1.7",
"nesbot/carbon": "^1.26",
"nwidart/laravel-modules": "2.0.*",
"omnipay/authorizenet": "dev-solution-id as 2.5.0",
"omnipay/firstdata": "^2.4",
"patricktalmadge/bootstrapper": "5.5.x",
"turbo124/google2fa-laravel": "0.1.2",
"predis/predis": "^1.1",
"simshaun/recurr": "dev-master",
"stripe/stripe-php": "^6.40",
"symfony/css-selector": "~3.1",
"turbo124/laravel-push-notification": "2.*",
"webpatser/laravel-countries": "dev-master#75992ad",
"websight/l5-google-cloud-storage": "dev-master",
"wepay/php-sdk": "^0.2",
"wildbit/postmark-php": "^2.5",
"abdala/omnipay-pagseguro": "0.2",
"agmscode/omnipay-agms": "~1.0",
"andreas22/omnipay-fasapay": "1.*",
"bramdevries/omnipay-paymill": "^1.0", "bramdevries/omnipay-paymill": "^1.0",
"cardgate/omnipay-cardgate": "~2.0", "cardgate/omnipay-cardgate": "~2.0",
"cerdic/css-tidy": "~v1.5",
"chumper/datatable": "dev-laravel6-support",
"cleverit/ubl_invoice": "1.*",
"codedge/laravel-selfupdater": "2.3.0",
"collizo4sky/omnipay-wepay": "dev-address-fix#942f3e0",
"delatbabel/omnipay-fatzebra": "dev-master", "delatbabel/omnipay-fatzebra": "dev-master",
"dercoder/omnipay-ecopayz": "~1.0", "dercoder/omnipay-ecopayz": "~1.0",
"dercoder/omnipay-paysafecard": "dev-master", "dercoder/omnipay-paysafecard": "dev-master",
"digitickets/omnipay-barclays-epdq": "~3.0", "digitickets/omnipay-barclays-epdq": "~3.0",
"digitickets/omnipay-datacash": "~3.0", "digitickets/omnipay-datacash": "~3.0",
"digitickets/omnipay-gocardlessv2": "dev-payment-fix",
"digitickets/omnipay-realex": "~5.0", "digitickets/omnipay-realex": "~5.0",
"doctrine/dbal": "2.6.x",
"dompdf/dompdf": "^2.0",
"ezyang/htmlpurifier": "~v4.7",
"fotografde/omnipay-checkoutcom": "~2.0", "fotografde/omnipay-checkoutcom": "~2.0",
"fruitcakestudio/omnipay-sisow": "~2.0", "fruitcakestudio/omnipay-sisow": "~2.0",
"fzaninotto/faker": "^1.5",
"google/apiclient": "^2.0",
"guzzlehttp/guzzle": "^6.5",
"guzzlehttp/psr7": "1.8.5",
"intervention/image": "dev-master",
"jaybizzle/laravel-crawler-detect": "1.*",
"jlapp/swaggervel": "master-dev",
"jonnyw/php-phantomjs": "dev-fixes",
"justinbusschau/omnipay-secpay": "~2.0", "justinbusschau/omnipay-secpay": "~2.0",
"laracasts/presenter": "dev-master",
"laravel/framework": "^6.20",
"laravel/helpers": "^1.4",
"laravel/legacy-encrypter": "^1.0",
"laravel/socialite": "~4.4.1",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^6.2",
"league/csv": "^9.1",
"league/flysystem-aws-s3-v3": "~1.0",
"league/flysystem-rackspace": "~1.0",
"league/fractal": "0.13.*",
"lokielse/omnipay-alipay": "~1.4", "lokielse/omnipay-alipay": "~1.4",
"maatwebsite/excel": "dev-php-fix",
"meebio/omnipay-creditcall": "dev-master", "meebio/omnipay-creditcall": "dev-master",
"meebio/omnipay-secure-trading": "dev-master", "meebio/omnipay-secure-trading": "dev-master",
"mfauveau/omnipay-pacnet": "~2.0", "mfauveau/omnipay-pacnet": "~2.0",
"mpdf/mpdf": "^8.0",
"nesbot/carbon": "^2.0",
"nwidart/laravel-modules": "2.0.*",
"omnipay/authorizenet": "dev-solution-id as 2.5.0",
"omnipay/bitpay": "dev-master", "omnipay/bitpay": "dev-master",
"omnipay/braintree": "^1.1", "omnipay/braintree": "^1.1",
"omnipay/common": "2.5.2",
"omnipay/firstdata": "^2.4",
"omnipay/gocardless": "dev-master", "omnipay/gocardless": "dev-master",
"omnipay/mollie": "3.*", "omnipay/mollie": "3.*",
"omnipay/omnipay": "~2.3", "omnipay/omnipay": "~2.3",
"omnipay/payfast": "~2.0", "omnipay/payfast": "~2.0",
"omnipay/stripe": "~2.0", "omnipay/stripe": "~2.0",
"patricktalmadge/bootstrapper": "5.12.x",
"pragmarx/google2fa-laravel": "0.1.4",
"predis/predis": "^1.1",
"simshaun/recurr": "dev-master",
"softcommerce/omnipay-paytrace": "~1.0", "softcommerce/omnipay-paytrace": "~1.0",
"stripe/stripe-php": "^7",
"superbalist/laravel-google-cloud-storage": "^2.2",
"symfony/css-selector": "~3.1",
"therobfonz/laravel-mandrill-driver": "~1.0",
"turbo124/laravel-push-notification": "dev-master",
"vemcogroup/laravel-sparkpost-driver": "~2.0",
"vink/omnipay-komoju": "~1.0", "vink/omnipay-komoju": "~1.0",
"webpatser/laravel-countries": "dev-master#75992ad", "omnipay/common": "2.5.2"
"wepay/php-sdk": "^0.2",
"wildbit/postmark-php": "^2.5"
}, },
"require-dev": { "require-dev": {
"symfony/dom-crawler": "~3.1", "symfony/dom-crawler": "~3.1",
"codeception/c3": "2.*", "codeception/c3": "2.*",
"codeception/codeception": "2.*", "codeception/codeception": "2.*",
"phpspec/phpspec": "~6.1", "phpspec/phpspec": "~2.1",
"phpunit/phpunit": "~5.7" "phpunit/phpunit": "~5.7"
}, },
"autoload": { "autoload": {
@ -160,10 +157,7 @@
"config": { "config": {
"preferred-install": "dist", "preferred-install": "dist",
"sort-packages": true, "sort-packages": true,
"optimize-autoloader": true, "optimize-autoloader": true
"allow-plugins": {
"codeception/c3": true
}
}, },
"repositories": [ "repositories": [
{ {
@ -180,11 +174,11 @@
}, },
{ {
"type": "vcs", "type": "vcs",
"url": "https://github.com/turbo124/chumper-datatable" "url": "https://github.com/hillelcoren/datatable"
}, },
{ {
"type": "vcs", "type": "vcs",
"url": "https://github.com/turbo124/php-phantomjs" "url": "https://github.com/hillelcoren/php-phantomjs"
}, },
{ {
"type": "vcs", "type": "vcs",
@ -193,22 +187,6 @@
{ {
"type": "vcs", "type": "vcs",
"url": "https://github.com/hillelcoren/omnipay-authorizenet" "url": "https://github.com/hillelcoren/omnipay-authorizenet"
},
{
"type": "vcs",
"url": "https://github.com/turbo124/omnipay-common"
},
{
"type": "vcs",
"url": "https://github.com/turbo124/laravel-push-notification"
},
{
"type": "vcs",
"url": "https://github.com/turbo124/NotificationPusher"
},
{
"type": "vcs",
"url": "https://github.com/turbo124/Laravel-Excel"
} }
] ]
} }

7790
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -88,6 +88,21 @@ return [
'cipher' => env('APP_CIPHER', 'AES-256-CBC'), 'cipher' => env('APP_CIPHER', 'AES-256-CBC'),
/*
|--------------------------------------------------------------------------
| Logging Configuration
|--------------------------------------------------------------------------
|
| Here you may configure the log settings for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Settings: "single", "daily", "syslog", "errorlog"
|
*/
'log' => env('LOG', 'single'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Autoloaded Service Providers | Autoloaded Service Providers
@ -140,10 +155,11 @@ return [
'Laravel\Socialite\SocialiteServiceProvider', 'Laravel\Socialite\SocialiteServiceProvider',
'Jlapp\Swaggervel\SwaggervelServiceProvider', 'Jlapp\Swaggervel\SwaggervelServiceProvider',
'Maatwebsite\Excel\ExcelServiceProvider', 'Maatwebsite\Excel\ExcelServiceProvider',
Jaybizzle\LaravelCrawlerDetect\LaravelCrawlerDetectServiceProvider::class, Websight\GcsProvider\CloudStorageServiceProvider::class,
'Jaybizzle\LaravelCrawlerDetect\LaravelCrawlerDetectServiceProvider',
Codedge\Updater\UpdaterServiceProvider::class, Codedge\Updater\UpdaterServiceProvider::class,
Nwidart\Modules\LaravelModulesServiceProvider::class, Nwidart\Modules\LaravelModulesServiceProvider::class,
Fruitcake\Cors\CorsServiceProvider::class, Barryvdh\Cors\ServiceProvider::class,
PragmaRX\Google2FALaravel\ServiceProvider::class, PragmaRX\Google2FALaravel\ServiceProvider::class,
'Chumper\Datatable\DatatableServiceProvider', 'Chumper\Datatable\DatatableServiceProvider',
Laravel\Tinker\TinkerServiceProvider::class, Laravel\Tinker\TinkerServiceProvider::class,
@ -159,6 +175,7 @@ return [
'App\Providers\RouteServiceProvider', 'App\Providers\RouteServiceProvider',
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider', 'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',
'Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider',
], ],
@ -186,75 +203,76 @@ return [
'Cookie' => 'Illuminate\Support\Facades\Cookie', 'Cookie' => 'Illuminate\Support\Facades\Cookie',
'Crypt' => 'Illuminate\Support\Facades\Crypt', 'Crypt' => 'Illuminate\Support\Facades\Crypt',
'DB' => 'Illuminate\Support\Facades\DB', 'DB' => 'Illuminate\Support\Facades\DB',
'Eloquent' => 'Illuminate\Database\Eloquent\Model', 'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event', 'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File', 'File' => 'Illuminate\Support\Facades\File',
'Gate' => 'Illuminate\Support\Facades\Gate', 'Gate' => 'Illuminate\Support\Facades\Gate',
'Hash' => 'Illuminate\Support\Facades\Hash', 'Hash' => 'Illuminate\Support\Facades\Hash',
'Input' => 'Illuminate\Support\Facades\Input', 'Input' => 'Illuminate\Support\Facades\Input',
'Lang' => 'Illuminate\Support\Facades\Lang', 'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log', 'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail', 'Mail' => 'Illuminate\Support\Facades\Mail',
'Password' => 'Illuminate\Support\Facades\Password', 'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue', 'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect', 'Redirect' => 'Illuminate\Support\Facades\Redirect',
'Redis' => 'Illuminate\Support\Facades\Redis', 'Redis' => 'Illuminate\Support\Facades\Redis',
'Request' => 'Illuminate\Support\Facades\Request', 'Request' => 'Illuminate\Support\Facades\Request',
'Response' => 'Illuminate\Support\Facades\Response', 'Response' => 'Illuminate\Support\Facades\Response',
'Route' => 'Illuminate\Support\Facades\Route', 'Route' => 'Illuminate\Support\Facades\Route',
'Schema' => 'Illuminate\Support\Facades\Schema', 'Schema' => 'Illuminate\Support\Facades\Schema',
'Seeder' => 'Illuminate\Database\Seeder', 'Seeder' => 'Illuminate\Database\Seeder',
'Session' => 'Illuminate\Support\Facades\Session', 'Session' => 'Illuminate\Support\Facades\Session',
'Storage' => 'Illuminate\Support\Facades\Storage', 'Storage' => 'Illuminate\Support\Facades\Storage',
'Str' => 'Illuminate\Support\Str', 'Str' => 'Illuminate\Support\Str',
'URL' => 'Illuminate\Support\Facades\URL', 'URL' => 'Illuminate\Support\Facades\URL',
'Validator' => 'Illuminate\Support\Facades\Validator', 'Validator' => 'Illuminate\Support\Facades\Validator',
'View' => 'Illuminate\Support\Facades\View', 'View' => 'Illuminate\Support\Facades\View',
// Added Class Aliases // Added Class Aliases
'Form' => 'Collective\Html\FormFacade', 'Form' => 'Collective\Html\FormFacade',
'HTML' => 'Collective\Html\HtmlFacade', 'HTML' => 'Collective\Html\HtmlFacade',
'SSH' => 'Illuminate\Support\Facades\SSH', 'SSH' => 'Illuminate\Support\Facades\SSH',
'Alert' => 'Bootstrapper\Facades\Alert', 'Alert' => 'Bootstrapper\Facades\Alert',
'Badge' => 'Bootstrapper\Facades\Badge', 'Badge' => 'Bootstrapper\Facades\Badge',
'Breadcrumb' => 'Bootstrapper\Facades\Breadcrumb', 'Breadcrumb' => 'Bootstrapper\Facades\Breadcrumb',
'Button' => 'Bootstrapper\Facades\Button', 'Button' => 'Bootstrapper\Facades\Button',
'ButtonGroup' => 'Bootstrapper\Facades\ButtonGroup', 'ButtonGroup' => 'Bootstrapper\Facades\ButtonGroup',
'ButtonToolbar' => 'Bootstrapper\Facades\ButtonToolbar', 'ButtonToolbar' => 'Bootstrapper\Facades\ButtonToolbar',
'Carousel' => 'Bootstrapper\Facades\Carousel', 'Carousel' => 'Bootstrapper\Facades\Carousel',
'DropdownButton' => 'Bootstrapper\Facades\DropdownButton', 'DropdownButton' => 'Bootstrapper\Facades\DropdownButton',
'Helpers' => 'Bootstrapper\Facades\Helpers', 'Helpers' => 'Bootstrapper\Facades\Helpers',
'Icon' => 'Bootstrapper\Facades\Icon', 'Icon' => 'Bootstrapper\Facades\Icon',
'Label' => 'Bootstrapper\Facades\Label', 'Label' => 'Bootstrapper\Facades\Label',
'MediaObject' => 'Bootstrapper\Facades\MediaObject', 'MediaObject' => 'Bootstrapper\Facades\MediaObject',
'Navbar' => 'Bootstrapper\Facades\Navbar', 'Navbar' => 'Bootstrapper\Facades\Navbar',
'Navigation' => 'Bootstrapper\Facades\Navigation', 'Navigation' => 'Bootstrapper\Facades\Navigation',
'Paginator' => 'Bootstrapper\Facades\Paginator', 'Paginator' => 'Bootstrapper\Facades\Paginator',
'Progress' => 'Bootstrapper\Facades\Progress', 'Progress' => 'Bootstrapper\Facades\Progress',
'Tabbable' => 'Bootstrapper\Facades\Tabbable', 'Tabbable' => 'Bootstrapper\Facades\Tabbable',
'Table' => 'Bootstrapper\Facades\Table', 'Table' => 'Bootstrapper\Facades\Table',
'Thumbnail' => 'Bootstrapper\Facades\Thumbnail', 'Thumbnail' => 'Bootstrapper\Facades\Thumbnail',
'Typeahead' => 'Bootstrapper\Facades\Typeahead', 'Typeahead' => 'Bootstrapper\Facades\Typeahead',
'Typography' => 'Bootstrapper\Facades\Typography', 'Typography' => 'Bootstrapper\Facades\Typography',
'Former' => 'Former\Facades\Former', 'Former' => 'Former\Facades\Former',
'Omnipay' => 'Omnipay\Omnipay', 'Omnipay' => 'Omnipay\Omnipay',
'CreditCard' => 'Omnipay\Common\CreditCard', 'CreditCard' => 'Omnipay\Common\CreditCard',
'Image' => 'Intervention\Image\Facades\Image', 'Image' => 'Intervention\Image\Facades\Image',
'Countries' => 'Webpatser\Countries\CountriesFacade', 'Countries' => 'Webpatser\Countries\CountriesFacade',
'Carbon' => 'Carbon\Carbon', 'Carbon' => 'Carbon\Carbon',
'Rocketeer' => 'Rocketeer\Facades\Rocketeer', 'Rocketeer' => 'Rocketeer\Facades\Rocketeer',
'Socialite' => 'Laravel\Socialite\Facades\Socialite', 'Socialite' => 'Laravel\Socialite\Facades\Socialite',
'Excel' => 'Maatwebsite\Excel\Facades\Excel', 'Excel' => 'Maatwebsite\Excel\Facades\Excel',
'Crawler' => Jaybizzle\LaravelCrawlerDetect\Facades\LaravelCrawlerDetect::class, 'PushNotification' => 'Davibennun\LaravelPushNotification\Facades\PushNotification',
'Datatable' => 'Chumper\Datatable\Facades\DatatableFacade', 'Crawler' => 'Jaybizzle\LaravelCrawlerDetect\Facades\LaravelCrawlerDetect',
'Updater' => Codedge\Updater\UpdaterFacade::class, 'Datatable' => 'Chumper\Datatable\Facades\DatatableFacade',
'Module' => Nwidart\Modules\Facades\Module::class, 'Updater' => Codedge\Updater\UpdaterFacade::class,
'Module' => Nwidart\Modules\Facades\Module::class,
'Utils' => App\Libraries\Utils::class, 'Utils' => App\Libraries\Utils::class,
'DateUtils' => App\Libraries\DateUtils::class, 'DateUtils' => App\Libraries\DateUtils::class,
'HTMLUtils' => App\Libraries\HTMLUtils::class, 'HTMLUtils' => App\Libraries\HTMLUtils::class,
'CurlUtils' => App\Libraries\CurlUtils::class, 'CurlUtils' => App\Libraries\CurlUtils::class,
'Domain' => App\Constants\Domain::class, 'Domain' => App\Constants\Domain::class,
'Google2FA' => PragmaRX\Google2FALaravel\Facade::class, 'Google2FA' => PragmaRX\Google2FALaravel\Facade::class,
], ],

Some files were not shown because too many files have changed in this diff Show more