mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
php-cs-fixer cleanup
This commit is contained in:
parent
4da2a7125f
commit
c0fbaf1e89
100
.php_cs.dist
Normal file
100
.php_cs.dist
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->notPath('bootstrap/cache')
|
||||
->notPath('storage')
|
||||
->notPath('vendor')
|
||||
->in(__DIR__)
|
||||
->name('*.php')
|
||||
->notName('*.blade.php')
|
||||
->ignoreDotFiles(true)
|
||||
->ignoreVCS(true);
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules(array(
|
||||
'@PSR2' => true,
|
||||
'binary_operator_spaces' => true,
|
||||
'blank_line_after_namespace' => true,
|
||||
'blank_line_after_opening_tag' => true,
|
||||
'blank_line_before_return' => true,
|
||||
'braces' => true,
|
||||
'cast_spaces' => true,
|
||||
'class_definition' => true,
|
||||
'elseif' => true,
|
||||
'encoding' => true,
|
||||
'full_opening_tag' => true,
|
||||
'function_declaration' => true,
|
||||
'function_typehint_space' => true,
|
||||
'hash_to_slash_comment' => true,
|
||||
'heredoc_to_nowdoc' => true,
|
||||
'include' => true,
|
||||
'lowercase_cast' => true,
|
||||
'lowercase_constants' => true,
|
||||
'lowercase_keywords' => true,
|
||||
'method_argument_space' => true,
|
||||
'method_separation' => true,
|
||||
'native_function_casing' => true,
|
||||
'new_with_braces' => true,
|
||||
'no_alias_functions' => true,
|
||||
'no_blank_lines_after_class_opening' => true,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_closing_tag' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_extra_consecutive_blank_lines' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_leading_namespace_whitespace' => true,
|
||||
'no_multiline_whitespace_around_double_arrow' => true,
|
||||
'no_multiline_whitespace_before_semicolons' => true,
|
||||
'no_short_bool_cast' => true,
|
||||
'no_singleline_whitespace_before_semicolons' => true,
|
||||
'no_spaces_after_function_name' => true,
|
||||
'no_spaces_inside_parenthesis' => true,
|
||||
'no_trailing_comma_in_list_call' => true,
|
||||
'no_trailing_comma_in_singleline_array' => true,
|
||||
'no_trailing_whitespace' => true,
|
||||
'no_trailing_whitespace_in_comment' => true,
|
||||
'no_unneeded_control_parentheses' => true,
|
||||
'no_unreachable_default_argument_value' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_useless_return' => true,
|
||||
'no_whitespace_before_comma_in_array' => true,
|
||||
'not_operator_with_successor_space' => true,
|
||||
'object_operator_without_whitespace' => true,
|
||||
'ordered_imports' => true,
|
||||
'phpdoc_align' => true,
|
||||
'phpdoc_indent' => true,
|
||||
'phpdoc_inline_tag' => true,
|
||||
'phpdoc_no_access' => true,
|
||||
'phpdoc_no_package' => true,
|
||||
'phpdoc_order' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_separation' => true,
|
||||
'phpdoc_summary' => true,
|
||||
'phpdoc_to_comment' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_types' => true,
|
||||
'phpdoc_var_without_name' => true,
|
||||
//'psr4' => true,
|
||||
'self_accessor' => true,
|
||||
'short_scalar_cast' => true,
|
||||
//'simplified_null_return' => true,
|
||||
'single_blank_line_at_eof' => true,
|
||||
'single_blank_line_before_namespace' => true,
|
||||
'single_import_per_statement' => true,
|
||||
'single_line_after_imports' => true,
|
||||
'single_quote' => true,
|
||||
'space_after_semicolon' => true,
|
||||
'standardize_not_equals' => true,
|
||||
'switch_case_semicolon_to_colon' => true,
|
||||
'switch_case_space' => true,
|
||||
'ternary_operator_spaces' => true,
|
||||
'trailing_comma_in_multiline_array' => true,
|
||||
'trim_array_spaces' => true,
|
||||
'unary_operator_spaces' => true,
|
||||
'visibility_required' => true,
|
||||
'whitespace_after_comma_in_array' => true,
|
||||
//'strict_param' => true,
|
||||
'array_syntax' => array('syntax' => 'short'),
|
||||
))
|
||||
->setFinder($finder)
|
||||
;
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
abstract class Command
|
||||
{
|
||||
|
@ -1,14 +1,16 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Invoice;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Services\PaymentService;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Account;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class ChargeRenewalInvoices
|
||||
* Class ChargeRenewalInvoices.
|
||||
*/
|
||||
class ChargeRenewalInvoices extends Command
|
||||
{
|
||||
@ -39,9 +41,10 @@ class ChargeRenewalInvoices extends Command
|
||||
|
||||
/**
|
||||
* ChargeRenewalInvoices constructor.
|
||||
* @param Mailer $mailer
|
||||
*
|
||||
* @param Mailer $mailer
|
||||
* @param AccountRepository $repo
|
||||
* @param PaymentService $paymentService
|
||||
* @param PaymentService $paymentService
|
||||
*/
|
||||
public function __construct(Mailer $mailer, AccountRepository $repo, PaymentService $paymentService)
|
||||
{
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Mail;
|
||||
use Utils;
|
||||
use Carbon;
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use Mail;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Utils;
|
||||
|
||||
/*
|
||||
|
||||
@ -37,13 +39,11 @@ Options:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class CheckData
|
||||
* Class CheckData.
|
||||
*/
|
||||
class CheckData extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -61,14 +61,14 @@ class CheckData extends Command
|
||||
{
|
||||
$this->logMessage(date('Y-m-d') . ' Running CheckData...');
|
||||
|
||||
if (!$this->option('client_id')) {
|
||||
if (! $this->option('client_id')) {
|
||||
$this->checkPaidToDate();
|
||||
$this->checkBlankInvoiceHistory();
|
||||
}
|
||||
|
||||
$this->checkBalances();
|
||||
|
||||
if (!$this->option('client_id')) {
|
||||
if (! $this->option('client_id')) {
|
||||
$this->checkAccountData();
|
||||
}
|
||||
|
||||
@ -115,33 +115,33 @@ class CheckData extends Command
|
||||
ENTITY_CONTACT,
|
||||
ENTITY_PAYMENT,
|
||||
ENTITY_INVITATION,
|
||||
ENTITY_USER
|
||||
ENTITY_USER,
|
||||
],
|
||||
'invoices' => [
|
||||
ENTITY_CLIENT,
|
||||
ENTITY_USER
|
||||
ENTITY_USER,
|
||||
],
|
||||
'payments' => [
|
||||
ENTITY_INVOICE,
|
||||
ENTITY_CLIENT,
|
||||
ENTITY_USER,
|
||||
ENTITY_INVITATION,
|
||||
ENTITY_CONTACT
|
||||
ENTITY_CONTACT,
|
||||
],
|
||||
'tasks' => [
|
||||
ENTITY_INVOICE,
|
||||
ENTITY_CLIENT,
|
||||
ENTITY_USER
|
||||
ENTITY_USER,
|
||||
],
|
||||
'credits' => [
|
||||
ENTITY_CLIENT,
|
||||
ENTITY_USER
|
||||
ENTITY_USER,
|
||||
],
|
||||
'expenses' => [
|
||||
ENTITY_CLIENT,
|
||||
ENTITY_VENDOR,
|
||||
ENTITY_INVOICE,
|
||||
ENTITY_USER
|
||||
ENTITY_USER,
|
||||
],
|
||||
'products' => [
|
||||
ENTITY_USER,
|
||||
@ -152,7 +152,7 @@ class CheckData extends Command
|
||||
'projects' => [
|
||||
ENTITY_USER,
|
||||
ENTITY_CLIENT,
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($tables as $table => $entityTypes) {
|
||||
@ -259,7 +259,7 @@ class CheckData extends Command
|
||||
->first(['invoices.amount', 'invoices.is_recurring', 'invoices.invoice_type_id', 'invoices.deleted_at', 'invoices.id', 'invoices.is_deleted']);
|
||||
|
||||
// Check if this invoice was once set as recurring invoice
|
||||
if ($invoice && !$invoice->is_recurring && DB::table('invoices')
|
||||
if ($invoice && ! $invoice->is_recurring && DB::table('invoices')
|
||||
->where('recurring_invoice_id', '=', $activity->invoice_id)
|
||||
->first(['invoices.id'])) {
|
||||
$invoice->is_recurring = 1;
|
||||
@ -273,7 +273,6 @@ class CheckData extends Command
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_INVOICE
|
||||
|| $activity->activity_type_id == ACTIVITY_TYPE_CREATE_QUOTE) {
|
||||
|
||||
@ -294,12 +293,12 @@ class CheckData extends Command
|
||||
|
||||
// **Fix for ninja invoices which didn't have the invoice_type_id value set
|
||||
if ($noAdjustment && $client->account_id == 20432) {
|
||||
$this->logMessage("No adjustment for ninja invoice");
|
||||
$this->logMessage('No adjustment for ninja invoice');
|
||||
$foundProblem = true;
|
||||
$clientFix += $invoice->amount;
|
||||
$activityFix = $invoice->amount;
|
||||
// **Fix for allowing converting a recurring invoice to a normal one without updating the balance**
|
||||
} elseif ($noAdjustment && $invoice->invoice_type_id == INVOICE_TYPE_STANDARD && !$invoice->is_recurring) {
|
||||
} elseif ($noAdjustment && $invoice->invoice_type_id == INVOICE_TYPE_STANDARD && ! $invoice->is_recurring) {
|
||||
$this->logMessage("No adjustment for new invoice:{$activity->invoice_id} amount:{$invoice->amount} invoiceTypeId:{$invoice->invoice_type_id} isRecurring:{$invoice->is_recurring}");
|
||||
$foundProblem = true;
|
||||
$clientFix += $invoice->amount;
|
||||
@ -323,7 +322,7 @@ class CheckData extends Command
|
||||
}
|
||||
} elseif ($activity->activity_type_id == ACTIVITY_TYPE_ARCHIVE_INVOICE) {
|
||||
// **Fix for updating balance when archiving an invoice**
|
||||
if ($activity->adjustment != 0 && !$invoice->is_recurring) {
|
||||
if ($activity->adjustment != 0 && ! $invoice->is_recurring) {
|
||||
$this->logMessage("Incorrect adjustment for archiving invoice adjustment:{$activity->adjustment}");
|
||||
$foundProblem = true;
|
||||
$activityFix = 0;
|
||||
@ -362,7 +361,7 @@ class CheckData extends Command
|
||||
|
||||
if ($activityFix !== false || $clientFix !== false) {
|
||||
$data = [
|
||||
'balance' => $activity->balance + $clientFix
|
||||
'balance' => $activity->balance + $clientFix,
|
||||
];
|
||||
|
||||
if ($activityFix !== false) {
|
||||
@ -385,8 +384,8 @@ class CheckData extends Command
|
||||
$this->logMessage("** Creating 'recovered update' activity **");
|
||||
if ($this->option('fix') == 'true') {
|
||||
DB::table('activities')->insert([
|
||||
'created_at' => new Carbon,
|
||||
'updated_at' => new Carbon,
|
||||
'created_at' => new Carbon(),
|
||||
'updated_at' => new Carbon(),
|
||||
'account_id' => $client->account_id,
|
||||
'client_id' => $client->id,
|
||||
'adjustment' => $client->actual_balance - $activity->balance,
|
||||
|
@ -1,17 +1,19 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Auth;
|
||||
use Utils;
|
||||
use Illuminate\Console\Command;
|
||||
use Faker\Factory;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
use App\Ninja\Repositories\ExpenseRepository;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Repositories\PaymentRepository;
|
||||
use App\Ninja\Repositories\VendorRepository;
|
||||
use App\Ninja\Repositories\ExpenseRepository;
|
||||
use Auth;
|
||||
use Faker\Factory;
|
||||
use Illuminate\Console\Command;
|
||||
use Utils;
|
||||
|
||||
/**
|
||||
* Class CreateTestData
|
||||
* Class CreateTestData.
|
||||
*/
|
||||
class CreateTestData extends Command
|
||||
{
|
||||
@ -32,10 +34,11 @@ class CreateTestData extends Command
|
||||
|
||||
/**
|
||||
* CreateTestData constructor.
|
||||
* @param ClientRepository $clientRepo
|
||||
*
|
||||
* @param ClientRepository $clientRepo
|
||||
* @param InvoiceRepository $invoiceRepo
|
||||
* @param PaymentRepository $paymentRepo
|
||||
* @param VendorRepository $vendorRepo
|
||||
* @param VendorRepository $vendorRepo
|
||||
* @param ExpenseRepository $expenseRepo
|
||||
*/
|
||||
public function __construct(
|
||||
@ -78,7 +81,7 @@ class CreateTestData extends Command
|
||||
|
||||
private function createClients()
|
||||
{
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
for ($i = 0; $i < $this->count; $i++) {
|
||||
$data = [
|
||||
'name' => $this->faker->name,
|
||||
'address1' => $this->faker->streetAddress,
|
||||
@ -91,7 +94,7 @@ class CreateTestData extends Command
|
||||
'last_name' => $this->faker->lastName,
|
||||
'email' => $this->faker->safeEmail,
|
||||
'phone' => $this->faker->phoneNumber,
|
||||
]]
|
||||
]],
|
||||
];
|
||||
|
||||
$client = $this->clientRepo->save($data);
|
||||
@ -106,7 +109,7 @@ class CreateTestData extends Command
|
||||
*/
|
||||
private function createInvoices($client)
|
||||
{
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
for ($i = 0; $i < $this->count; $i++) {
|
||||
$data = [
|
||||
'client_id' => $client->id,
|
||||
'invoice_date_sql' => date_create()->modify(rand(-100, 100) . ' days')->format('Y-m-d'),
|
||||
@ -115,8 +118,8 @@ class CreateTestData extends Command
|
||||
'product_key' => $this->faker->word,
|
||||
'qty' => $this->faker->randomDigit + 1,
|
||||
'cost' => $this->faker->randomFloat(2, 1, 10),
|
||||
'notes' => $this->faker->text($this->faker->numberBetween(50, 300))
|
||||
]]
|
||||
'notes' => $this->faker->text($this->faker->numberBetween(50, 300)),
|
||||
]],
|
||||
];
|
||||
|
||||
$invoice = $this->invoiceRepo->save($data);
|
||||
@ -146,7 +149,7 @@ class CreateTestData extends Command
|
||||
|
||||
private function createVendors()
|
||||
{
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
for ($i = 0; $i < $this->count; $i++) {
|
||||
$data = [
|
||||
'name' => $this->faker->name,
|
||||
'address1' => $this->faker->streetAddress,
|
||||
@ -159,7 +162,7 @@ class CreateTestData extends Command
|
||||
'last_name' => $this->faker->lastName,
|
||||
'email' => $this->faker->safeEmail,
|
||||
'phone' => $this->faker->phoneNumber,
|
||||
]]
|
||||
]],
|
||||
];
|
||||
|
||||
$vendor = $this->vendorRepo->save($data);
|
||||
@ -174,7 +177,7 @@ class CreateTestData extends Command
|
||||
*/
|
||||
private function createExpense($vendor)
|
||||
{
|
||||
for ($i=0; $i<$this->count; $i++) {
|
||||
for ($i = 0; $i < $this->count; $i++) {
|
||||
$data = [
|
||||
'vendor_id' => $vendor->id,
|
||||
'amount' => $this->faker->randomFloat(2, 1, 10),
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use File;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class GenerateResources
|
||||
* Class GenerateResources.
|
||||
*/
|
||||
class GenerateResources extends Command
|
||||
{
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php namespace InvoiceNinja\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace InvoiceNinja\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
|
||||
/**
|
||||
* Class Inspire
|
||||
* Class Inspire.
|
||||
*/
|
||||
class Inspire extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Nwidart\Modules\Commands\GeneratorCommand;
|
||||
use Nwidart\Modules\Support\Stub;
|
||||
|
||||
use Nwidart\Modules\Traits\ModuleCommandTrait;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class MakeClass extends GeneratorCommand
|
||||
{
|
||||
@ -48,20 +48,19 @@ class MakeClass extends GeneratorCommand
|
||||
*/
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('fields', null, InputOption::VALUE_OPTIONAL, 'The model attributes.', null),
|
||||
array('filename', null, InputOption::VALUE_OPTIONAL, 'The class filename.', null),
|
||||
);
|
||||
return [
|
||||
['fields', null, InputOption::VALUE_OPTIONAL, 'The model attributes.', null],
|
||||
['filename', null, InputOption::VALUE_OPTIONAL, 'The class filename.', null],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getTemplateContents()
|
||||
{
|
||||
$module = $this->laravel['modules']->findOrFail($this->getModuleName());
|
||||
$path = str_replace('/', '\\', config('modules.paths.generator.' . $this->argument('class')));
|
||||
|
||||
return (new Stub('/' . $this->argument('prefix') . $this->argument('class') . '.stub', [
|
||||
'NAMESPACE' => $this->getClassNamespace($module) . "\\" . $path,
|
||||
'NAMESPACE' => $this->getClassNamespace($module) . '\\' . $path,
|
||||
'LOWER_NAME' => $module->getLowerName(),
|
||||
'CLASS' => $this->getClass(),
|
||||
'STUDLY_NAME' => Str::studly($module->getLowerName()),
|
||||
@ -88,6 +87,7 @@ class MakeClass extends GeneratorCommand
|
||||
if ($this->option('filename')) {
|
||||
return $this->option('filename');
|
||||
}
|
||||
|
||||
return studly_case($this->argument('prefix')) . studly_case($this->argument('name')) . Str::studly($this->argument('class'));
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class MakeModule extends Command
|
||||
$fillable = array_map(function ($item) {
|
||||
return explode(':', $item)[0];
|
||||
}, $fillable);
|
||||
$fillable = join(',', $fillable);
|
||||
$fillable = implode(',', $fillable);
|
||||
|
||||
$this->info("Creating module: {$name}...");
|
||||
|
||||
@ -77,21 +77,21 @@ class MakeModule extends Command
|
||||
|
||||
Artisan::call('module:dump');
|
||||
|
||||
$this->info("Done");
|
||||
$this->info('Done');
|
||||
}
|
||||
|
||||
protected function getArguments()
|
||||
{
|
||||
return [
|
||||
['name', InputArgument::REQUIRED, 'The name of the module.'],
|
||||
['fields', InputArgument::OPTIONAL, 'The fields of the module.']
|
||||
['fields', InputArgument::OPTIONAL, 'The fields of the module.'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOptions()
|
||||
{
|
||||
return array(
|
||||
array('migrate', null, InputOption::VALUE_OPTIONAL, 'The model attributes.', null),
|
||||
);
|
||||
return [
|
||||
['migrate', null, InputOption::VALUE_OPTIONAL, 'The model attributes.', null],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class PruneData
|
||||
* Class PruneData.
|
||||
*/
|
||||
class PruneData extends Command
|
||||
{
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use DateTime;
|
||||
use App\Models\Document;
|
||||
use DateTime;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class RemoveOrphanedDocuments
|
||||
* Class RemoveOrphanedDocuments.
|
||||
*/
|
||||
class RemoveOrphanedDocuments extends Command
|
||||
{
|
||||
|
@ -1,14 +1,15 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Utils;
|
||||
use Illuminate\Console\Command;
|
||||
use Utils;
|
||||
|
||||
/**
|
||||
* Class ResetData
|
||||
* Class ResetData.
|
||||
*/
|
||||
class ResetData extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -23,7 +24,7 @@ class ResetData extends Command
|
||||
{
|
||||
$this->info(date('Y-m-d') . ' Running ResetData...');
|
||||
|
||||
if (!Utils::isNinjaDev()) {
|
||||
if (! Utils::isNinjaDev()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ class ResetInvoiceSchemaCounter extends Command
|
||||
|
||||
if (Carbon::now()->year > $invoiceYear || $force) {
|
||||
$accounts->transform(function ($a) {
|
||||
/** @var Account $a */
|
||||
/* @var Account $a */
|
||||
$a->invoice_number_counter = 1;
|
||||
$a->update();
|
||||
});
|
||||
|
@ -1,14 +1,16 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
use DateTime;
|
||||
use Illuminate\Console\Command;
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Services\PaymentService;
|
||||
use App\Models\Invoice;
|
||||
use DateTime;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class SendRecurringInvoices
|
||||
* Class SendRecurringInvoices.
|
||||
*/
|
||||
class SendRecurringInvoices extends Command
|
||||
{
|
||||
@ -39,9 +41,10 @@ class SendRecurringInvoices extends Command
|
||||
|
||||
/**
|
||||
* SendRecurringInvoices constructor.
|
||||
* @param Mailer $mailer
|
||||
*
|
||||
* @param Mailer $mailer
|
||||
* @param InvoiceRepository $invoiceRepo
|
||||
* @param PaymentService $paymentService
|
||||
* @param PaymentService $paymentService
|
||||
*/
|
||||
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, PaymentService $paymentService)
|
||||
{
|
||||
@ -74,7 +77,7 @@ class SendRecurringInvoices extends Command
|
||||
$recurInvoice->account->loadLocalizationSettings($recurInvoice->client);
|
||||
$invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice);
|
||||
|
||||
if ($invoice && !$invoice->isPaid()) {
|
||||
if ($invoice && ! $invoice->isPaid()) {
|
||||
$this->info('Sending Invoice');
|
||||
$this->mailer->sendInvoice($invoice);
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class SendReminders
|
||||
* Class SendReminders.
|
||||
*/
|
||||
class SendReminders extends Command
|
||||
{
|
||||
@ -38,7 +40,8 @@ class SendReminders extends Command
|
||||
|
||||
/**
|
||||
* SendReminders constructor.
|
||||
* @param Mailer $mailer
|
||||
*
|
||||
* @param Mailer $mailer
|
||||
* @param InvoiceRepository $invoiceRepo
|
||||
* @param accountRepository $accountRepo
|
||||
*/
|
||||
@ -60,7 +63,7 @@ class SendReminders extends Command
|
||||
|
||||
/** @var \App\Models\Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
if (!$account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) {
|
||||
if (! $account->hasFeature(FEATURE_EMAIL_TEMPLATES_REMINDERS)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Utils;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Company;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use Illuminate\Console\Command;
|
||||
use Utils;
|
||||
|
||||
/**
|
||||
* Class SendRenewalInvoices
|
||||
* Class SendRenewalInvoices.
|
||||
*/
|
||||
class SendRenewalInvoices extends Command
|
||||
{
|
||||
@ -34,7 +36,7 @@ class SendRenewalInvoices extends Command
|
||||
/**
|
||||
* SendRenewalInvoices constructor.
|
||||
*
|
||||
* @param Mailer $mailer
|
||||
* @param Mailer $mailer
|
||||
* @param AccountRepository $repo
|
||||
*/
|
||||
public function __construct(Mailer $mailer, AccountRepository $repo)
|
||||
@ -56,7 +58,7 @@ class SendRenewalInvoices extends Command
|
||||
$this->info(count($companies).' companies found renewing in 10 days');
|
||||
|
||||
foreach ($companies as $company) {
|
||||
if (!count($company->accounts)) {
|
||||
if (! count($company->accounts)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -74,7 +76,7 @@ class SendRenewalInvoices extends Command
|
||||
$plan['price'] = min($company->pending_plan_price, Utils::getPlanPrice($plan));
|
||||
}
|
||||
|
||||
if ($plan['plan'] == PLAN_FREE || !$plan['plan'] || !$plan['term'] || !$plan['price']) {
|
||||
if ($plan['plan'] == PLAN_FREE || ! $plan['plan'] || ! $plan['term'] || ! $plan['price']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Console\Commands;
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\BankAccountService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* Class TestOFX
|
||||
* Class TestOFX.
|
||||
*/
|
||||
class TestOFX extends Command
|
||||
{
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php namespace App\Console;
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Utils;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
use Utils;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
@ -30,7 +32,8 @@ class Kernel extends ConsoleKernel
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (!defined('APP_NAME')) {
|
||||
if (! defined('APP_NAME')) {
|
||||
define('APP_NAME', env('APP_NAME', 'Invoice Ninja'));
|
||||
define('CONTACT_EMAIL', env('MAIL_FROM_ADDRESS', env('MAIL_USERNAME')));
|
||||
define('CONTACT_NAME', env('MAIL_FROM_NAME'));
|
||||
@ -128,7 +128,6 @@ if (!defined('APP_NAME')) {
|
||||
define('ACTIVITY_TYPE_RESTORE_TASK', 46);
|
||||
define('ACTIVITY_TYPE_UPDATE_EXPENSE', 47);
|
||||
|
||||
|
||||
define('DEFAULT_INVOICE_NUMBER', '0001');
|
||||
define('RECENTLY_VIEWED_LIMIT', 20);
|
||||
define('LOGGED_ERROR_LIMIT', 100);
|
||||
@ -140,13 +139,13 @@ if (!defined('APP_NAME')) {
|
||||
define('MAX_LOGO_FILE_SIZE', 200); // KB
|
||||
define('MAX_FAILED_LOGINS', 10);
|
||||
define('MAX_INVOICE_ITEMS', env('MAX_INVOICE_ITEMS', 100));
|
||||
define('MAX_DOCUMENT_SIZE', env('MAX_DOCUMENT_SIZE', 10000));// KB
|
||||
define('MAX_EMAIL_DOCUMENTS_SIZE', env('MAX_EMAIL_DOCUMENTS_SIZE', 10000));// Total KB
|
||||
define('MAX_ZIP_DOCUMENTS_SIZE', env('MAX_EMAIL_DOCUMENTS_SIZE', 30000));// Total KB (uncompressed)
|
||||
define('DOCUMENT_PREVIEW_SIZE', env('DOCUMENT_PREVIEW_SIZE', 300));// pixels
|
||||
define('MAX_DOCUMENT_SIZE', env('MAX_DOCUMENT_SIZE', 10000)); // KB
|
||||
define('MAX_EMAIL_DOCUMENTS_SIZE', env('MAX_EMAIL_DOCUMENTS_SIZE', 10000)); // Total KB
|
||||
define('MAX_ZIP_DOCUMENTS_SIZE', env('MAX_EMAIL_DOCUMENTS_SIZE', 30000)); // Total KB (uncompressed)
|
||||
define('DOCUMENT_PREVIEW_SIZE', env('DOCUMENT_PREVIEW_SIZE', 300)); // pixels
|
||||
define('DEFAULT_FONT_SIZE', 9);
|
||||
define('DEFAULT_HEADER_FONT', 1);// Roboto
|
||||
define('DEFAULT_BODY_FONT', 1);// Roboto
|
||||
define('DEFAULT_HEADER_FONT', 1); // Roboto
|
||||
define('DEFAULT_BODY_FONT', 1); // Roboto
|
||||
define('DEFAULT_SEND_RECURRING_HOUR', 8);
|
||||
|
||||
define('IMPORT_CSV', 'CSV');
|
||||
@ -241,7 +240,6 @@ if (!defined('APP_NAME')) {
|
||||
define('RESULT_SUCCESS', 'success');
|
||||
define('RESULT_FAILURE', 'failure');
|
||||
|
||||
|
||||
define('PAYMENT_LIBRARY_OMNIPAY', 1);
|
||||
define('PAYMENT_LIBRARY_PHP_PAYMENTS', 2);
|
||||
|
||||
@ -469,7 +467,7 @@ if (!defined('APP_NAME')) {
|
||||
define('FEATURE_DOCUMENTS', 'documents');
|
||||
|
||||
// No Trial allowed
|
||||
define('FEATURE_USERS', 'users');// Grandfathered for old Pro users
|
||||
define('FEATURE_USERS', 'users'); // Grandfathered for old Pro users
|
||||
define('FEATURE_USER_PERMISSIONS', 'user_permissions');
|
||||
|
||||
// Pro users who started paying on or before this date will be able to manage users
|
||||
@ -514,7 +512,7 @@ if (!defined('APP_NAME')) {
|
||||
2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'],
|
||||
4 => ['card' => 'images/credit_cards/Test-AmericanExpress-Icon.png', 'text' => 'American Express'],
|
||||
8 => ['card' => 'images/credit_cards/Test-Diners-Icon.png', 'text' => 'Diners'],
|
||||
16 => ['card' => 'images/credit_cards/Test-Discover-Icon.png', 'text' => 'Discover']
|
||||
16 => ['card' => 'images/credit_cards/Test-Discover-Icon.png', 'text' => 'Discover'],
|
||||
];
|
||||
define('CREDIT_CARDS', serialize($creditCards));
|
||||
|
||||
@ -539,7 +537,6 @@ if (!defined('APP_NAME')) {
|
||||
];
|
||||
define('CACHED_TABLES', serialize($cachedTables));
|
||||
|
||||
|
||||
// TODO remove these translation functions
|
||||
function uctrans($text)
|
||||
{
|
||||
@ -556,6 +553,7 @@ if (!defined('APP_NAME')) {
|
||||
} else {
|
||||
$string = trans($text);
|
||||
$english = trans($text, [], 'en');
|
||||
|
||||
return $string != $english ? $string : '';
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Constants;
|
||||
<?php
|
||||
|
||||
namespace App\Constants;
|
||||
|
||||
class Domain
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Client;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ClientWasArchived
|
||||
* Class ClientWasArchived.
|
||||
*/
|
||||
class ClientWasArchived extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Client;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ClientWasCreated
|
||||
* Class ClientWasCreated.
|
||||
*/
|
||||
class ClientWasCreated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Client;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ClientWasDeleted
|
||||
* Class ClientWasDeleted.
|
||||
*/
|
||||
class ClientWasDeleted extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Client;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ClientWasRestored
|
||||
* Class ClientWasRestored.
|
||||
*/
|
||||
class ClientWasRestored extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Client;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ClientWasUpdated
|
||||
* Class ClientWasUpdated.
|
||||
*/
|
||||
class ClientWasUpdated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Credit;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class CreditWasArchived
|
||||
* Class CreditWasArchived.
|
||||
*/
|
||||
class CreditWasArchived extends Event
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Credit;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Credit;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class CreditWasDeleted
|
||||
* Class CreditWasDeleted.
|
||||
*/
|
||||
class CreditWasDeleted extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Credit;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class CreditWasRestored
|
||||
* Class CreditWasRestored.
|
||||
*/
|
||||
class CreditWasRestored extends Event
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
abstract class Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Expense;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ExpenseWasArchived
|
||||
* Class ExpenseWasArchived.
|
||||
*/
|
||||
class ExpenseWasArchived extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Expense;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ExpenseWasCreated
|
||||
* Class ExpenseWasCreated.
|
||||
*/
|
||||
class ExpenseWasCreated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Expense;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ExpenseWasDeleted
|
||||
* Class ExpenseWasDeleted.
|
||||
*/
|
||||
class ExpenseWasDeleted extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Expense;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ExpenseWasRestored
|
||||
* Class ExpenseWasRestored.
|
||||
*/
|
||||
class ExpenseWasRestored extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Expense;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class ExpenseWasUpdated
|
||||
* Class ExpenseWasUpdated.
|
||||
*/
|
||||
class ExpenseWasUpdated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invitation;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceInvitationWasEmailed
|
||||
* Class InvoiceInvitationWasEmailed.
|
||||
*/
|
||||
class InvoiceInvitationWasEmailed extends Event
|
||||
{
|
||||
@ -16,7 +18,7 @@ class InvoiceInvitationWasEmailed extends Event
|
||||
public $invitation;
|
||||
|
||||
/**
|
||||
* @var String
|
||||
* @var string
|
||||
*/
|
||||
public $notes;
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceInvitationWasViewed
|
||||
* Class InvoiceInvitationWasViewed.
|
||||
*/
|
||||
class InvoiceInvitationWasViewed extends Event
|
||||
{
|
||||
@ -24,7 +26,7 @@ class InvoiceInvitationWasViewed extends Event
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param Invoice $invoice
|
||||
* @param Invoice $invoice
|
||||
* @param Invitation $invitation
|
||||
*/
|
||||
public function __construct(Invoice $invoice, Invitation $invitation)
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasArchived
|
||||
* Class InvoiceWasArchived.
|
||||
*/
|
||||
class InvoiceWasArchived extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasCreated
|
||||
* Class InvoiceWasCreated.
|
||||
*/
|
||||
class InvoiceWasCreated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasDeleted
|
||||
* Class InvoiceWasDeleted.
|
||||
*/
|
||||
class InvoiceWasDeleted extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasEmailed
|
||||
* Class InvoiceWasEmailed.
|
||||
*/
|
||||
class InvoiceWasEmailed extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasRestored
|
||||
* Class InvoiceWasRestored.
|
||||
*/
|
||||
class InvoiceWasRestored extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceWasUpdated
|
||||
* Class InvoiceWasUpdated.
|
||||
*/
|
||||
class InvoiceWasUpdated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PaymentCompleted
|
||||
* Class PaymentCompleted.
|
||||
*/
|
||||
class PaymentCompleted extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PaymentFailed
|
||||
* Class PaymentFailed.
|
||||
*/
|
||||
class PaymentFailed extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PaymentWasArchived
|
||||
* Class PaymentWasArchived.
|
||||
*/
|
||||
class PaymentWasArchived extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PaymentWasCreated
|
||||
* Class PaymentWasCreated.
|
||||
*/
|
||||
class PaymentWasCreated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PaymentWasRefunded
|
||||
* Class PaymentWasRefunded.
|
||||
*/
|
||||
class PaymentWasRefunded extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PaymentWasRestored
|
||||
* Class PaymentWasRestored.
|
||||
*/
|
||||
class PaymentWasRestored extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PaymentWasVoided
|
||||
* Class PaymentWasVoided.
|
||||
*/
|
||||
class PaymentWasVoided extends Event
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Invoice;
|
||||
@ -19,7 +21,7 @@ class QuoteInvitationWasApproved extends Event
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param $quote
|
||||
* @param Invoice $invoice
|
||||
* @param Invoice $invoice
|
||||
* @param Invitation $invitation
|
||||
*/
|
||||
public function __construct(Invoice $quote, Invitation $invitation)
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invitation;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class QuoteInvitationWasEmailed
|
||||
* Class QuoteInvitationWasEmailed.
|
||||
*/
|
||||
class QuoteInvitationWasEmailed extends Event
|
||||
{
|
||||
@ -16,7 +18,7 @@ class QuoteInvitationWasEmailed extends Event
|
||||
public $invitation;
|
||||
|
||||
/**
|
||||
* @var String
|
||||
* @var string
|
||||
*/
|
||||
public $notes;
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invitation;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class QuoteInvitationWasViewed
|
||||
* Class QuoteInvitationWasViewed.
|
||||
*/
|
||||
class QuoteInvitationWasViewed extends Event
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class QuoteWasCreated
|
||||
* Class QuoteWasCreated.
|
||||
*/
|
||||
class QuoteWasCreated extends Event
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class QuoteWasDeleted
|
||||
* Class QuoteWasDeleted.
|
||||
*/
|
||||
class QuoteWasDeleted extends Event
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class QuoteWasEmailed
|
||||
* Class QuoteWasEmailed.
|
||||
*/
|
||||
class QuoteWasEmailed extends Event
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class QuoteWasRestored
|
||||
* Class QuoteWasRestored.
|
||||
*/
|
||||
class QuoteWasRestored extends Event
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class QuoteWasUpdated
|
||||
* Class QuoteWasUpdated.
|
||||
*/
|
||||
class QuoteWasUpdated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Task;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class TaskWasArchived
|
||||
* Class TaskWasArchived.
|
||||
*/
|
||||
class TaskWasArchived extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Task;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class TaskWasCreated
|
||||
* Class TaskWasCreated.
|
||||
*/
|
||||
class TaskWasCreated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Task;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class TaskWasDeleted
|
||||
* Class TaskWasDeleted.
|
||||
*/
|
||||
class TaskWasDeleted extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Task;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class TaskWasRestored
|
||||
* Class TaskWasRestored.
|
||||
*/
|
||||
class TaskWasRestored extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Task;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class TaskWasUpdated
|
||||
* Class TaskWasUpdated.
|
||||
*/
|
||||
class TaskWasUpdated extends Event
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UserLoggedIn
|
||||
* Class UserLoggedIn.
|
||||
*/
|
||||
class UserLoggedIn extends Event
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class UserSignedUp
|
||||
* Class UserSignedUp.
|
||||
*/
|
||||
class UserSignedUp extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Vendor;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class VendorWasArchived
|
||||
* Class VendorWasArchived.
|
||||
*/
|
||||
class VendorWasArchived extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Vendor;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class VendorWasCreated
|
||||
* Class VendorWasCreated.
|
||||
*/
|
||||
class VendorWasCreated extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Vendor;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class VendorWasDeleted
|
||||
* Class VendorWasDeleted.
|
||||
*/
|
||||
class VendorWasDeleted extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Vendor;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class VendorWasRestored
|
||||
* Class VendorWasRestored.
|
||||
*/
|
||||
class VendorWasRestored extends Event
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Vendor;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class VendorWasUpdated
|
||||
* Class VendorWasUpdated.
|
||||
*/
|
||||
class VendorWasUpdated extends Event
|
||||
{
|
||||
|
@ -1,24 +1,25 @@
|
||||
<?php namespace App\Exceptions;
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Redirect;
|
||||
use Utils;
|
||||
use Exception;
|
||||
use Crawler;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\Exception\HttpResponseException;
|
||||
use Exception;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Foundation\Validation\ValidationException;
|
||||
use Illuminate\Http\Exception\HttpResponseException;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Redirect;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Illuminate\Foundation\Validation\ValidationException;
|
||||
use Utils;
|
||||
|
||||
/**
|
||||
* Class Handler
|
||||
* Class Handler.
|
||||
*/
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
@ -36,7 +37,8 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return bool|void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
@ -52,6 +54,7 @@ class Handler extends ExceptionHandler
|
||||
|
||||
if (Utils::isNinja() && ! Utils::isTravis()) {
|
||||
Utils::logError(Utils::getErrorString($e));
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return parent::report($e);
|
||||
@ -61,8 +64,9 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
@ -78,7 +82,7 @@ class Handler extends ExceptionHandler
|
||||
->back()
|
||||
->withInput($request->except('password', '_token'))
|
||||
->with([
|
||||
'warning' => trans('texts.token_expired')
|
||||
'warning' => trans('texts.token_expired'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -90,7 +94,7 @@ class Handler extends ExceptionHandler
|
||||
if ($request->header('X-Ninja-Token') != '') {
|
||||
//API request which has hit a route which does not exist
|
||||
|
||||
$error['error'] = ['message'=>'Route does not exist'];
|
||||
$error['error'] = ['message' => 'Route does not exist'];
|
||||
$error = json_encode($error, JSON_PRETTY_PRINT);
|
||||
$headers = Utils::getApiHeaders();
|
||||
|
||||
@ -103,7 +107,7 @@ class Handler extends ExceptionHandler
|
||||
if ($request->header('X-Ninja-Token') != '') {
|
||||
//API request which produces 500 error
|
||||
|
||||
$error['error'] = ['message'=>'Internal Server Error'];
|
||||
$error['error'] = ['message' => 'Internal Server Error'];
|
||||
$error = json_encode($error, JSON_PRETTY_PRINT);
|
||||
$headers = Utils::getApiHeaders();
|
||||
|
||||
@ -116,9 +120,9 @@ class Handler extends ExceptionHandler
|
||||
|
||||
// In production, except for maintenance mode, we'll show a custom error screen
|
||||
if (Utils::isNinjaProd()
|
||||
&& !Utils::isDownForMaintenance()
|
||||
&& !($e instanceof HttpResponseException)
|
||||
&& !($e instanceof ValidationException)) {
|
||||
&& ! Utils::isDownForMaintenance()
|
||||
&& ! ($e instanceof HttpResponseException)
|
||||
&& ! ($e instanceof ValidationException)) {
|
||||
$data = [
|
||||
'error' => get_class($e),
|
||||
'hideHeader' => true,
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?php namespace App\Handlers;
|
||||
<?php
|
||||
|
||||
namespace App\Handlers;
|
||||
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
|
||||
class InvoiceEventHandler
|
||||
{
|
||||
|
@ -1,20 +1,22 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Utils;
|
||||
use Response;
|
||||
use Cache;
|
||||
use Socialite;
|
||||
use Exception;
|
||||
use App\Services\AuthService;
|
||||
use App\Models\Account;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Ninja\Transformers\AccountTransformer;
|
||||
use App\Ninja\Transformers\UserAccountTransformer;
|
||||
use App\Events\UserSignedUp;
|
||||
use App\Http\Requests\RegisterRequest;
|
||||
use App\Http\Requests\UpdateAccountRequest;
|
||||
use App\Models\Account;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Ninja\Transformers\AccountTransformer;
|
||||
use App\Ninja\Transformers\UserAccountTransformer;
|
||||
use App\Services\AuthService;
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Response;
|
||||
use Socialite;
|
||||
use Utils;
|
||||
|
||||
class AccountApiController extends BaseAPIController
|
||||
{
|
||||
@ -34,7 +36,7 @@ class AccountApiController extends BaseAPIController
|
||||
if (hash_equals(env(API_SECRET), $request->api_secret)) {
|
||||
return Response::make(RESULT_SUCCESS, 200, $headers);
|
||||
} else {
|
||||
return $this->errorResponse(['message'=>'API Secret does not match .env variable'], 400);
|
||||
return $this->errorResponse(['message' => 'API Secret does not match .env variable'], 400);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +57,8 @@ class AccountApiController extends BaseAPIController
|
||||
return $this->processLogin($request);
|
||||
} else {
|
||||
sleep(ERROR_DELAY);
|
||||
return $this->errorResponse(['message'=>'Invalid credentials'], 401);
|
||||
|
||||
return $this->errorResponse(['message' => 'Invalid credentials'], 401);
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,8 +122,7 @@ class AccountApiController extends BaseAPIController
|
||||
//scan if this user has a token already registered (tokens can change, so we need to use the users email as key)
|
||||
$devices = json_decode($account->devices, true);
|
||||
|
||||
|
||||
for ($x=0; $x<count($devices); $x++) {
|
||||
for ($x = 0; $x < count($devices); $x++) {
|
||||
if ($devices[$x]['email'] == Auth::user()->username) {
|
||||
$devices[$x]['token'] = $request->token; //update
|
||||
$account->devices = json_encode($devices);
|
||||
@ -158,10 +160,10 @@ class AccountApiController extends BaseAPIController
|
||||
$devices = json_decode($account->devices, true);
|
||||
|
||||
if (count($devices) < 1) {
|
||||
return $this->errorResponse(['message'=>'No registered devices.'], 400);
|
||||
return $this->errorResponse(['message' => 'No registered devices.'], 400);
|
||||
}
|
||||
|
||||
for ($x=0; $x<count($devices); $x++) {
|
||||
for ($x = 0; $x < count($devices); $x++) {
|
||||
if ($devices[$x]['email'] == Auth::user()->username) {
|
||||
$newDevice = [
|
||||
'token' => $devices[$x]['token'],
|
||||
@ -202,9 +204,11 @@ class AccountApiController extends BaseAPIController
|
||||
|
||||
if ($user) {
|
||||
Auth::login($user);
|
||||
|
||||
return $this->processLogin($request);
|
||||
} else {
|
||||
sleep(ERROR_DELAY);
|
||||
|
||||
return $this->errorResponse(['message' => 'Invalid credentials'], 401);
|
||||
}
|
||||
}
|
||||
|
@ -1,49 +1,51 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\UserSettingsChanged;
|
||||
use App\Events\UserSignedUp;
|
||||
use App\Http\Requests\SaveClientPortalSettings;
|
||||
use App\Http\Requests\SaveEmailSettings;
|
||||
use App\Http\Requests\UpdateAccountRequest;
|
||||
use App\Models\Account;
|
||||
use App\Models\AccountGateway;
|
||||
use App\Models\AccountGatewaySettings;
|
||||
use App\Models\Affiliate;
|
||||
use App\Models\Document;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceDesign;
|
||||
use App\Models\License;
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Models\Product;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\User;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Ninja\Repositories\ReferralRepository;
|
||||
use App\Services\AuthService;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\TemplateService;
|
||||
use Auth;
|
||||
use Cache;
|
||||
use File;
|
||||
use Image;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Request;
|
||||
use Response;
|
||||
use Session;
|
||||
use stdClass;
|
||||
use URL;
|
||||
use Utils;
|
||||
|
||||
use Validator;
|
||||
use View;
|
||||
use URL;
|
||||
use stdClass;
|
||||
use Cache;
|
||||
use Response;
|
||||
use Request;
|
||||
use App\Models\Affiliate;
|
||||
use App\Models\License;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\User;
|
||||
use App\Models\Account;
|
||||
use App\Models\Document;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\InvoiceDesign;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\Product;
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Ninja\Repositories\ReferralRepository;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
use App\Events\UserSignedUp;
|
||||
use App\Events\UserSettingsChanged;
|
||||
use App\Services\AuthService;
|
||||
use App\Services\PaymentService;
|
||||
use App\Http\Requests\UpdateAccountRequest;
|
||||
|
||||
use App\Http\Requests\SaveClientPortalSettings;
|
||||
use App\Http\Requests\SaveEmailSettings;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
* Class AccountController.
|
||||
*/
|
||||
class AccountController extends BaseController
|
||||
{
|
||||
@ -75,11 +77,11 @@ class AccountController extends BaseController
|
||||
/**
|
||||
* AccountController constructor.
|
||||
*
|
||||
* @param AccountRepository $accountRepo
|
||||
* @param UserMailer $userMailer
|
||||
* @param ContactMailer $contactMailer
|
||||
* @param AccountRepository $accountRepo
|
||||
* @param UserMailer $userMailer
|
||||
* @param ContactMailer $contactMailer
|
||||
* @param ReferralRepository $referralRepository
|
||||
* @param PaymentService $paymentService
|
||||
* @param PaymentService $paymentService
|
||||
*/
|
||||
public function __construct(
|
||||
AccountRepository $accountRepo,
|
||||
@ -102,7 +104,7 @@ class AccountController extends BaseController
|
||||
{
|
||||
$demoAccountId = Utils::getDemoAccountId();
|
||||
|
||||
if (!$demoAccountId) {
|
||||
if (! $demoAccountId) {
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
@ -127,11 +129,11 @@ class AccountController extends BaseController
|
||||
return Redirect::to('invoices/create');
|
||||
}
|
||||
|
||||
if (!Utils::isNinja() && (Account::count() > 0 && !$prevUserId)) {
|
||||
if (! Utils::isNinja() && (Account::count() > 0 && ! $prevUserId)) {
|
||||
return Redirect::to('/login');
|
||||
}
|
||||
|
||||
if ($guestKey && !$prevUserId) {
|
||||
if ($guestKey && ! $prevUserId) {
|
||||
$user = User::where('password', '=', $guestKey)->first();
|
||||
|
||||
if ($user && $user->registered) {
|
||||
@ -139,7 +141,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
if (! $user) {
|
||||
$account = $this->accountRepo->create();
|
||||
$user = $account->users()->first();
|
||||
|
||||
@ -184,7 +186,7 @@ class AccountController extends BaseController
|
||||
$newPlan['price'] = Utils::getPlanPrice($newPlan);
|
||||
$credit = 0;
|
||||
|
||||
if (!empty($planDetails['started']) && $plan == PLAN_FREE) {
|
||||
if (! empty($planDetails['started']) && $plan == PLAN_FREE) {
|
||||
// Downgrade
|
||||
$refund_deadline = clone $planDetails['started'];
|
||||
$refund_deadline->modify('+30 days');
|
||||
@ -203,7 +205,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
|
||||
$hasPaid = false;
|
||||
if (!empty($planDetails['paid']) && $plan != PLAN_FREE) {
|
||||
if (! empty($planDetails['paid']) && $plan != PLAN_FREE) {
|
||||
$hasPaid = true;
|
||||
$time_used = $planDetails['paid']->diff(date_create());
|
||||
$days_used = $time_used->days;
|
||||
@ -243,10 +245,10 @@ class AccountController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $entityType
|
||||
* @param $visible
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setEntityFilter($entityType, $filter = '')
|
||||
@ -267,8 +269,8 @@ class AccountController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
Session::put("entity_state_filter:{$entityType}", join(',', $stateFilter));
|
||||
Session::put("entity_status_filter:{$entityType}", join(',', $statusFilter));
|
||||
Session::put("entity_state_filter:{$entityType}", implode(',', $stateFilter));
|
||||
Session::put("entity_status_filter:{$entityType}", implode(',', $statusFilter));
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
@ -285,6 +287,7 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param bool $section
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function showSection($section = false)
|
||||
@ -293,7 +296,7 @@ class AccountController extends BaseController
|
||||
return Redirect::to('/settings/user_details');
|
||||
}
|
||||
|
||||
if (!$section) {
|
||||
if (! $section) {
|
||||
return Redirect::to('/settings/'.ACCOUNT_COMPANY_DETAILS, 301);
|
||||
}
|
||||
|
||||
@ -362,7 +365,7 @@ class AccountController extends BaseController
|
||||
$account = Auth::user()->account;
|
||||
$recurringHours = [];
|
||||
|
||||
for ($i = 0; $i<24; $i++) {
|
||||
for ($i = 0; $i < 24; $i++) {
|
||||
if ($account->military_time) {
|
||||
$format = 'H:i';
|
||||
} else {
|
||||
@ -488,17 +491,17 @@ class AccountController extends BaseController
|
||||
return Redirect::to('gateways/create');
|
||||
} else {
|
||||
$tokenBillingOptions = [];
|
||||
for ($i=1; $i<=4; $i++) {
|
||||
for ($i = 1; $i <= 4; $i++) {
|
||||
$tokenBillingOptions[$i] = trans("texts.token_billing_{$i}");
|
||||
}
|
||||
|
||||
return View::make('accounts.payments', [
|
||||
'showAdd' => $count < count(Gateway::$alternate) + 1,
|
||||
'title' => trans('texts.online_payments'),
|
||||
'showAdd' => $count < count(Gateway::$alternate) + 1,
|
||||
'title' => trans('texts.online_payments'),
|
||||
'tokenBillingOptions' => $tokenBillingOptions,
|
||||
'currency' => Utils::getFromCache(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY),
|
||||
'currency' => Utils::getFromCache(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY),
|
||||
'currencies'),
|
||||
'account' => $account,
|
||||
'account' => $account,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -546,6 +549,7 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param $section
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
private function showInvoiceDesign($section)
|
||||
@ -608,7 +612,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
|
||||
if ($section == ACCOUNT_CUSTOMIZE_DESIGN) {
|
||||
$data['customDesign'] = ($account->custom_design && !$design) ? $account->custom_design : $design;
|
||||
$data['customDesign'] = ($account->custom_design && ! $design) ? $account->custom_design : $design;
|
||||
|
||||
// sample invoice to help determine variables
|
||||
$invoice = Invoice::scope()
|
||||
@ -651,7 +655,7 @@ class AccountController extends BaseController
|
||||
GATEWAY_TYPE_BANK_TRANSFER,
|
||||
GATEWAY_TYPE_PAYPAL,
|
||||
GATEWAY_TYPE_BITCOIN,
|
||||
GATEWAY_TYPE_DWOLLA
|
||||
GATEWAY_TYPE_DWOLLA,
|
||||
];
|
||||
$options = [];
|
||||
foreach ($types as $type) {
|
||||
@ -702,34 +706,35 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param $section
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function doSection($section)
|
||||
{
|
||||
if ($section === ACCOUNT_LOCALIZATION) {
|
||||
return AccountController::saveLocalization();
|
||||
return self::saveLocalization();
|
||||
} elseif ($section == ACCOUNT_PAYMENTS) {
|
||||
return self::saveOnlinePayments();
|
||||
} elseif ($section === ACCOUNT_NOTIFICATIONS) {
|
||||
return AccountController::saveNotifications();
|
||||
return self::saveNotifications();
|
||||
} elseif ($section === ACCOUNT_EXPORT) {
|
||||
return AccountController::export();
|
||||
return self::export();
|
||||
} elseif ($section === ACCOUNT_INVOICE_SETTINGS) {
|
||||
return AccountController::saveInvoiceSettings();
|
||||
return self::saveInvoiceSettings();
|
||||
} elseif ($section === ACCOUNT_INVOICE_DESIGN) {
|
||||
return AccountController::saveInvoiceDesign();
|
||||
return self::saveInvoiceDesign();
|
||||
} elseif ($section === ACCOUNT_CUSTOMIZE_DESIGN) {
|
||||
return AccountController::saveCustomizeDesign();
|
||||
return self::saveCustomizeDesign();
|
||||
} elseif ($section === ACCOUNT_TEMPLATES_AND_REMINDERS) {
|
||||
return AccountController::saveEmailTemplates();
|
||||
return self::saveEmailTemplates();
|
||||
} elseif ($section === ACCOUNT_PRODUCTS) {
|
||||
return AccountController::saveProducts();
|
||||
return self::saveProducts();
|
||||
} elseif ($section === ACCOUNT_TAX_RATES) {
|
||||
return AccountController::saveTaxRates();
|
||||
return self::saveTaxRates();
|
||||
} elseif ($section === ACCOUNT_PAYMENT_TERMS) {
|
||||
return AccountController::savePaymetTerms();
|
||||
return self::savePaymetTerms();
|
||||
} elseif ($section === ACCOUNT_MANAGEMENT) {
|
||||
return AccountController::saveAccountManagement();
|
||||
return self::saveAccountManagement();
|
||||
}
|
||||
}
|
||||
|
||||
@ -752,6 +757,7 @@ class AccountController extends BaseController
|
||||
if ($font->google_font) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $font->id == $account->header_font_id || $font->id == $account->body_font_id;
|
||||
});
|
||||
if ($account->live_preview && count($fonts)) {
|
||||
@ -934,7 +940,7 @@ class AccountController extends BaseController
|
||||
$account->recurring_hour = Input::get('recurring_hour');
|
||||
}
|
||||
|
||||
if (!$account->share_counter) {
|
||||
if (! $account->share_counter) {
|
||||
$account->quote_number_counter = Input::get('quote_number_counter');
|
||||
}
|
||||
|
||||
@ -948,7 +954,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
if (!$account->share_counter
|
||||
if (! $account->share_counter
|
||||
&& $account->invoice_number_prefix == $account->quote_number_prefix
|
||||
&& $account->invoice_number_pattern == $account->quote_number_pattern) {
|
||||
Session::flash('error', trans('texts.invalid_counter'));
|
||||
@ -1018,6 +1024,7 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param UpdateAccountRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function updateDetails(UpdateAccountRequest $request)
|
||||
@ -1035,13 +1042,13 @@ class AccountController extends BaseController
|
||||
}
|
||||
|
||||
$extension = strtolower($uploaded->getClientOriginalExtension());
|
||||
if (empty(Document::$types[$extension]) && !empty(Document::$extraExtensions[$extension])) {
|
||||
if (empty(Document::$types[$extension]) && ! empty(Document::$extraExtensions[$extension])) {
|
||||
$documentType = Document::$extraExtensions[$extension];
|
||||
} else {
|
||||
$documentType = $extension;
|
||||
}
|
||||
|
||||
if (!in_array($documentType, ['jpeg', 'png', 'gif'])) {
|
||||
if (! in_array($documentType, ['jpeg', 'png', 'gif'])) {
|
||||
Session::flash('warning', 'Unsupported file type');
|
||||
} else {
|
||||
$documentTypeData = Document::$types[$documentType];
|
||||
@ -1049,7 +1056,7 @@ class AccountController extends BaseController
|
||||
$filePath = $uploaded->path();
|
||||
$size = filesize($filePath);
|
||||
|
||||
if ($size/1000 > MAX_DOCUMENT_SIZE) {
|
||||
if ($size / 1000 > MAX_DOCUMENT_SIZE) {
|
||||
Session::flash('warning', 'File too large');
|
||||
} else {
|
||||
if ($documentType != 'gif') {
|
||||
@ -1070,7 +1077,7 @@ class AccountController extends BaseController
|
||||
$account->logo_size = strlen($imageStr);
|
||||
} else {
|
||||
$stream = fopen($filePath, 'r');
|
||||
$disk->getDriver()->putStream($account->logo, $stream, ['mimetype'=>$documentTypeData['mime']]);
|
||||
$disk->getDriver()->putStream($account->logo, $stream, ['mimetype' => $documentTypeData['mime']]);
|
||||
fclose($stream);
|
||||
}
|
||||
} else {
|
||||
@ -1134,7 +1141,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
|
||||
if (Utils::isNinja()) {
|
||||
if (Input::get('referral_code') && !$user->referral_code) {
|
||||
if (Input::get('referral_code') && ! $user->referral_code) {
|
||||
$user->referral_code = $this->accountRepo->getReferralCode();
|
||||
}
|
||||
}
|
||||
@ -1307,7 +1314,7 @@ class AccountController extends BaseController
|
||||
$affiliate = Affiliate::where('affiliate_key', '=', SELF_HOST_AFFILIATE_KEY)->first();
|
||||
$email = trim(Input::get('email'));
|
||||
|
||||
if (!$email || $email == TEST_USERNAME) {
|
||||
if (! $email || $email == TEST_USERNAME) {
|
||||
return RESULT_FAILURE;
|
||||
}
|
||||
|
||||
@ -1380,6 +1387,7 @@ class AccountController extends BaseController
|
||||
/**
|
||||
* @param $section
|
||||
* @param bool $subSection
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function redirectLegacy($section, $subSection = false)
|
||||
@ -1395,7 +1403,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array($section, array_merge(Account::$basicSettings, Account::$advancedSettings))) {
|
||||
if (! in_array($section, array_merge(Account::$basicSettings, Account::$advancedSettings))) {
|
||||
$section = ACCOUNT_COMPANY_DETAILS;
|
||||
}
|
||||
|
||||
@ -1404,6 +1412,7 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param TemplateService $templateService
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function previewEmail(TemplateService $templateService)
|
||||
@ -1429,7 +1438,7 @@ class AccountController extends BaseController
|
||||
'invitation' => $invitation,
|
||||
'link' => $invitation->getLink(),
|
||||
'client' => $invoice->client,
|
||||
'amount' => $invoice->amount
|
||||
'amount' => $invoice->amount,
|
||||
];
|
||||
|
||||
// create the email view
|
||||
|
@ -1,19 +1,21 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\AccountGateway;
|
||||
use App\Models\Gateway;
|
||||
use App\Services\AccountGatewayService;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use View;
|
||||
use Validator;
|
||||
use stdClass;
|
||||
use URL;
|
||||
use Utils;
|
||||
use Validator;
|
||||
use View;
|
||||
use WePay;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\Account;
|
||||
use App\Models\AccountGateway;
|
||||
use App\Services\AccountGatewayService;
|
||||
|
||||
class AccountGatewayController extends BaseController
|
||||
{
|
||||
@ -76,8 +78,7 @@ class AccountGatewayController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the form for account creation
|
||||
*
|
||||
* Displays the form for account creation.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@ -114,7 +115,7 @@ class AccountGatewayController extends BaseController
|
||||
{
|
||||
$selectedCards = $accountGateway ? $accountGateway->accepted_credit_cards : 0;
|
||||
$user = Auth::user();
|
||||
$account =$user->account;
|
||||
$account = $user->account;
|
||||
|
||||
$creditCardsArray = unserialize(CREDIT_CARDS);
|
||||
$creditCards = [];
|
||||
@ -148,11 +149,10 @@ class AccountGatewayController extends BaseController
|
||||
'config' => false,
|
||||
'gateways' => $gateways,
|
||||
'creditCardTypes' => $creditCards,
|
||||
'countGateways' => count($currentGateways)
|
||||
'countGateways' => count($currentGateways),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function bulk()
|
||||
{
|
||||
$action = Input::get('bulk_action');
|
||||
@ -165,8 +165,7 @@ class AccountGatewayController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores new account
|
||||
*
|
||||
* Stores new account.
|
||||
*/
|
||||
public function save($accountGatewayPublicId = false)
|
||||
{
|
||||
@ -190,7 +189,7 @@ class AccountGatewayController extends BaseController
|
||||
|
||||
if ($gatewayId != GATEWAY_WEPAY) {
|
||||
foreach ($fields as $field => $details) {
|
||||
if (!in_array($field, $optional)) {
|
||||
if (! in_array($field, $optional)) {
|
||||
if (strtolower($gateway->name) == 'beanstream') {
|
||||
if (in_array($field, ['merchant_id', 'passCode'])) {
|
||||
$rules[$gateway->id . '_' . $field] = 'required';
|
||||
@ -224,6 +223,7 @@ class AccountGatewayController extends BaseController
|
||||
->first();
|
||||
if ($accountGateway) {
|
||||
Session::flash('error', trans('texts.gateway_exists'));
|
||||
|
||||
return Redirect::to("gateways/{$accountGateway->public_id}/edit");
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ class AccountGatewayController extends BaseController
|
||||
$accountGateway->gateway_id = $gatewayId;
|
||||
|
||||
if ($gatewayId == GATEWAY_WEPAY) {
|
||||
if (!$this->setupWePay($accountGateway, $wepayResponse)) {
|
||||
if (! $this->setupWePay($accountGateway, $wepayResponse)) {
|
||||
return $wepayResponse;
|
||||
}
|
||||
$oldConfig = $accountGateway->getConfig();
|
||||
@ -247,7 +247,7 @@ class AccountGatewayController extends BaseController
|
||||
if ($oldConfig && $value && $value === str_repeat('*', strlen($value))) {
|
||||
$value = $oldConfig->$field;
|
||||
}
|
||||
if (!$value && ($field == 'testMode' || $field == 'developerMode')) {
|
||||
if (! $value && ($field == 'testMode' || $field == 'developerMode')) {
|
||||
// do nothing
|
||||
} elseif ($gatewayId == GATEWAY_CUSTOM) {
|
||||
$config->$field = strip_tags($value);
|
||||
@ -321,11 +321,13 @@ class AccountGatewayController extends BaseController
|
||||
if ($accountGatewayPublicId) {
|
||||
$message = trans('texts.updated_gateway');
|
||||
Session::flash('message', $message);
|
||||
|
||||
return Redirect::to("gateways/{$accountGateway->public_id}/edit");
|
||||
} else {
|
||||
$message = trans('texts.created_gateway');
|
||||
Session::flash('message', $message);
|
||||
return Redirect::to("/settings/online_payments");
|
||||
|
||||
return Redirect::to('/settings/online_payments');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -350,8 +352,8 @@ class AccountGatewayController extends BaseController
|
||||
$wepay = Utils::setupWePay($accountGateway);
|
||||
|
||||
$update_uri_data = $wepay->request('account/get_update_uri', [
|
||||
'account_id' => $accountGateway->getConfig()->accountId,
|
||||
'mode' => 'iframe',
|
||||
'account_id' => $accountGateway->getConfig()->accountId,
|
||||
'mode' => 'iframe',
|
||||
'redirect_uri' => URL::to('/gateways'),
|
||||
]);
|
||||
|
||||
@ -407,11 +409,11 @@ class AccountGatewayController extends BaseController
|
||||
$wepay = new WePay($accessToken);
|
||||
|
||||
$accountDetails = [
|
||||
'name' => Input::get('company_name'),
|
||||
'description' => trans('texts.wepay_account_description'),
|
||||
'name' => Input::get('company_name'),
|
||||
'description' => trans('texts.wepay_account_description'),
|
||||
'theme_object' => json_decode(WEPAY_THEME),
|
||||
'callback_uri' => $accountGateway->getWebhookUrl(),
|
||||
'rbits' => $account->present()->rBits,
|
||||
'rbits' => $account->present()->rBits,
|
||||
];
|
||||
|
||||
if (WEPAY_ENABLE_CANADA) {
|
||||
@ -457,20 +459,22 @@ class AccountGatewayController extends BaseController
|
||||
]);
|
||||
|
||||
$response = Redirect::to($updateUri->uri);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$response = Redirect::to("gateways/{$accountGateway->public_id}/edit");
|
||||
|
||||
return true;
|
||||
} catch (\WePayException $e) {
|
||||
Session::flash('error', $e->getMessage());
|
||||
$response = Redirect::to('gateways/create')
|
||||
->withInput();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function resendConfirmation($publicId = false)
|
||||
{
|
||||
$accountGateway = AccountGateway::scope($publicId)->firstOrFail();
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\ActivityService;
|
||||
|
||||
|
@ -1,24 +1,26 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
use Auth;
|
||||
use Artisan;
|
||||
use Cache;
|
||||
use Config;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Input;
|
||||
use Utils;
|
||||
use View;
|
||||
use Event;
|
||||
use Session;
|
||||
use Response;
|
||||
use Redirect;
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\UserSettingsChanged;
|
||||
use App\Models\Account;
|
||||
use App\Models\Industry;
|
||||
use App\Ninja\Mailers\Mailer;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Events\UserSettingsChanged;
|
||||
use App\Services\EmailService;
|
||||
use Artisan;
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Config;
|
||||
use DB;
|
||||
use Event;
|
||||
use Exception;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Response;
|
||||
use Session;
|
||||
use Utils;
|
||||
use View;
|
||||
|
||||
class AppController extends BaseController
|
||||
{
|
||||
@ -71,7 +73,7 @@ class AppController extends BaseController
|
||||
|
||||
if ($test == 'db') {
|
||||
return $valid === true ? 'Success' : $valid;
|
||||
} elseif (!$valid) {
|
||||
} elseif (! $valid) {
|
||||
return Redirect::to('/setup')->withInput();
|
||||
}
|
||||
|
||||
@ -113,7 +115,6 @@ class AppController extends BaseController
|
||||
$config .= "{$key}={$val}\n";
|
||||
}
|
||||
|
||||
|
||||
// Write Config Settings
|
||||
$fp = fopen(base_path().'/.env', 'w');
|
||||
fwrite($fp, $config);
|
||||
@ -141,12 +142,13 @@ class AppController extends BaseController
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
if (!Auth::check() && Utils::isDatabaseSetup() && Account::count() > 0) {
|
||||
if (! Auth::check() && Utils::isDatabaseSetup() && Account::count() > 0) {
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
if (! $canUpdateEnv = @fopen(base_path().'/.env', 'w')) {
|
||||
Session::flash('error', 'Warning: Permission denied to write to .env config file, try running <code>sudo chown www-data:www-data /path/to/ninja/.env</code>');
|
||||
|
||||
return Redirect::to('/settings/system_settings');
|
||||
}
|
||||
|
||||
@ -193,6 +195,7 @@ class AppController extends BaseController
|
||||
fclose($fp);
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
|
||||
return Redirect::to('/settings/system_settings');
|
||||
}
|
||||
|
||||
@ -241,7 +244,7 @@ class AppController extends BaseController
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!Utils::isNinjaProd() && !Utils::isDatabaseSetup()) {
|
||||
if (! Utils::isNinjaProd() && ! Utils::isDatabaseSetup()) {
|
||||
try {
|
||||
set_time_limit(60 * 5); // shouldn't take this long but just in case
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
@ -251,6 +254,7 @@ class AppController extends BaseController
|
||||
Artisan::call('optimize', ['--force' => true]);
|
||||
} catch (Exception $e) {
|
||||
Utils::logError($e);
|
||||
|
||||
return Response::make($e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
@ -260,7 +264,7 @@ class AppController extends BaseController
|
||||
|
||||
public function update()
|
||||
{
|
||||
if (!Utils::isNinjaProd()) {
|
||||
if (! Utils::isNinjaProd()) {
|
||||
try {
|
||||
set_time_limit(60 * 5);
|
||||
Artisan::call('clear-compiled');
|
||||
@ -290,6 +294,7 @@ class AppController extends BaseController
|
||||
Session::flash('warning', $message);
|
||||
} catch (Exception $e) {
|
||||
Utils::logError($e);
|
||||
|
||||
return Response::make($e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
@ -301,12 +306,14 @@ class AppController extends BaseController
|
||||
{
|
||||
$messageId = Input::get('MessageID');
|
||||
$error = Input::get('Name') . ': ' . Input::get('Description');
|
||||
|
||||
return $this->emailService->markBounced($messageId, $error) ? RESULT_SUCCESS : RESULT_FAILURE;
|
||||
}
|
||||
|
||||
public function emailOpened()
|
||||
{
|
||||
$messageId = Input::get('MessageID');
|
||||
|
||||
return $this->emailService->markOpened($messageId) ? RESULT_SUCCESS : RESULT_FAILURE;
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
@ -316,6 +323,7 @@ class AppController extends BaseController
|
||||
{
|
||||
if (! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) {
|
||||
sleep(3);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -329,7 +337,7 @@ class AppController extends BaseController
|
||||
'clients.public_id as client_id',
|
||||
'payments.public_id as payment_id',
|
||||
'payments.payment_date',
|
||||
'payments.amount'
|
||||
'payments.amount',
|
||||
]);
|
||||
} else {
|
||||
$data = DB::table('users')->count();
|
||||
|
@ -1,20 +1,21 @@
|
||||
<?php namespace App\Http\Controllers\Auth;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Auth;
|
||||
use Event;
|
||||
use Utils;
|
||||
use Session;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Events\UserLoggedIn;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Services\AuthService;
|
||||
use Auth;
|
||||
use Event;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Session;
|
||||
use Utils;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Registration & Login Controller
|
||||
@ -47,7 +48,8 @@ class AuthController extends Controller
|
||||
* Create a new authentication controller instance.
|
||||
*
|
||||
* @param AccountRepository $repo
|
||||
* @param AuthService $authService
|
||||
* @param AuthService $authService
|
||||
*
|
||||
* @internal param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @internal param \Illuminate\Contracts\Auth\Registrar $registrar
|
||||
*/
|
||||
@ -59,6 +61,7 @@ class AuthController extends Controller
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function validator(array $data)
|
||||
@ -73,7 +76,7 @@ class AuthController extends Controller
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $data
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
@ -105,6 +108,7 @@ class AuthController extends Controller
|
||||
$this->accountRepo->unlinkUserFromOauth(Auth::user());
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
|
||||
return redirect()->to('/settings/' . ACCOUNT_USER_DETAILS);
|
||||
}
|
||||
|
||||
@ -113,7 +117,7 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function getLoginWrapper()
|
||||
{
|
||||
if (!Utils::isNinja() && !User::count()) {
|
||||
if (! Utils::isNinja() && ! User::count()) {
|
||||
return redirect()->to('invoice_now');
|
||||
}
|
||||
|
||||
@ -132,6 +136,7 @@ class AuthController extends Controller
|
||||
|
||||
if ($user && $user->failed_logins >= MAX_FAILED_LOGINS) {
|
||||
Session::flash('error', trans('texts.invalid_credentials'));
|
||||
|
||||
return redirect()->to('login');
|
||||
}
|
||||
|
||||
@ -167,7 +172,7 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function getLogoutWrapper()
|
||||
{
|
||||
if (Auth::check() && !Auth::user()->registered) {
|
||||
if (Auth::check() && ! Auth::user()->registered) {
|
||||
$account = Auth::user()->account;
|
||||
$this->accountRepo->unlinkAccount($account);
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php namespace App\Http\Controllers\Auth;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|
@ -1,20 +1,22 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
use Cache;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use View;
|
||||
use Crypt;
|
||||
use File;
|
||||
use Utils;
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\CreateBankAccountRequest;
|
||||
use App\Models\Account;
|
||||
use App\Models\BankAccount;
|
||||
use App\Ninja\Repositories\BankAccountRepository;
|
||||
use App\Services\BankAccountService;
|
||||
use App\Http\Requests\CreateBankAccountRequest;
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Crypt;
|
||||
use File;
|
||||
use Illuminate\Http\Request;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use Utils;
|
||||
use View;
|
||||
|
||||
class BankAccountController extends BaseController
|
||||
{
|
||||
@ -58,8 +60,7 @@ class BankAccountController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the form for account creation
|
||||
*
|
||||
* Displays the form for account creation.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
@ -132,13 +133,14 @@ class BankAccountController extends BaseController
|
||||
} catch (\Exception $e) {
|
||||
Session::flash('error', trans('texts.ofx_parse_failed'));
|
||||
Utils::logError($e);
|
||||
|
||||
return view('accounts.import_ofx');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'banks' => null,
|
||||
'bankAccount' => null,
|
||||
'transactions' => json_encode([$data])
|
||||
'transactions' => json_encode([$data]),
|
||||
];
|
||||
|
||||
return View::make('accounts.bank_account', $data);
|
||||
|
@ -1,17 +1,19 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Utils;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Response;
|
||||
use Request;
|
||||
use League\Fractal\Manager;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use App\Models\EntityModel;
|
||||
use App\Ninja\Serializers\ArraySerializer;
|
||||
use Auth;
|
||||
use Input;
|
||||
use League\Fractal\Manager;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Resource\Collection;
|
||||
use League\Fractal\Resource\Item;
|
||||
use League\Fractal\Serializer\JsonApiSerializer;
|
||||
use Request;
|
||||
use Response;
|
||||
use Utils;
|
||||
|
||||
/**
|
||||
* @SWG\Swagger(
|
||||
@ -128,6 +130,7 @@ class BaseAPIController extends Controller
|
||||
}
|
||||
|
||||
$resource = new Item($data, $transformer, $entityType);
|
||||
|
||||
return $this->manager->createData($resource)->toArray();
|
||||
}
|
||||
|
||||
@ -159,7 +162,7 @@ class BaseAPIController extends Controller
|
||||
} else {
|
||||
$meta = isset($response['meta']) ? $response['meta'] : null;
|
||||
$response = [
|
||||
$index => $response
|
||||
$index => $response,
|
||||
];
|
||||
|
||||
if ($meta) {
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Utils;
|
||||
use Request;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Request;
|
||||
use Utils;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
||||
|
@ -5,8 +5,8 @@ namespace App\Http\Controllers;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use URL;
|
||||
use Session;
|
||||
use URL;
|
||||
|
||||
class BlueVineController extends BaseController
|
||||
{
|
||||
@ -14,38 +14,37 @@ class BlueVineController extends BaseController
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
$data = array(
|
||||
'personal_user_full_name' => Input::get('name'),
|
||||
'business_phone_number' => Input::get('phone'),
|
||||
'email' => Input::get('email'),
|
||||
'personal_fico_score' => intval(Input::get('fico_score')),
|
||||
'business_annual_revenue' => intval(Input::get('annual_revenue')),
|
||||
$data = [
|
||||
'personal_user_full_name' => Input::get('name'),
|
||||
'business_phone_number' => Input::get('phone'),
|
||||
'email' => Input::get('email'),
|
||||
'personal_fico_score' => intval(Input::get('fico_score')),
|
||||
'business_annual_revenue' => intval(Input::get('annual_revenue')),
|
||||
'business_monthly_average_bank_balance' => intval(Input::get('average_bank_balance')),
|
||||
'business_inception_date' => date('Y-m-d', strtotime(Input::get('business_inception'))),
|
||||
'partner_internal_business_id' => 'ninja_account_' . $user->account_id,
|
||||
);
|
||||
'business_inception_date' => date('Y-m-d', strtotime(Input::get('business_inception'))),
|
||||
'partner_internal_business_id' => 'ninja_account_' . $user->account_id,
|
||||
];
|
||||
|
||||
if (! empty(Input::get('quote_type_factoring'))) {
|
||||
$data['invoice_factoring_offer'] = true;
|
||||
$data['desired_credit_line'] = intval(Input::get('desired_credit_limit')['invoice_factoring']);
|
||||
$data['desired_credit_line'] = intval(Input::get('desired_credit_limit')['invoice_factoring']);
|
||||
}
|
||||
|
||||
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(Input::get('desired_credit_limit')['line_of_credit']);
|
||||
}
|
||||
|
||||
|
||||
$api_client = new \GuzzleHttp\Client();
|
||||
try {
|
||||
$response = $api_client->request('POST',
|
||||
'https://app.bluevine.com/api/v1/user/register_external?' . http_build_query(array(
|
||||
'https://app.bluevine.com/api/v1/user/register_external?' . http_build_query([
|
||||
'external_register_token' => env('BLUEVINE_PARTNER_TOKEN'),
|
||||
'c' => env('BLUEVINE_PARTNER_UNIQUE_ID'),
|
||||
'signup_parent_url' => URL::to('/bluevine/completed'),
|
||||
)), array(
|
||||
'json' => $data
|
||||
)
|
||||
'c' => env('BLUEVINE_PARTNER_UNIQUE_ID'),
|
||||
'signup_parent_url' => URL::to('/bluevine/completed'),
|
||||
]), [
|
||||
'json' => $data,
|
||||
]
|
||||
);
|
||||
} catch (\GuzzleHttp\Exception\RequestException $ex) {
|
||||
if ($ex->getCode() == 403) {
|
||||
@ -53,12 +52,12 @@ class BlueVineController extends BaseController
|
||||
$response_data = json_decode($response_body);
|
||||
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $response_data->reason
|
||||
'error' => true,
|
||||
'message' => $response_data->reason,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error' => true
|
||||
'error' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,18 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use DB;
|
||||
use Utils;
|
||||
use Cache;
|
||||
use Input;
|
||||
use Exception;
|
||||
use App\Libraries\Skype\SkypeResponse;
|
||||
use App\Libraries\CurlUtils;
|
||||
use App\Models\User;
|
||||
use App\Libraries\Skype\SkypeResponse;
|
||||
use App\Models\SecurityCode;
|
||||
use App\Models\User;
|
||||
use App\Ninja\Intents\BaseIntent;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
use Auth;
|
||||
use Cache;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Input;
|
||||
use Utils;
|
||||
|
||||
class BotController extends Controller
|
||||
{
|
||||
@ -42,6 +42,7 @@ class BotController extends Controller
|
||||
} elseif ($input['action'] === 'remove') {
|
||||
$this->removeBot($botUserId);
|
||||
$this->saveState($token, false);
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
@ -130,7 +131,7 @@ class BotController extends Controller
|
||||
$url = sprintf('%s/botstate/skype/conversations/%s', MSBOT_STATE_URL, '29:1C-OsU7OWBEDOYJhQUsDkYHmycOwOq9QOg5FVTwRX9ts');
|
||||
|
||||
$headers = [
|
||||
'Authorization: Bearer ' . $token
|
||||
'Authorization: Bearer ' . $token,
|
||||
];
|
||||
|
||||
$response = CurlUtils::get($url, $headers);
|
||||
@ -165,7 +166,6 @@ class BotController extends Controller
|
||||
|
||||
$data = '{ eTag: "*", data: "' . addslashes(json_encode($data)) . '" }';
|
||||
|
||||
|
||||
CurlUtils::post($url, $data, $headers);
|
||||
}
|
||||
|
||||
@ -237,6 +237,7 @@ class BotController extends Controller
|
||||
if (! hash_equals($code->code, $input)) {
|
||||
$code->attempts += 1;
|
||||
$code->save();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -298,7 +299,7 @@ class BotController extends Controller
|
||||
}
|
||||
|
||||
// 7 show result
|
||||
return ($token_valid == 1);
|
||||
return $token_valid == 1;
|
||||
}
|
||||
|
||||
private function base64_url_decode($arg)
|
||||
@ -310,15 +311,16 @@ class BotController extends Controller
|
||||
case 0:
|
||||
break;
|
||||
case 2:
|
||||
$res .= "==";
|
||||
$res .= '==';
|
||||
break;
|
||||
case 3:
|
||||
$res .= "=";
|
||||
$res .= '=';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$res = base64_decode($res);
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ClientRequest;
|
||||
use Response;
|
||||
use Input;
|
||||
use App\Models\Client;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
use App\Http\Requests\CreateClientRequest;
|
||||
use App\Http\Requests\UpdateClientRequest;
|
||||
use App\Models\Client;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
use Input;
|
||||
use Response;
|
||||
|
||||
class ClientApiController extends BaseAPIController
|
||||
{
|
||||
@ -69,15 +71,11 @@ class ClientApiController extends BaseAPIController
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
|
||||
public function show(ClientRequest $request)
|
||||
{
|
||||
return $this->itemResponse($request->entity());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @SWG\Post(
|
||||
* path="/clients",
|
||||
@ -127,7 +125,6 @@ class ClientApiController extends BaseAPIController
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
|
||||
public function update(UpdateClientRequest $request, $publicId)
|
||||
{
|
||||
if ($request->action) {
|
||||
@ -143,7 +140,6 @@ class ClientApiController extends BaseAPIController
|
||||
return $this->itemResponse($client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @SWG\Delete(
|
||||
* path="/clients/{client_id}",
|
||||
@ -165,7 +161,6 @@ class ClientApiController extends BaseAPIController
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
|
||||
public function destroy(UpdateClientRequest $request)
|
||||
{
|
||||
$client = $request->entity();
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php namespace App\Http\Controllers\ClientAuth;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\ClientAuth;
|
||||
|
||||
use Session;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Contact;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Session;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
@ -31,7 +33,7 @@ class AuthController extends Controller
|
||||
$contactKey = session('contact_key');
|
||||
if ($contactKey) {
|
||||
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
||||
if ($contact && !$contact->is_deleted) {
|
||||
if ($contact && ! $contact->is_deleted) {
|
||||
$account = $contact->account;
|
||||
|
||||
$data['account'] = $account;
|
||||
@ -45,7 +47,7 @@ class AuthController extends Controller
|
||||
/**
|
||||
* Get the needed authorization credentials from the request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -57,7 +59,7 @@ class AuthController extends Controller
|
||||
$contactKey = session('contact_key');
|
||||
if ($contactKey) {
|
||||
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
||||
if ($contact && !$contact->is_deleted) {
|
||||
if ($contact && ! $contact->is_deleted) {
|
||||
$credentials['id'] = $contact->id;
|
||||
}
|
||||
}
|
||||
@ -68,7 +70,7 @@ class AuthController extends Controller
|
||||
/**
|
||||
* Validate the user login request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -1,17 +1,18 @@
|
||||
<?php namespace App\Http\Controllers\ClientAuth;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\ClientAuth;
|
||||
|
||||
use Config;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Invitation;
|
||||
use Config;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Invitation;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
@ -51,7 +52,7 @@ class PasswordController extends Controller
|
||||
$contactKey = session('contact_key');
|
||||
if ($contactKey) {
|
||||
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
||||
if ($contact && !$contact->is_deleted) {
|
||||
if ($contact && ! $contact->is_deleted) {
|
||||
$account = $contact->account;
|
||||
$data['account'] = $account;
|
||||
$data['clientFontUrl'] = $account->getFontsUrl();
|
||||
@ -66,7 +67,7 @@ class PasswordController extends Controller
|
||||
/**
|
||||
* Send a reset link to the given user.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
@ -78,7 +79,7 @@ class PasswordController extends Controller
|
||||
$contactKey = session('contact_key');
|
||||
if ($contactKey) {
|
||||
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
||||
if ($contact && !$contact->is_deleted) {
|
||||
if ($contact && ! $contact->is_deleted) {
|
||||
$contactId = $contact->id;
|
||||
}
|
||||
}
|
||||
@ -102,9 +103,10 @@ class PasswordController extends Controller
|
||||
*
|
||||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string|null $key
|
||||
* @param string|null $token
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string|null $key
|
||||
* @param string|null $token
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function showResetForm(Request $request, $key = null, $token = null)
|
||||
@ -116,19 +118,19 @@ class PasswordController extends Controller
|
||||
$data = compact('token');
|
||||
if ($key) {
|
||||
$contact = Contact::where('contact_key', '=', $key)->first();
|
||||
if ($contact && !$contact->is_deleted) {
|
||||
if ($contact && ! $contact->is_deleted) {
|
||||
$account = $contact->account;
|
||||
$data['contact_key'] = $contact->contact_key;
|
||||
} else {
|
||||
// Maybe it's an invitation key
|
||||
$invitation = Invitation::where('invitation_key', '=', $key)->first();
|
||||
if ($invitation && !$invitation->is_deleted) {
|
||||
if ($invitation && ! $invitation->is_deleted) {
|
||||
$account = $invitation->account;
|
||||
$data['contact_key'] = $invitation->contact->contact_key;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($account)) {
|
||||
if (! empty($account)) {
|
||||
$data['account'] = $account;
|
||||
$data['clientFontUrl'] = $account->getFontsUrl();
|
||||
} else {
|
||||
@ -139,15 +141,15 @@ class PasswordController extends Controller
|
||||
return view('clientauth.reset')->with($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display the password reset view for the given token.
|
||||
*
|
||||
* If no token is present, display the link request form.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string|null $key
|
||||
* @param string|null $token
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param string|null $key
|
||||
* @param string|null $token
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getReset(Request $request, $key = null, $token = null)
|
||||
@ -158,7 +160,8 @@ class PasswordController extends Controller
|
||||
/**
|
||||
* Reset the given user's password.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function reset(Request $request)
|
||||
@ -174,7 +177,7 @@ class PasswordController extends Controller
|
||||
$contactKey = session('contact_key');
|
||||
if ($contactKey) {
|
||||
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
||||
if ($contact && !$contact->is_deleted) {
|
||||
if ($contact && ! $contact->is_deleted) {
|
||||
$credentials['id'] = $contact->id;
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,26 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use Utils;
|
||||
use View;
|
||||
use URL;
|
||||
use Input;
|
||||
use Session;
|
||||
use Redirect;
|
||||
use Cache;
|
||||
use App\Models\Client;
|
||||
use App\Models\Account;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Task;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
use App\Services\ClientService;
|
||||
use App\Http\Requests\ClientRequest;
|
||||
use App\Http\Requests\CreateClientRequest;
|
||||
use App\Http\Requests\UpdateClientRequest;
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Task;
|
||||
use App\Ninja\Datatables\ClientDatatable;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
use App\Services\ClientService;
|
||||
use Auth;
|
||||
use Cache;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use URL;
|
||||
use Utils;
|
||||
use View;
|
||||
|
||||
class ClientController extends BaseController
|
||||
{
|
||||
@ -74,7 +76,8 @@ class ClientController extends BaseController
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show(ClientRequest $request)
|
||||
@ -93,7 +96,7 @@ class ClientController extends BaseController
|
||||
$actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => URL::to('/quotes/create/'.$client->public_id)];
|
||||
}
|
||||
|
||||
if (!empty($actionLinks)) {
|
||||
if (! empty($actionLinks)) {
|
||||
$actionLinks[] = \DropdownButton::DIVIDER;
|
||||
}
|
||||
|
||||
@ -153,7 +156,8 @@ class ClientController extends BaseController
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(ClientRequest $request)
|
||||
@ -194,7 +198,8 @@ class ClientController extends BaseController
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(UpdateClientRequest $request)
|
||||
|
@ -1,32 +1,34 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\InvoiceInvitationWasViewed;
|
||||
use App\Events\QuoteInvitationWasViewed;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Document;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\Invitation;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Ninja\Repositories\ActivityRepository;
|
||||
use App\Ninja\Repositories\CreditRepository;
|
||||
use App\Ninja\Repositories\DocumentRepository;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Repositories\PaymentRepository;
|
||||
use App\Services\PaymentService;
|
||||
use Auth;
|
||||
use View;
|
||||
use URL;
|
||||
use Barracuda\ArchiveStream\ZipArchive;
|
||||
use Cache;
|
||||
use Datatable;
|
||||
use Exception;
|
||||
use Input;
|
||||
use Utils;
|
||||
use Redirect;
|
||||
use Request;
|
||||
use Response;
|
||||
use Session;
|
||||
use Datatable;
|
||||
use URL;
|
||||
use Utils;
|
||||
use Validator;
|
||||
use Cache;
|
||||
use Redirect;
|
||||
use Exception;
|
||||
use App\Models\Gateway;
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Document;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\Contact;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Repositories\PaymentRepository;
|
||||
use App\Ninja\Repositories\ActivityRepository;
|
||||
use App\Ninja\Repositories\DocumentRepository;
|
||||
use App\Ninja\Repositories\CreditRepository;
|
||||
use App\Events\InvoiceInvitationWasViewed;
|
||||
use App\Events\QuoteInvitationWasViewed;
|
||||
use App\Services\PaymentService;
|
||||
use Barracuda\ArchiveStream\ZipArchive;
|
||||
use View;
|
||||
|
||||
class ClientPortalController extends BaseController
|
||||
{
|
||||
@ -46,7 +48,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function view($invitationKey)
|
||||
{
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -54,7 +56,7 @@ class ClientPortalController extends BaseController
|
||||
$client = $invoice->client;
|
||||
$account = $invoice->account;
|
||||
|
||||
if (!$account->checkSubdomain(Request::server('HTTP_HOST'))) {
|
||||
if (! $account->checkSubdomain(Request::server('HTTP_HOST'))) {
|
||||
return response()->view('error', [
|
||||
'error' => trans('texts.invoice_not_found'),
|
||||
'hideHeader' => true,
|
||||
@ -65,8 +67,8 @@ class ClientPortalController extends BaseController
|
||||
|
||||
$account->loadLocalizationSettings($client);
|
||||
|
||||
if (!Input::has('phantomjs') && !Input::has('silent') && !Session::has($invitationKey)
|
||||
&& (!Auth::check() || Auth::user()->account_id != $invoice->account_id)) {
|
||||
if (! Input::has('phantomjs') && ! Input::has('silent') && ! Session::has($invitationKey)
|
||||
&& (! Auth::check() || Auth::user()->account_id != $invoice->account_id)) {
|
||||
if ($invoice->isType(INVOICE_TYPE_QUOTE)) {
|
||||
event(new QuoteInvitationWasViewed($invoice, $invitation));
|
||||
} else {
|
||||
@ -75,7 +77,7 @@ class ClientPortalController extends BaseController
|
||||
}
|
||||
|
||||
Session::put($invitationKey, true); // track this invitation has been seen
|
||||
Session::put('contact_key', $invitation->contact->contact_key);// track current contact
|
||||
Session::put('contact_key', $invitation->contact->contact_key); // track current contact
|
||||
|
||||
$invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
|
||||
$invoice->due_date = Utils::fromSqlDate($invoice->due_date);
|
||||
@ -111,7 +113,7 @@ class ClientPortalController extends BaseController
|
||||
$paymentURL = $paymentTypes[0]['url'];
|
||||
if ($paymentTypes[0]['gatewayTypeId'] == GATEWAY_TYPE_CUSTOM) {
|
||||
// do nothing
|
||||
} elseif (!$account->isGatewayConfigured(GATEWAY_PAYPAL_EXPRESS)) {
|
||||
} elseif (! $account->isGatewayConfigured(GATEWAY_PAYPAL_EXPRESS)) {
|
||||
$paymentURL = URL::to($paymentURL);
|
||||
}
|
||||
}
|
||||
@ -184,7 +186,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function download($invitationKey)
|
||||
{
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
return response()->view('error', [
|
||||
'error' => trans('texts.invoice_not_found'),
|
||||
'hideHeader' => true,
|
||||
@ -205,7 +207,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function sign($invitationKey)
|
||||
{
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
return RESULT_FAILURE;
|
||||
}
|
||||
|
||||
@ -223,11 +225,11 @@ class ClientPortalController extends BaseController
|
||||
public function dashboard($contactKey = false)
|
||||
{
|
||||
if ($contactKey) {
|
||||
if (!$contact = Contact::where('contact_key', '=', $contactKey)->first()) {
|
||||
if (! $contact = Contact::where('contact_key', '=', $contactKey)->first()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
Session::put('contact_key', $contactKey);// track current contact
|
||||
} elseif (!$contact = $this->getContact()) {
|
||||
Session::put('contact_key', $contactKey); // track current contact
|
||||
} elseif (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -238,9 +240,9 @@ class ClientPortalController extends BaseController
|
||||
$color = $account->primary_color ? $account->primary_color : '#0b4d78';
|
||||
$customer = false;
|
||||
|
||||
if (!$account->enable_client_portal) {
|
||||
if (! $account->enable_client_portal) {
|
||||
return $this->returnError();
|
||||
} elseif (!$account->enable_client_portal_dashboard) {
|
||||
} elseif (! $account->enable_client_portal_dashboard) {
|
||||
return redirect()->to('/client/invoices/');
|
||||
}
|
||||
|
||||
@ -264,7 +266,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function activityDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -302,14 +304,14 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function recurringInvoiceIndex()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
$account = $contact->account;
|
||||
$account->loadLocalizationSettings($contact->client);
|
||||
|
||||
if (!$account->enable_client_portal) {
|
||||
if (! $account->enable_client_portal) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -330,14 +332,14 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function invoiceIndex()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
$account = $contact->account;
|
||||
$account->loadLocalizationSettings($contact->client);
|
||||
|
||||
if (!$account->enable_client_portal) {
|
||||
if (! $account->enable_client_portal) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -358,7 +360,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function invoiceDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -367,24 +369,23 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function recurringInvoiceDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->invoiceRepo->getClientRecurringDatatable($contact->id);
|
||||
}
|
||||
|
||||
|
||||
public function paymentIndex()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
$account = $contact->account;
|
||||
$account->loadLocalizationSettings($contact->client);
|
||||
|
||||
if (!$account->enable_client_portal) {
|
||||
if (! $account->enable_client_portal) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -396,7 +397,7 @@ class ClientPortalController extends BaseController
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'entityType' => ENTITY_PAYMENT,
|
||||
'title' => trans('texts.payments'),
|
||||
'columns' => Utils::trans(['invoice', 'transaction_reference', 'method', 'payment_amount', 'payment_date', 'status'])
|
||||
'columns' => Utils::trans(['invoice', 'transaction_reference', 'method', 'payment_amount', 'payment_date', 'status']),
|
||||
];
|
||||
|
||||
return response()->view('public_list', $data);
|
||||
@ -404,7 +405,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function paymentDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
$payments = $this->paymentRepo->findForContact($contact->id, Input::get('sSearch'));
|
||||
@ -417,7 +418,7 @@ class ClientPortalController extends BaseController
|
||||
return $model->transaction_reference ? $model->transaction_reference : '<i>'.trans('texts.manual_entry').'</i>';
|
||||
})
|
||||
->addColumn('payment_type', function ($model) {
|
||||
return ($model->payment_type && !$model->last4) ? $model->payment_type : ($model->account_gateway_id ? '<i>Online payment</i>' : '');
|
||||
return ($model->payment_type && ! $model->last4) ? $model->payment_type : ($model->account_gateway_id ? '<i>Online payment</i>' : '');
|
||||
})
|
||||
->addColumn('amount', function ($model) {
|
||||
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
||||
@ -456,19 +457,20 @@ class ClientPortalController extends BaseController
|
||||
$class = 'default';
|
||||
break;
|
||||
}
|
||||
|
||||
return "<h4><div class=\"label label-{$class}\">$label</div></h4>";
|
||||
}
|
||||
|
||||
public function quoteIndex()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
$account = $contact->account;
|
||||
$account->loadLocalizationSettings($contact->client);
|
||||
|
||||
if (!$account->enable_client_portal) {
|
||||
if (! $account->enable_client_portal) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -486,10 +488,9 @@ class ClientPortalController extends BaseController
|
||||
return response()->view('public_list', $data);
|
||||
}
|
||||
|
||||
|
||||
public function quoteDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -498,14 +499,14 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function creditIndex()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
$account = $contact->account;
|
||||
$account->loadLocalizationSettings($contact->client);
|
||||
|
||||
if (!$account->enable_client_portal) {
|
||||
if (! $account->enable_client_portal) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -525,7 +526,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function creditDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -534,14 +535,14 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function documentIndex()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
$account = $contact->account;
|
||||
$account->loadLocalizationSettings($contact->client);
|
||||
|
||||
if (!$account->enable_client_portal) {
|
||||
if (! $account->enable_client_portal) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -559,10 +560,9 @@ class ClientPortalController extends BaseController
|
||||
return response()->view('public_list', $data);
|
||||
}
|
||||
|
||||
|
||||
public function documentDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -582,13 +582,13 @@ class ClientPortalController extends BaseController
|
||||
{
|
||||
$contactKey = session('contact_key');
|
||||
|
||||
if (!$contactKey) {
|
||||
if (! $contactKey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
||||
|
||||
if (!$contact || $contact->is_deleted) {
|
||||
if (! $contact || $contact->is_deleted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -597,33 +597,32 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function getDocumentVFSJS($publicId, $name)
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
$document = Document::scope($publicId, $contact->account_id)->first();
|
||||
|
||||
|
||||
if (!$document->isPDFEmbeddable()) {
|
||||
return Response::view('error', ['error'=>'Image does not exist!'], 404);
|
||||
if (! $document->isPDFEmbeddable()) {
|
||||
return Response::view('error', ['error' => 'Image does not exist!'], 404);
|
||||
}
|
||||
|
||||
$authorized = false;
|
||||
if ($document->expense && $document->expense->client_id == $contact->client_id) {
|
||||
$authorized = true;
|
||||
} elseif ($document->invoice && $document->invoice->client_id ==$contact->client_id) {
|
||||
} elseif ($document->invoice && $document->invoice->client_id == $contact->client_id) {
|
||||
$authorized = true;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
return Response::view('error', ['error'=>'Not authorized'], 403);
|
||||
if (! $authorized) {
|
||||
return Response::view('error', ['error' => 'Not authorized'], 403);
|
||||
}
|
||||
|
||||
if (substr($name, -3)=='.js') {
|
||||
if (substr($name, -3) == '.js') {
|
||||
$name = substr($name, 0, -3);
|
||||
}
|
||||
|
||||
$content = $document->preview?$document->getRawPreview():$document->getRaw();
|
||||
$content = $document->preview ? $document->getRawPreview() : $document->getRaw();
|
||||
$content = 'ninjaAddVFSDoc('.json_encode(intval($publicId).'/'.strval($name)).',"'.base64_encode($content).'")';
|
||||
$response = Response::make($content, 200);
|
||||
$response->header('content-type', 'text/javascript');
|
||||
@ -637,7 +636,7 @@ class ClientPortalController extends BaseController
|
||||
return function_exists('gmp_init');
|
||||
}
|
||||
|
||||
protected function getInvoiceZipDocuments($invoice, &$size=0)
|
||||
protected function getInvoiceZipDocuments($invoice, &$size = 0)
|
||||
{
|
||||
$documents = $invoice->documents;
|
||||
|
||||
@ -655,13 +654,13 @@ class ClientPortalController extends BaseController
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($toZip[$document->name])) {
|
||||
if (! empty($toZip[$document->name])) {
|
||||
// This name is taken
|
||||
if ($toZip[$document->name]->hash != $document->hash) {
|
||||
// 2 different files with the same name
|
||||
$nameInfo = pathinfo($document->name);
|
||||
|
||||
for ($i = 1;; $i++) {
|
||||
for ($i = 1; ; $i++) {
|
||||
$name = $nameInfo['filename'].' ('.$i.').'.$nameInfo['extension'];
|
||||
|
||||
if (empty($toZip[$name])) {
|
||||
@ -685,26 +684,27 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function getInvoiceDocumentsZip($invitationKey)
|
||||
{
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
Session::put('contact_key', $invitation->contact->contact_key);// track current contact
|
||||
Session::put('contact_key', $invitation->contact->contact_key); // track current contact
|
||||
|
||||
$invoice = $invitation->invoice;
|
||||
|
||||
$toZip = $this->getInvoiceZipDocuments($invoice);
|
||||
|
||||
if (!count($toZip)) {
|
||||
return Response::view('error', ['error'=>'No documents small enough'], 404);
|
||||
if (! count($toZip)) {
|
||||
return Response::view('error', ['error' => 'No documents small enough'], 404);
|
||||
}
|
||||
|
||||
$zip = new ZipArchive($invitation->account->name.' Invoice '.$invoice->invoice_number.'.zip');
|
||||
|
||||
return Response::stream(function () use ($toZip, $zip) {
|
||||
foreach ($toZip as $name=>$document) {
|
||||
foreach ($toZip as $name => $document) {
|
||||
$fileStream = $document->getStream();
|
||||
if ($fileStream) {
|
||||
$zip->init_file_stream_transfer($name, $document->size, ['time'=>$document->created_at->timestamp]);
|
||||
$zip->init_file_stream_transfer($name, $document->size, ['time' => $document->created_at->timestamp]);
|
||||
while ($buffer = fread($fileStream, 256000)) {
|
||||
$zip->stream_file_part($buffer);
|
||||
}
|
||||
@ -720,11 +720,11 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function getDocument($invitationKey, $publicId)
|
||||
{
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
Session::put('contact_key', $invitation->contact->contact_key);// track current contact
|
||||
Session::put('contact_key', $invitation->contact->contact_key); // track current contact
|
||||
|
||||
$clientId = $invitation->invoice->client_id;
|
||||
$document = Document::scope($publicId, $invitation->account_id)->firstOrFail();
|
||||
@ -736,8 +736,8 @@ class ClientPortalController extends BaseController
|
||||
$authorized = true;
|
||||
}
|
||||
|
||||
if (!$authorized) {
|
||||
return Response::view('error', ['error'=>'Not authorized'], 403);
|
||||
if (! $authorized) {
|
||||
return Response::view('error', ['error' => 'Not authorized'], 403);
|
||||
}
|
||||
|
||||
return DocumentController::getDownloadResponse($document);
|
||||
@ -745,7 +745,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function paymentMethods()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ class ClientPortalController extends BaseController
|
||||
$amount1 = Input::get('verification1');
|
||||
$amount2 = Input::get('verification2');
|
||||
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -793,12 +793,12 @@ class ClientPortalController extends BaseController
|
||||
Session::flash('message', trans('texts.payment_method_verified'));
|
||||
}
|
||||
|
||||
return redirect()->to($account->enable_client_portal_dashboard?'/client/dashboard':'/client/payment_methods/');
|
||||
return redirect()->to($account->enable_client_portal_dashboard ? '/client/dashboard' : '/client/payment_methods/');
|
||||
}
|
||||
|
||||
public function removePaymentMethod($publicId)
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -817,12 +817,12 @@ class ClientPortalController extends BaseController
|
||||
Session::flash('error', $exception->getMessage());
|
||||
}
|
||||
|
||||
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/');
|
||||
}
|
||||
|
||||
public function setDefaultPaymentMethod()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -831,7 +831,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
$validator = Validator::make(Input::all(), ['source' => 'required']);
|
||||
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);
|
||||
@ -845,7 +845,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
Session::flash('message', trans('texts.payment_method_set_as_default'));
|
||||
|
||||
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/');
|
||||
}
|
||||
|
||||
private function paymentMethodError($type, $error, $accountGateway = false, $exception = false)
|
||||
@ -862,7 +862,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function setAutoBill()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
/**
|
||||
* Class Controller
|
||||
* Class Controller.
|
||||
*/
|
||||
abstract class Controller extends BaseController
|
||||
{
|
||||
|
@ -1,19 +1,21 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\CreateCreditRequest;
|
||||
use App\Http\Requests\CreditRequest;
|
||||
use App\Http\Requests\UpdateCreditRequest;
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use App\Ninja\Datatables\CreditDatatable;
|
||||
use App\Ninja\Repositories\CreditRepository;
|
||||
use App\Services\CreditService;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use URL;
|
||||
use Utils;
|
||||
use View;
|
||||
use App\Models\Client;
|
||||
use App\Models\Credit;
|
||||
use App\Services\CreditService;
|
||||
use App\Ninja\Repositories\CreditRepository;
|
||||
use App\Http\Requests\UpdateCreditRequest;
|
||||
use App\Http\Requests\CreateCreditRequest;
|
||||
use App\Http\Requests\CreditRequest;
|
||||
use App\Ninja\Datatables\CreditDatatable;
|
||||
|
||||
class CreditController extends BaseController
|
||||
{
|
||||
@ -70,7 +72,7 @@ class CreditController extends BaseController
|
||||
|
||||
$credit->credit_date = Utils::fromSqlDate($credit->credit_date);
|
||||
|
||||
$data = array(
|
||||
$data = [
|
||||
'client' => $credit->client,
|
||||
'clientPublicId' => $credit->client->public_id,
|
||||
'credit' => $credit,
|
||||
@ -78,7 +80,7 @@ class CreditController extends BaseController
|
||||
'url' => 'credits/'.$publicId,
|
||||
'title' => 'Edit Credit',
|
||||
'clients' => null,
|
||||
);
|
||||
];
|
||||
|
||||
return View::make('credits.edit', $data);
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use App\Ninja\Repositories\DashboardRepository;
|
||||
use App\Ninja\Transformers\ActivityTransformer;
|
||||
use Auth;
|
||||
|
||||
class DashboardApiController extends BaseAPIController
|
||||
{
|
||||
|
@ -1,13 +1,15 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use View;
|
||||
use Utils;
|
||||
use App\Models\Client;
|
||||
use App\Ninja\Repositories\DashboardRepository;
|
||||
use Auth;
|
||||
use Utils;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class DashboardController
|
||||
* Class DashboardController.
|
||||
*/
|
||||
class DashboardController extends BaseController
|
||||
{
|
||||
|
@ -1,12 +1,14 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\CreateDocumentRequest;
|
||||
use App\Http\Requests\DocumentRequest;
|
||||
use App\Models\Document;
|
||||
use App\Ninja\Repositories\DocumentRepository;
|
||||
use App\Http\Requests\DocumentRequest;
|
||||
use App\Http\Requests\CreateDocumentRequest;
|
||||
|
||||
/**
|
||||
* Class DocumentAPIController
|
||||
* Class DocumentAPIController.
|
||||
*/
|
||||
class DocumentAPIController extends BaseAPIController
|
||||
{
|
||||
@ -67,7 +69,7 @@ class DocumentAPIController extends BaseAPIController
|
||||
if (array_key_exists($document->type, Document::$types)) {
|
||||
return DocumentController::getDownloadResponse($document);
|
||||
} else {
|
||||
return $this->errorResponse(['error'=>'Invalid mime type'], 400);
|
||||
return $this->errorResponse(['error' => 'Invalid mime type'], 400);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
use Redirect;
|
||||
use View;
|
||||
use Response;
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\CreateDocumentRequest;
|
||||
use App\Http\Requests\DocumentRequest;
|
||||
use App\Http\Requests\UpdateDocumentRequest;
|
||||
use App\Models\Document;
|
||||
use App\Ninja\Repositories\DocumentRepository;
|
||||
use App\Http\Requests\DocumentRequest;
|
||||
use App\Http\Requests\CreateDocumentRequest;
|
||||
use App\Http\Requests\UpdateDocumentRequest;
|
||||
use Redirect;
|
||||
use Response;
|
||||
use View;
|
||||
|
||||
class DocumentController extends BaseController
|
||||
{
|
||||
@ -37,8 +39,8 @@ class DocumentController extends BaseController
|
||||
|
||||
if ($stream) {
|
||||
$headers = [
|
||||
'Content-Type' => Document::$types[$document->type]['mime'],
|
||||
'Content-Length' => $document->size,
|
||||
'Content-Type' => Document::$types[$document->type]['mime'],
|
||||
'Content-Length' => $document->size,
|
||||
];
|
||||
|
||||
$response = Response::stream(function () use ($stream) {
|
||||
@ -57,7 +59,7 @@ class DocumentController extends BaseController
|
||||
$document = $request->entity();
|
||||
|
||||
if (empty($document->preview)) {
|
||||
return Response::view('error', ['error'=>'Preview does not exist!'], 404);
|
||||
return Response::view('error', ['error' => 'Preview does not exist!'], 404);
|
||||
}
|
||||
|
||||
$direct_url = $document->getDirectPreviewUrl();
|
||||
@ -76,15 +78,15 @@ class DocumentController extends BaseController
|
||||
{
|
||||
$document = $request->entity();
|
||||
|
||||
if (substr($name, -3)=='.js') {
|
||||
if (substr($name, -3) == '.js') {
|
||||
$name = substr($name, 0, -3);
|
||||
}
|
||||
|
||||
if (!$document->isPDFEmbeddable()) {
|
||||
return Response::view('error', ['error'=>'Image does not exist!'], 404);
|
||||
if (! $document->isPDFEmbeddable()) {
|
||||
return Response::view('error', ['error' => 'Image does not exist!'], 404);
|
||||
}
|
||||
|
||||
$content = $document->preview?$document->getRawPreview():$document->getRaw();
|
||||
$content = $document->preview ? $document->getRawPreview() : $document->getRaw();
|
||||
$content = 'ninjaAddVFSDoc('.json_encode(intval($publicId).'/'.strval($name)).',"'.base64_encode($content).'")';
|
||||
$response = Response::make($content, 200);
|
||||
$response->header('content-type', 'text/javascript');
|
||||
@ -100,13 +102,13 @@ class DocumentController extends BaseController
|
||||
if (is_string($result)) {
|
||||
return Response::json([
|
||||
'error' => $result,
|
||||
'code' => 400
|
||||
'code' => 400,
|
||||
], 400);
|
||||
} else {
|
||||
return Response::json([
|
||||
'error' => false,
|
||||
'document' => $doc_array,
|
||||
'code' => 200
|
||||
'code' => 200,
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\CreateExpenseRequest;
|
||||
use App\Http\Requests\ExpenseRequest;
|
||||
use App\Http\Requests\UpdateExpenseRequest;
|
||||
use App\Models\Expense;
|
||||
use App\Ninja\Repositories\ExpenseRepository;
|
||||
use App\Services\ExpenseService;
|
||||
use App\Http\Requests\ExpenseRequest;
|
||||
use App\Http\Requests\CreateExpenseRequest;
|
||||
use App\Http\Requests\UpdateExpenseRequest;
|
||||
|
||||
class ExpenseApiController extends BaseAPIController
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Input;
|
||||
use App\Services\ExpenseCategoryService;
|
||||
use App\Http\Requests\CreateExpenseCategoryRequest;
|
||||
use App\Http\Requests\UpdateExpenseCategoryRequest;
|
||||
use App\Ninja\Repositories\ExpenseCategoryRepository;
|
||||
use App\Services\ExpenseCategoryService;
|
||||
use Input;
|
||||
|
||||
class ExpenseCategoryApiController extends BaseAPIController
|
||||
{
|
||||
@ -48,7 +50,6 @@ class ExpenseCategoryApiController extends BaseAPIController
|
||||
return $this->itemResponse($category);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @SWG\Put(
|
||||
* path="/expense_categories/{expense_category_id}",
|
||||
|
@ -1,14 +1,16 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
use View;
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\CreateExpenseCategoryRequest;
|
||||
use App\Http\Requests\ExpenseCategoryRequest;
|
||||
use App\Http\Requests\UpdateExpenseCategoryRequest;
|
||||
use App\Ninja\Datatables\ExpenseCategoryDatatable;
|
||||
use App\Ninja\Repositories\ExpenseCategoryRepository;
|
||||
use App\Services\ExpenseCategoryService;
|
||||
use Input;
|
||||
use Session;
|
||||
use App\Services\ExpenseCategoryService;
|
||||
use App\Ninja\Repositories\ExpenseCategoryRepository;
|
||||
use App\Ninja\Datatables\ExpenseCategoryDatatable;
|
||||
use App\Http\Requests\ExpenseCategoryRequest;
|
||||
use App\Http\Requests\CreateExpenseCategoryRequest;
|
||||
use App\Http\Requests\UpdateExpenseCategoryRequest;
|
||||
use View;
|
||||
|
||||
class ExpenseCategoryController extends BaseController
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user