mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge branch 'release-3.1.0'
This commit is contained in:
commit
93ba0cb201
@ -54,6 +54,12 @@ FCM_API_TOKEN=
|
||||
GOOGLE_MAPS_ENABLED=true
|
||||
#GOOGLE_MAPS_API_KEY=
|
||||
|
||||
# Create a cookie to stay logged in
|
||||
#REMEMBER_ME_ENABLED=true
|
||||
|
||||
# The app automatically logs the user out after this number of seconds
|
||||
#AUTO_LOGOUT_SECONDS=28800
|
||||
|
||||
#S3_KEY=
|
||||
#S3_SECRET=
|
||||
#S3_REGION=
|
||||
@ -88,5 +94,6 @@ WEPAY_APP_FEE_MULTIPLIER=0.002
|
||||
WEPAY_APP_FEE_FIXED=0
|
||||
WEPAY_THEME='{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}' # See https://www.wepay.com/developer/reference/structures#theme
|
||||
|
||||
|
||||
BLUEVINE_PARTNER_UNIQUE_ID=
|
||||
BLUEVINE_PARTNER_TOKEN=
|
||||
|
98
.php_cs.dist
Normal file
98
.php_cs.dist
Normal file
@ -0,0 +1,98 @@
|
||||
<?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([
|
||||
'@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,
|
||||
'linebreak_after_opening_tag' => 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_add_missing_param_annotation' => 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,
|
||||
'self_accessor' => true,
|
||||
'short_scalar_cast' => 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,
|
||||
'array_syntax' => array('syntax' => 'short'),
|
||||
])
|
||||
->setFinder($finder);
|
@ -49,6 +49,7 @@ before_script:
|
||||
- php artisan key:generate --no-interaction
|
||||
- sed -i 's/APP_ENV=production/APP_ENV=development/g' .env
|
||||
- sed -i 's/APP_DEBUG=false/APP_DEBUG=true/g' .env
|
||||
- sed -i 's/MAIL_DRIVER=smtp/MAIL_DRIVER=log/g' .env
|
||||
- sed -i '$a NINJA_DEV=true' .env
|
||||
- sed -i '$a TRAVIS=true' .env
|
||||
# create the database and user
|
||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
||||
Copyright (c) 2016 by Hillel Coren
|
||||
Copyright (c) 2017 by Hillel Coren
|
||||
Invoice Ninja * https://www.invoiceninja.com
|
||||
"CREATE. SEND. GET PAID"
|
||||
|
||||
|
@ -61,9 +61,9 @@ The [self-host zip](https://www.invoiceninja.com/self-host/) includes all third
|
||||
* [Feature Roadmap](https://trello.com/b/63BbiVVe/)
|
||||
|
||||
## Development
|
||||
* [Custom Module](http://docs.invoiceninja.com/en/latest/custom_modules.html) | [Watch Video](https://www.youtube.com/watch?v=8jJ-PYuq85k)
|
||||
* [PHP SDK](https://github.com/invoiceninja/sdk-php)
|
||||
* [API Documentation](https://www.invoiceninja.com/api-documentation/)
|
||||
* [PHP SDK](https://github.com/invoiceninja/sdk-php)
|
||||
* [Custom Module](http://docs.invoiceninja.com/en/latest/custom_modules.html) | [Watch Video](https://www.youtube.com/watch?v=8jJ-PYuq85k)
|
||||
|
||||
## Contributing
|
||||
All contributors are welcome!
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?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)
|
||||
{
|
||||
@ -71,17 +74,17 @@ class ChargeRenewalInvoices extends Command
|
||||
// check if account has switched to free since the invoice was created
|
||||
$account = Account::find($invoice->client->public_id);
|
||||
|
||||
if ( ! $account) {
|
||||
if (! $account) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$company = $account->company;
|
||||
if ( ! $company->plan || $company->plan == PLAN_FREE) {
|
||||
if (! $company->plan || $company->plan == PLAN_FREE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->info("Charging invoice {$invoice->invoice_number}");
|
||||
if ( ! $this->paymentService->autoBillInvoice($invoice)) {
|
||||
if (! $this->paymentService->autoBillInvoice($invoice)) {
|
||||
$this->info('Failed to auto-bill, emailing invoice');
|
||||
$this->mailer->sendInvoice($invoice);
|
||||
}
|
||||
|
@ -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,12 +39,11 @@ Options:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class CheckData
|
||||
* Class CheckData.
|
||||
*/
|
||||
class CheckData extends Command {
|
||||
|
||||
class CheckData extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -60,14 +61,15 @@ 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->checkFailedJobs();
|
||||
$this->checkAccountData();
|
||||
}
|
||||
|
||||
@ -79,7 +81,7 @@ class CheckData extends Command {
|
||||
Mail::raw($this->log, function ($message) use ($errorEmail) {
|
||||
$message->to($errorEmail)
|
||||
->from(CONTACT_EMAIL)
|
||||
->subject('Check-Data');
|
||||
->subject('Check-Data: ' . strtoupper($this->isValid ? RESULT_SUCCESS : RESULT_FAILURE));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -89,6 +91,17 @@ class CheckData extends Command {
|
||||
$this->log .= $str . "\n";
|
||||
}
|
||||
|
||||
private function checkFailedJobs()
|
||||
{
|
||||
$count = DB::table('failed_jobs')->count();
|
||||
|
||||
if ($count > 0) {
|
||||
$this->isValid = false;
|
||||
}
|
||||
|
||||
$this->logMessage($count . ' failed jobs');
|
||||
}
|
||||
|
||||
private function checkBlankInvoiceHistory()
|
||||
{
|
||||
$count = DB::table('activities')
|
||||
@ -113,33 +126,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,
|
||||
@ -150,7 +163,7 @@ class CheckData extends Command {
|
||||
'projects' => [
|
||||
ENTITY_USER,
|
||||
ENTITY_CLIENT,
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($tables as $table => $entityTypes) {
|
||||
@ -249,7 +262,6 @@ class CheckData extends Command {
|
||||
//$this->logMessage(var_dump($activities));
|
||||
|
||||
foreach ($activities as $activity) {
|
||||
|
||||
$activityFix = false;
|
||||
|
||||
if ($activity->invoice_id) {
|
||||
@ -258,7 +270,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;
|
||||
@ -272,7 +284,6 @@ class CheckData extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($activity->activity_type_id == ACTIVITY_TYPE_CREATE_INVOICE
|
||||
|| $activity->activity_type_id == ACTIVITY_TYPE_CREATE_QUOTE) {
|
||||
|
||||
@ -293,12 +304,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;
|
||||
@ -322,7 +333,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;
|
||||
@ -335,7 +346,7 @@ class CheckData extends Command {
|
||||
$foundProblem = true;
|
||||
$clientFix -= $activity->adjustment;
|
||||
$activityFix = 0;
|
||||
} else if ((strtotime($activity->created_at) - strtotime($lastCreatedAt) <= 1) && $activity->adjustment > 0 && $activity->adjustment == $lastAdjustment) {
|
||||
} elseif ((strtotime($activity->created_at) - strtotime($lastCreatedAt) <= 1) && $activity->adjustment > 0 && $activity->adjustment == $lastAdjustment) {
|
||||
$this->logMessage("Duplicate adjustment for updated invoice adjustment:{$activity->adjustment}");
|
||||
$foundProblem = true;
|
||||
$clientFix -= $activity->adjustment;
|
||||
@ -349,7 +360,7 @@ class CheckData extends Command {
|
||||
$clientFix += $lastBalance - $activity->balance;
|
||||
$activityFix = 0;
|
||||
}
|
||||
} else if ($activity->activity_type_id == ACTIVITY_TYPE_DELETE_PAYMENT) {
|
||||
} elseif ($activity->activity_type_id == ACTIVITY_TYPE_DELETE_PAYMENT) {
|
||||
// **Fix for deleting payment after deleting invoice**
|
||||
if ($activity->adjustment != 0 && $invoice->is_deleted && $activity->created_at > $invoice->deleted_at) {
|
||||
$this->logMessage("Incorrect adjustment for deleted payment adjustment:{$activity->adjustment}");
|
||||
@ -361,7 +372,7 @@ class CheckData extends Command {
|
||||
|
||||
if ($activityFix !== false || $clientFix !== false) {
|
||||
$data = [
|
||||
'balance' => $activity->balance + $clientFix
|
||||
'balance' => $activity->balance + $clientFix,
|
||||
];
|
||||
|
||||
if ($activityFix !== false) {
|
||||
@ -384,8 +395,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,
|
||||
@ -422,5 +433,4 @@ class CheckData extends Command {
|
||||
['client_id', null, InputOption::VALUE_OPTIONAL, 'Client id', null],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,35 +1,36 @@
|
||||
<?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 {
|
||||
class Inspire extends Command
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
@ -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'));
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ class MakeClass extends GeneratorCommand
|
||||
$str = '';
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if ( ! $field) {
|
||||
if (! $field) {
|
||||
continue;
|
||||
}
|
||||
$field = explode(':', $field)[0];
|
||||
@ -120,7 +120,7 @@ class MakeClass extends GeneratorCommand
|
||||
$str = '';
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if ( ! $field) {
|
||||
if (! $field) {
|
||||
continue;
|
||||
}
|
||||
$parts = explode(':', $field);
|
||||
@ -144,7 +144,7 @@ class MakeClass extends GeneratorCommand
|
||||
$str = '';
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if ( ! $field) {
|
||||
if (! $field) {
|
||||
continue;
|
||||
}
|
||||
$field = explode(':', $field)[0];
|
||||
@ -161,7 +161,7 @@ class MakeClass extends GeneratorCommand
|
||||
$str = '';
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if ( ! $field) {
|
||||
if (! $field) {
|
||||
continue;
|
||||
}
|
||||
$field = explode(':', $field)[0];
|
||||
@ -169,6 +169,5 @@ class MakeClass extends GeneratorCommand
|
||||
}
|
||||
|
||||
return rtrim($str);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ class MakeModule extends Command
|
||||
|
||||
// convert 'name:string,description:text' to 'name,description'
|
||||
$fillable = explode(',', $fields);
|
||||
$fillable = array_map(function($item) {
|
||||
$fillable = array_map(function ($item) {
|
||||
return explode(':', $item)[0];
|
||||
}, $fillable);
|
||||
$fillable = join(',', $fillable);
|
||||
$fillable = implode(',', $fillable);
|
||||
|
||||
$this->info("Creating module: {$name}...");
|
||||
|
||||
@ -77,22 +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,15 +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
|
||||
*/
|
||||
@ -24,7 +24,7 @@ class ResetData extends Command
|
||||
{
|
||||
$this->info(date('Y-m-d') . ' Running ResetData...');
|
||||
|
||||
if (!Utils::isNinjaDev()) {
|
||||
if (! Utils::isNinjaDev()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,9 @@ class ResetInvoiceSchemaCounter extends Command
|
||||
$latestInvoice = $this->invoice->latest()->first();
|
||||
$invoiceYear = Carbon::parse($latestInvoice->created_at)->year;
|
||||
|
||||
if(Carbon::now()->year > $invoiceYear || $force) {
|
||||
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)
|
||||
{
|
||||
@ -67,14 +70,14 @@ class SendRecurringInvoices extends Command
|
||||
$shouldSendToday = $recurInvoice->shouldSendToday();
|
||||
$this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($shouldSendToday ? 'YES' : 'NO'));
|
||||
|
||||
if ( ! $shouldSendToday) {
|
||||
if (! $shouldSendToday) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -77,6 +80,14 @@ class SendReminders extends Command
|
||||
}
|
||||
|
||||
$this->info('Done');
|
||||
|
||||
if ($errorEmail = env('ERROR_EMAIL')) {
|
||||
\Mail::raw('EOM', function ($message) use ($errorEmail) {
|
||||
$message->to($errorEmail)
|
||||
->from(CONTACT_EMAIL)
|
||||
->subject('SendReminders: Finished successfully');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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,7 +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'));
|
||||
@ -44,7 +43,7 @@ if (!defined('APP_NAME'))
|
||||
|
||||
define('PERSON_CONTACT', 'contact');
|
||||
define('PERSON_USER', 'user');
|
||||
define('PERSON_VENDOR_CONTACT','vendorcontact');
|
||||
define('PERSON_VENDOR_CONTACT', 'vendorcontact');
|
||||
|
||||
define('BASIC_SETTINGS', 'basic_settings');
|
||||
define('ADVANCED_SETTINGS', 'advanced_settings');
|
||||
@ -74,7 +73,7 @@ if (!defined('APP_NAME'))
|
||||
define('ACCOUNT_API_TOKENS', 'api_tokens');
|
||||
define('ACCOUNT_CUSTOMIZE_DESIGN', 'customize_design');
|
||||
define('ACCOUNT_SYSTEM_SETTINGS', 'system_settings');
|
||||
define('ACCOUNT_PAYMENT_TERMS','payment_terms');
|
||||
define('ACCOUNT_PAYMENT_TERMS', 'payment_terms');
|
||||
|
||||
define('ACTION_RESTORE', 'restore');
|
||||
define('ACTION_ARCHIVE', 'archive');
|
||||
@ -129,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);
|
||||
@ -141,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');
|
||||
@ -181,7 +179,8 @@ if (!defined('APP_NAME'))
|
||||
define('INVOICE_STATUS_APPROVED', 4);
|
||||
define('INVOICE_STATUS_PARTIAL', 5);
|
||||
define('INVOICE_STATUS_PAID', 6);
|
||||
define('INVOICE_STATUS_OVERDUE', 7);
|
||||
define('INVOICE_STATUS_OVERDUE', -1);
|
||||
define('INVOICE_STATUS_UNPAID', -2);
|
||||
|
||||
define('PAYMENT_STATUS_PENDING', 1);
|
||||
define('PAYMENT_STATUS_VOIDED', 2);
|
||||
@ -205,9 +204,10 @@ if (!defined('APP_NAME'))
|
||||
define('FREQUENCY_TWO_WEEKS', 2);
|
||||
define('FREQUENCY_FOUR_WEEKS', 3);
|
||||
define('FREQUENCY_MONTHLY', 4);
|
||||
define('FREQUENCY_THREE_MONTHS', 5);
|
||||
define('FREQUENCY_SIX_MONTHS', 6);
|
||||
define('FREQUENCY_ANNUALLY', 7);
|
||||
define('FREQUENCY_TWO_MONTHS', 5);
|
||||
define('FREQUENCY_THREE_MONTHS', 6);
|
||||
define('FREQUENCY_SIX_MONTHS', 7);
|
||||
define('FREQUENCY_ANNUALLY', 8);
|
||||
|
||||
define('SESSION_TIMEZONE', 'timezone');
|
||||
define('SESSION_CURRENCY', 'currency');
|
||||
@ -242,7 +242,6 @@ if (!defined('APP_NAME'))
|
||||
define('RESULT_SUCCESS', 'success');
|
||||
define('RESULT_FAILURE', 'failure');
|
||||
|
||||
|
||||
define('PAYMENT_LIBRARY_OMNIPAY', 1);
|
||||
define('PAYMENT_LIBRARY_PHP_PAYMENTS', 2);
|
||||
|
||||
@ -292,7 +291,7 @@ if (!defined('APP_NAME'))
|
||||
define('NINJA_APP_URL', env('NINJA_APP_URL', 'https://app.invoiceninja.com'));
|
||||
define('NINJA_DOCS_URL', env('NINJA_DOCS_URL', 'http://docs.invoiceninja.com/en/latest'));
|
||||
define('NINJA_DATE', '2000-01-01');
|
||||
define('NINJA_VERSION', '3.0.5' . env('NINJA_VERSION_SUFFIX'));
|
||||
define('NINJA_VERSION', '3.1.0' . env('NINJA_VERSION_SUFFIX'));
|
||||
|
||||
define('SOCIAL_LINK_FACEBOOK', env('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja'));
|
||||
define('SOCIAL_LINK_TWITTER', env('SOCIAL_LINK_TWITTER', 'https://twitter.com/invoiceninja'));
|
||||
@ -394,6 +393,12 @@ if (!defined('APP_NAME'))
|
||||
define('REMINDER2', 'reminder2');
|
||||
define('REMINDER3', 'reminder3');
|
||||
|
||||
define('RESET_FREQUENCY_DAILY', 1);
|
||||
define('RESET_FREQUENCY_WEEKLY', 2);
|
||||
define('RESET_FREQUENCY_MONTHLY', 3);
|
||||
define('RESET_FREQUENCY_QUATERLY', 4);
|
||||
define('RESET_FREQUENCY_YEARLY', 5);
|
||||
|
||||
define('REMINDER_DIRECTION_AFTER', 1);
|
||||
define('REMINDER_DIRECTION_BEFORE', 2);
|
||||
|
||||
@ -470,7 +475,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
|
||||
@ -485,7 +490,7 @@ if (!defined('APP_NAME'))
|
||||
define('WEPAY_AUTO_UPDATE', env('WEPAY_AUTO_UPDATE', false));
|
||||
define('WEPAY_ENVIRONMENT', env('WEPAY_ENVIRONMENT', WEPAY_PRODUCTION));
|
||||
define('WEPAY_ENABLE_CANADA', env('WEPAY_ENABLE_CANADA', false));
|
||||
define('WEPAY_THEME', env('WEPAY_THEME','{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}'));
|
||||
define('WEPAY_THEME', env('WEPAY_THEME', '{"name":"Invoice Ninja","primary_color":"0b4d78","secondary_color":"0b4d78","background_color":"f8f8f8","button_color":"33b753"}'));
|
||||
|
||||
define('SKYPE_CARD_RECEIPT', 'message/card.receipt');
|
||||
define('SKYPE_CARD_CAROUSEL', 'message/card.carousel');
|
||||
@ -515,7 +520,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));
|
||||
|
||||
@ -540,7 +545,6 @@ if (!defined('APP_NAME'))
|
||||
];
|
||||
define('CACHED_TABLES', serialize($cachedTables));
|
||||
|
||||
|
||||
// TODO remove these translation functions
|
||||
function uctrans($text)
|
||||
{
|
||||
@ -557,6 +561,7 @@ if (!defined('APP_NAME'))
|
||||
} else {
|
||||
$string = trans($text);
|
||||
$english = trans($text, [], 'en');
|
||||
|
||||
return $string != $english ? $string : '';
|
||||
}
|
||||
}
|
||||
@ -564,12 +569,12 @@ if (!defined('APP_NAME'))
|
||||
// include modules in translations
|
||||
function mtrans($entityType, $text = false)
|
||||
{
|
||||
if ( ! $text) {
|
||||
if (! $text) {
|
||||
$text = $entityType;
|
||||
}
|
||||
|
||||
// check if this has been translated in a module language file
|
||||
if ( ! Utils::isNinjaProd() && $module = Module::find($entityType)) {
|
||||
if (! Utils::isNinjaProd() && $module = Module::find($entityType)) {
|
||||
$key = "{$module->getLowerName()}::texts.{$text}";
|
||||
$value = trans($key);
|
||||
if ($key != $value) {
|
||||
|
@ -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,15 +1,15 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Credit;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class CreditWasArchived
|
||||
* Class CreditWasArchived.
|
||||
*/
|
||||
class CreditWasArchived extends Event
|
||||
{
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
@ -26,5 +26,4 @@ class CreditWasArchived extends Event
|
||||
{
|
||||
$this->credit = $credit;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Credit;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class CreditWasCreated extends Event
|
||||
{
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
@ -22,5 +23,4 @@ class CreditWasCreated extends Event
|
||||
{
|
||||
$this->credit = $credit;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Credit;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class CreditWasDeleted
|
||||
* Class CreditWasDeleted.
|
||||
*/
|
||||
class CreditWasDeleted extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
class CreditWasDeleted extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Credit
|
||||
@ -24,5 +26,4 @@ class CreditWasDeleted extends Event {
|
||||
{
|
||||
$this->credit = $credit;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,16 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Credit;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class CreditWasRestored
|
||||
* Class CreditWasRestored.
|
||||
*/
|
||||
class CreditWasRestored extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
class CreditWasRestored extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Credit
|
||||
@ -25,5 +26,4 @@ class CreditWasRestored extends Event {
|
||||
{
|
||||
$this->credit = $credit;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -24,5 +26,4 @@ class ExpenseWasArchived extends Event
|
||||
{
|
||||
$this->expense = $expense;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -24,5 +26,4 @@ class ExpenseWasDeleted extends Event
|
||||
{
|
||||
$this->expense = $expense;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +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
|
||||
{
|
||||
@ -25,5 +26,4 @@ class ExpenseWasRestored extends Event
|
||||
{
|
||||
$this->expense = $expense;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,15 +1,15 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invitation;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class InvoiceInvitationWasEmailed
|
||||
* Class InvoiceInvitationWasEmailed.
|
||||
*/
|
||||
class InvoiceInvitationWasEmailed extends Event
|
||||
{
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
@ -18,7 +18,7 @@ class InvoiceInvitationWasEmailed extends Event
|
||||
public $invitation;
|
||||
|
||||
/**
|
||||
* @var String
|
||||
* @var string
|
||||
*/
|
||||
public $notes;
|
||||
|
||||
@ -26,11 +26,11 @@ class InvoiceInvitationWasEmailed extends Event
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param Invitation $invitation
|
||||
* @param mixed $notes
|
||||
*/
|
||||
public function __construct(Invitation $invitation, $notes)
|
||||
{
|
||||
$this->invitation = $invitation;
|
||||
$this->notes = $notes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,15 +1,17 @@
|
||||
<?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 {
|
||||
|
||||
use SerializesModels;
|
||||
class InvoiceInvitationWasViewed extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Invoice
|
||||
@ -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
|
||||
{
|
||||
@ -24,5 +26,4 @@ class InvoiceWasArchived extends Event
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -24,5 +26,4 @@ class InvoiceWasCreated extends Event
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,11 +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
|
||||
{
|
||||
@ -29,5 +30,4 @@ class InvoiceWasRestored extends Event
|
||||
$this->invoice = $invoice;
|
||||
$this->fromDeleted = $fromDeleted;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -24,5 +26,4 @@ class PaymentCompleted extends Event
|
||||
{
|
||||
$this->payment = $payment;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -24,5 +26,4 @@ class PaymentWasArchived extends Event
|
||||
{
|
||||
$this->payment = $payment;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class PaymentWasCreated
|
||||
* Class PaymentWasCreated.
|
||||
*/
|
||||
class PaymentWasCreated extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Payment
|
||||
|
@ -10,7 +10,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
*/
|
||||
class PaymentWasDeleted extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* @var Payment
|
||||
|
@ -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,5 +1,6 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Invoice;
|
||||
@ -20,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;
|
||||
|
||||
@ -24,11 +26,11 @@ class QuoteInvitationWasEmailed extends Event
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param Invitation $invitation
|
||||
* @param mixed $notes
|
||||
*/
|
||||
public function __construct(Invitation $invitation, $notes)
|
||||
{
|
||||
$this->invitation = $invitation;
|
||||
$this->notes = $notes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Invitation;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Class QuoteInvitationWasViewed
|
||||
* Class QuoteInvitationWasViewed.
|
||||
*/
|
||||
class QuoteInvitationWasViewed extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
use SerializesModels;
|
||||
|
||||
public $quote;
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php namespace App\Events;
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
@ -16,5 +18,4 @@ class QuoteWasArchived extends Event
|
||||
{
|
||||
$this->quote = $quote;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -19,5 +21,4 @@ class QuoteWasUpdated extends Event
|
||||
{
|
||||
$this->quote = $quote;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -24,5 +26,4 @@ class TaskWasArchived extends Event
|
||||
{
|
||||
$this->task = $task;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +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
|
||||
{
|
||||
@ -24,5 +26,4 @@ class TaskWasDeleted extends Event
|
||||
{
|
||||
$this->task = $task;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +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
|
||||
{
|
||||
@ -25,5 +26,4 @@ class TaskWasRestored extends Event
|
||||
{
|
||||
$this->task = $task;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +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,48 +1,48 @@
|
||||
<?php namespace App\Exceptions;
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Braintree\Util;
|
||||
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.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
AuthorizationException::class,
|
||||
HttpException::class,
|
||||
ModelNotFoundException::class,
|
||||
ValidationException::class,
|
||||
];
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
public function report(Exception $e)
|
||||
{
|
||||
// don't show these errors in the logs
|
||||
if ($e instanceof NotFoundHttpException) {
|
||||
if (Crawler::isCrawler()) {
|
||||
@ -54,24 +54,27 @@ class Handler extends ExceptionHandler
|
||||
|
||||
if (Utils::isNinja() && ! Utils::isTravis()) {
|
||||
Utils::logError(Utils::getErrorString($e));
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return parent::report($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($e instanceof ModelNotFoundException) {
|
||||
return Redirect::to('/');
|
||||
} if ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
||||
}
|
||||
if ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
||||
// prevent loop since the page auto-submits
|
||||
if ($request->path() != 'get_started') {
|
||||
// https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e
|
||||
@ -79,35 +82,32 @@ class Handler extends ExceptionHandler
|
||||
->back()
|
||||
->withInput($request->except('password', '_token'))
|
||||
->with([
|
||||
'warning' => trans('texts.token_expired')
|
||||
'warning' => trans('texts.token_expired'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->isHttpException($e))
|
||||
{
|
||||
switch ($e->getStatusCode())
|
||||
{
|
||||
if ($this->isHttpException($e)) {
|
||||
switch ($e->getStatusCode()) {
|
||||
// not found
|
||||
case 404:
|
||||
if($request->header('X-Ninja-Token') != '') {
|
||||
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();
|
||||
|
||||
return response()->make($error, 404, $headers);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
// internal error
|
||||
case '500':
|
||||
if($request->header('X-Ninja-Token') != '') {
|
||||
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();
|
||||
|
||||
@ -120,17 +120,17 @@ 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,
|
||||
];
|
||||
|
||||
return response()->view('error', $data);
|
||||
return response()->view('error', $data, 500);
|
||||
} else {
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,51 @@
|
||||
<?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
|
||||
{
|
||||
protected $userMailer;
|
||||
protected $contactMailer;
|
||||
protected $userMailer;
|
||||
protected $contactMailer;
|
||||
|
||||
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
|
||||
{
|
||||
$this->userMailer = $userMailer;
|
||||
$this->contactMailer = $contactMailer;
|
||||
}
|
||||
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
|
||||
{
|
||||
$this->userMailer = $userMailer;
|
||||
$this->contactMailer = $contactMailer;
|
||||
}
|
||||
|
||||
public function subscribe($events)
|
||||
{
|
||||
$events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
|
||||
$events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
|
||||
$events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
|
||||
}
|
||||
public function subscribe($events)
|
||||
{
|
||||
$events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
|
||||
$events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
|
||||
$events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
|
||||
}
|
||||
|
||||
public function onSent($invoice)
|
||||
{
|
||||
$this->sendNotifications($invoice, 'sent');
|
||||
}
|
||||
public function onSent($invoice)
|
||||
{
|
||||
$this->sendNotifications($invoice, 'sent');
|
||||
}
|
||||
|
||||
public function onViewed($invoice)
|
||||
{
|
||||
$this->sendNotifications($invoice, 'viewed');
|
||||
}
|
||||
public function onViewed($invoice)
|
||||
{
|
||||
$this->sendNotifications($invoice, 'viewed');
|
||||
}
|
||||
|
||||
public function onPaid($payment)
|
||||
{
|
||||
$this->contactMailer->sendPaymentConfirmation($payment);
|
||||
public function onPaid($payment)
|
||||
{
|
||||
$this->contactMailer->sendPaymentConfirmation($payment);
|
||||
|
||||
$this->sendNotifications($payment->invoice, 'paid', $payment);
|
||||
}
|
||||
$this->sendNotifications($payment->invoice, 'paid', $payment);
|
||||
}
|
||||
|
||||
private function sendNotifications($invoice, $type, $payment = null)
|
||||
{
|
||||
foreach ($invoice->account->users as $user)
|
||||
{
|
||||
if ($user->{'notify_' . $type})
|
||||
{
|
||||
private function sendNotifications($invoice, $type, $payment = null)
|
||||
{
|
||||
foreach ($invoice->account->users as $user) {
|
||||
if ($user->{'notify_' . $type}) {
|
||||
$this->userMailer->sendNotification($user, $invoice, $type, $payment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
@ -36,7 +38,6 @@ class AccountApiController extends BaseAPIController
|
||||
|
||||
public function register(RegisterRequest $request)
|
||||
{
|
||||
|
||||
$account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password);
|
||||
$user = $account->users()->first();
|
||||
|
||||
@ -52,7 +53,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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,20 +116,18 @@ class AccountApiController extends BaseAPIController
|
||||
$account = Auth::user()->account;
|
||||
|
||||
//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);
|
||||
$devices = json_decode($account->devices, true);
|
||||
|
||||
|
||||
for($x=0; $x<count($devices); $x++)
|
||||
{
|
||||
if ($devices[$x]['email'] == Auth::user()->username) {
|
||||
$devices[$x]['token'] = $request->token; //update
|
||||
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);
|
||||
$account->save();
|
||||
$devices[$x]['account_key'] = $account->account_key;
|
||||
$account->save();
|
||||
$devices[$x]['account_key'] = $account->account_key;
|
||||
|
||||
return $this->response($devices[$x]);
|
||||
}
|
||||
return $this->response($devices[$x]);
|
||||
}
|
||||
}
|
||||
|
||||
//User does not have a device, create new record
|
||||
|
||||
@ -136,10 +136,10 @@ class AccountApiController extends BaseAPIController
|
||||
'email' => $request->email,
|
||||
'device' => $request->device,
|
||||
'account_key' => $account->account_key,
|
||||
'notify_sent' => TRUE,
|
||||
'notify_viewed' => TRUE,
|
||||
'notify_approved' => TRUE,
|
||||
'notify_paid' => TRUE,
|
||||
'notify_sent' => true,
|
||||
'notify_viewed' => true,
|
||||
'notify_approved' => true,
|
||||
'notify_paid' => true,
|
||||
];
|
||||
|
||||
$devices[] = $newDevice;
|
||||
@ -147,23 +147,20 @@ class AccountApiController extends BaseAPIController
|
||||
$account->save();
|
||||
|
||||
return $this->response($newDevice);
|
||||
|
||||
}
|
||||
|
||||
public function updatePushNotifications(Request $request)
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
|
||||
$devices = json_decode($account->devices, TRUE);
|
||||
$devices = json_decode($account->devices, true);
|
||||
|
||||
if(count($devices) < 1)
|
||||
return $this->errorResponse(['message'=>'No registered devices.'], 400);
|
||||
|
||||
for($x=0; $x<count($devices); $x++)
|
||||
{
|
||||
if($devices[$x]['email'] == Auth::user()->username)
|
||||
{
|
||||
if (count($devices) < 1) {
|
||||
return $this->errorResponse(['message' => 'No registered devices.'], 400);
|
||||
}
|
||||
|
||||
for ($x = 0; $x < count($devices); $x++) {
|
||||
if ($devices[$x]['email'] == Auth::user()->username) {
|
||||
$newDevice = [
|
||||
'token' => $devices[$x]['token'],
|
||||
'email' => $devices[$x]['email'],
|
||||
@ -182,7 +179,6 @@ class AccountApiController extends BaseAPIController
|
||||
return $this->response($newDevice);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function oauthLogin(Request $request)
|
||||
@ -204,9 +200,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,
|
||||
@ -87,8 +89,7 @@ class AccountController extends BaseController
|
||||
ContactMailer $contactMailer,
|
||||
ReferralRepository $referralRepository,
|
||||
PaymentService $paymentService
|
||||
)
|
||||
{
|
||||
) {
|
||||
$this->accountRepo = $accountRepo;
|
||||
$this->userMailer = $userMailer;
|
||||
$this->contactMailer = $contactMailer;
|
||||
@ -103,7 +104,7 @@ class AccountController extends BaseController
|
||||
{
|
||||
$demoAccountId = Utils::getDemoAccountId();
|
||||
|
||||
if (!$demoAccountId) {
|
||||
if (! $demoAccountId) {
|
||||
return Redirect::to('/');
|
||||
}
|
||||
|
||||
@ -128,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) {
|
||||
@ -140,7 +141,7 @@ class AccountController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
if (! $user) {
|
||||
$account = $this->accountRepo->create();
|
||||
$user = $account->users()->first();
|
||||
|
||||
@ -161,7 +162,8 @@ class AccountController extends BaseController
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function changePlan() {
|
||||
public function changePlan()
|
||||
{
|
||||
$user = Auth::user();
|
||||
$account = $user->account;
|
||||
$company = $account->company;
|
||||
@ -171,7 +173,7 @@ class AccountController extends BaseController
|
||||
$numUsers = Input::get('num_users');
|
||||
|
||||
if ($plan != PLAN_ENTERPRISE) {
|
||||
$numUsers = 1;
|
||||
$numUsers = 1;
|
||||
}
|
||||
|
||||
$planDetails = $account->getPlanDetails(false, false);
|
||||
@ -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;
|
||||
@ -221,12 +223,11 @@ class AccountController extends BaseController
|
||||
if ($newPlan['price'] > $credit) {
|
||||
$invitation = $this->accountRepo->enablePlan($newPlan, $credit);
|
||||
if ($hasPaid) {
|
||||
return Redirect::to('view/' . $invitation->invitation_key);
|
||||
return Redirect::to('view/' . $invitation->invitation_key);
|
||||
} else {
|
||||
return Redirect::to('payment/' . $invitation->invitation_key);
|
||||
return Redirect::to('payment/' . $invitation->invitation_key);
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($plan == PLAN_FREE) {
|
||||
$company->discount = 0;
|
||||
} else {
|
||||
@ -244,10 +245,11 @@ class AccountController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $entityType
|
||||
* @param $visible
|
||||
* @param mixed $filter
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setEntityFilter($entityType, $filter = '')
|
||||
@ -268,8 +270,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;
|
||||
}
|
||||
@ -286,15 +288,16 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param bool $section
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function showSection($section = false)
|
||||
{
|
||||
if ( ! Auth::user()->is_admin) {
|
||||
if (! Auth::user()->is_admin) {
|
||||
return Redirect::to('/settings/user_details');
|
||||
}
|
||||
|
||||
if (!$section) {
|
||||
if (! $section) {
|
||||
return Redirect::to('/settings/'.ACCOUNT_COMPANY_DETAILS, 301);
|
||||
}
|
||||
|
||||
@ -363,7 +366,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 {
|
||||
@ -489,17 +492,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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -539,7 +542,6 @@ class AccountController extends BaseController
|
||||
$data = [
|
||||
'account' => Auth::user()->account,
|
||||
'title' => trans('texts.payment_terms'),
|
||||
'taxRates' => PaymentTerm::scope()->get(['id', 'name', 'num_days']),
|
||||
];
|
||||
|
||||
return View::make('accounts.payment_terms', $data);
|
||||
@ -547,6 +549,7 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param $section
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
*/
|
||||
private function showInvoiceDesign($section)
|
||||
@ -609,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()
|
||||
@ -652,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) {
|
||||
@ -695,7 +698,6 @@ class AccountController extends BaseController
|
||||
'template' => $account->getDefaultEmailTemplate($type),
|
||||
];
|
||||
}
|
||||
$data['emailFooter'] = $account->getEmailFooter();
|
||||
$data['title'] = trans('texts.email_templates');
|
||||
|
||||
return View::make('accounts.templates_and_reminders', $data);
|
||||
@ -703,34 +705,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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -749,10 +752,11 @@ class AccountController extends BaseController
|
||||
$account->live_preview = Input::get('live_preview') ? true : false;
|
||||
|
||||
// Automatically disable live preview when using a large font
|
||||
$fonts = Cache::get('fonts')->filter(function($font) use ($account) {
|
||||
$fonts = Cache::get('fonts')->filter(function ($font) use ($account) {
|
||||
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)) {
|
||||
@ -792,7 +796,8 @@ class AccountController extends BaseController
|
||||
{
|
||||
$account = $request->user()->account;
|
||||
$account->fill($request->all());
|
||||
$account->subdomain = $request->subdomain;
|
||||
$account->client_view_css = $request->client_view_css;
|
||||
$account->subdomain = $request->subdomain;
|
||||
$account->iframe_url = $request->iframe_url;
|
||||
$account->save();
|
||||
|
||||
@ -835,12 +840,9 @@ class AccountController extends BaseController
|
||||
foreach ([REMINDER1, REMINDER2, REMINDER3] as $type) {
|
||||
$enableField = "enable_{$type}";
|
||||
$account->$enableField = Input::get($enableField) ? true : false;
|
||||
|
||||
if ($account->$enableField) {
|
||||
$account->{"num_days_{$type}"} = Input::get("num_days_{$type}");
|
||||
$account->{"field_{$type}"} = Input::get("field_{$type}");
|
||||
$account->{"direction_{$type}"} = Input::get("field_{$type}") == REMINDER_FIELD_INVOICE_DATE ? REMINDER_DIRECTION_AFTER : Input::get("direction_{$type}");
|
||||
}
|
||||
$account->{"num_days_{$type}"} = Input::get("num_days_{$type}");
|
||||
$account->{"field_{$type}"} = Input::get("field_{$type}");
|
||||
$account->{"direction_{$type}"} = Input::get("field_{$type}") == REMINDER_FIELD_INVOICE_DATE ? REMINDER_DIRECTION_AFTER : Input::get("direction_{$type}");
|
||||
}
|
||||
|
||||
$account->save();
|
||||
@ -935,7 +937,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');
|
||||
}
|
||||
|
||||
@ -949,7 +951,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'));
|
||||
@ -1019,6 +1021,7 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param UpdateAccountRequest $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function updateDetails(UpdateAccountRequest $request)
|
||||
@ -1036,14 +1039,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{
|
||||
} 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];
|
||||
@ -1051,7 +1053,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') {
|
||||
@ -1072,7 +1074,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 {
|
||||
@ -1128,7 +1130,7 @@ class AccountController extends BaseController
|
||||
$user->email = trim(strtolower(Input::get('email')));
|
||||
$user->phone = trim(Input::get('phone'));
|
||||
|
||||
if ( ! Auth::user()->is_admin) {
|
||||
if (! Auth::user()->is_admin) {
|
||||
$user->notify_sent = Input::get('notify_sent');
|
||||
$user->notify_viewed = Input::get('notify_viewed');
|
||||
$user->notify_paid = Input::get('notify_paid');
|
||||
@ -1136,7 +1138,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();
|
||||
}
|
||||
}
|
||||
@ -1204,7 +1206,7 @@ class AccountController extends BaseController
|
||||
$gateway_type_id = intval(Input::get('gateway_type_id'));
|
||||
$gateway_settings = AccountGatewaySettings::scope()->where('gateway_type_id', '=', $gateway_type_id)->first();
|
||||
|
||||
if ( ! $gateway_settings) {
|
||||
if (! $gateway_settings) {
|
||||
$gateway_settings = AccountGatewaySettings::createNew();
|
||||
$gateway_settings->gateway_type_id = $gateway_type_id;
|
||||
}
|
||||
@ -1308,7 +1310,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;
|
||||
}
|
||||
|
||||
@ -1348,15 +1350,16 @@ class AccountController extends BaseController
|
||||
$account = Auth::user()->account;
|
||||
\Log::info("Canceled Account: {$account->name} - {$user->email}");
|
||||
|
||||
Document::scope()->each(function($item, $key) {
|
||||
Document::scope()->each(function ($item, $key) {
|
||||
$item->delete();
|
||||
});
|
||||
|
||||
$this->accountRepo->unlinkAccount($account);
|
||||
if ($account->company->accounts->count() == 1) {
|
||||
$account->company->forceDelete();
|
||||
} else {
|
||||
|
||||
if ($account->hasMultipleAccounts()) {
|
||||
$account->forceDelete();
|
||||
} else {
|
||||
$account->company->forceDelete();
|
||||
}
|
||||
|
||||
Auth::logout();
|
||||
@ -1380,6 +1383,7 @@ class AccountController extends BaseController
|
||||
/**
|
||||
* @param $section
|
||||
* @param bool $subSection
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function redirectLegacy($section, $subSection = false)
|
||||
@ -1395,7 +1399,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 +1408,7 @@ class AccountController extends BaseController
|
||||
|
||||
/**
|
||||
* @param TemplateService $templateService
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function previewEmail(TemplateService $templateService)
|
||||
@ -1414,7 +1419,7 @@ class AccountController extends BaseController
|
||||
->withTrashed()
|
||||
->first();
|
||||
|
||||
if ( ! $invoice) {
|
||||
if (! $invoice) {
|
||||
return trans('texts.create_invoice_for_sample');
|
||||
}
|
||||
|
||||
@ -1429,7 +1434,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,12 +78,11 @@ class AccountGatewayController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the form for account creation
|
||||
*
|
||||
* Displays the form for account creation.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
if ( ! \Request::secure() && ! Utils::isNinjaDev()) {
|
||||
if (! \Request::secure() && ! Utils::isNinjaDev()) {
|
||||
Session::flash('warning', trans('texts.enable_https'));
|
||||
}
|
||||
|
||||
@ -89,7 +90,7 @@ class AccountGatewayController extends BaseController
|
||||
$accountGatewaysIds = $account->gatewayIds();
|
||||
$otherProviders = Input::get('other_providers');
|
||||
|
||||
if ( ! Utils::isNinja() || ! env('WEPAY_CLIENT_ID') || Gateway::hasStandardGateway($accountGatewaysIds)) {
|
||||
if (! Utils::isNinja() || ! env('WEPAY_CLIENT_ID') || Gateway::hasStandardGateway($accountGatewaysIds)) {
|
||||
$otherProviders = true;
|
||||
}
|
||||
|
||||
@ -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 = [];
|
||||
@ -132,7 +133,7 @@ class AccountGatewayController extends BaseController
|
||||
|
||||
foreach ($gateways as $gateway) {
|
||||
$fields = $gateway->getFields();
|
||||
if ( ! $gateway->isCustom()) {
|
||||
if (! $gateway->isCustom()) {
|
||||
asort($fields);
|
||||
}
|
||||
$gateway->fields = $gateway->id == GATEWAY_WEPAY ? [] : $fields;
|
||||
@ -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,9 @@ class AccountGatewayController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores new account
|
||||
* Stores new account.
|
||||
*
|
||||
* @param mixed $accountGatewayPublicId
|
||||
*/
|
||||
public function save($accountGatewayPublicId = false)
|
||||
{
|
||||
@ -190,7 +191,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 +225,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 +233,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 +249,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);
|
||||
@ -255,7 +257,7 @@ class AccountGatewayController extends BaseController
|
||||
$config->$field = $value;
|
||||
}
|
||||
}
|
||||
} elseif($oldConfig) {
|
||||
} elseif ($oldConfig) {
|
||||
$config = clone $oldConfig;
|
||||
}
|
||||
|
||||
@ -321,11 +323,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 +354,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'),
|
||||
]);
|
||||
|
||||
@ -383,7 +387,7 @@ class AccountGatewayController extends BaseController
|
||||
->withInput();
|
||||
}
|
||||
|
||||
try{
|
||||
try {
|
||||
$wepay = Utils::setupWePay();
|
||||
|
||||
$userDetails = [
|
||||
@ -407,11 +411,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) {
|
||||
@ -428,9 +432,9 @@ class AccountGatewayController extends BaseController
|
||||
try {
|
||||
$wepay->request('user/send_confirmation/', []);
|
||||
$confirmationRequired = true;
|
||||
} catch(\WePayException $ex){
|
||||
} catch (\WePayException $ex) {
|
||||
if ($ex->getMessage() == 'This access_token is already approved.') {
|
||||
$confirmationRequired = false;
|
||||
$confirmationRequired = false;
|
||||
} else {
|
||||
throw $ex;
|
||||
}
|
||||
@ -457,20 +461,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();
|
||||
@ -488,5 +494,4 @@ class AccountGatewayController extends BaseController
|
||||
|
||||
return Redirect::to("gateways/{$accountGateway->public_id}/edit");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,18 +115,14 @@ class AppController extends BaseController
|
||||
$config .= "{$key}={$val}\n";
|
||||
}
|
||||
|
||||
|
||||
// Write Config Settings
|
||||
$fp = fopen(base_path().'/.env', 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
|
||||
// == DB Migrate & Seed == //
|
||||
// Artisan::call('migrate:rollback', array('--force' => true)); // Debug Purposes
|
||||
Artisan::call('migrate', ['--force' => true]);
|
||||
if (Industry::count() == 0) {
|
||||
Artisan::call('db:seed', ['--force' => true]);
|
||||
}
|
||||
$sqlFile = base_path() . '/database/setup.sql';
|
||||
DB::unprepared(file_get_contents($sqlFile));
|
||||
Cache::flush();
|
||||
Artisan::call('optimize', ['--force' => true]);
|
||||
|
||||
@ -144,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')) {
|
||||
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');
|
||||
}
|
||||
|
||||
@ -186,7 +185,7 @@ class AppController extends BaseController
|
||||
continue;
|
||||
}
|
||||
if (preg_match('/\s/', $val)) {
|
||||
$val = "'{$val}'";
|
||||
$val = "'{$val}'";
|
||||
}
|
||||
$config .= "{$key}={$val}\n";
|
||||
}
|
||||
@ -196,6 +195,7 @@ class AppController extends BaseController
|
||||
fclose($fp);
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
|
||||
return Redirect::to('/settings/system_settings');
|
||||
}
|
||||
|
||||
@ -231,6 +231,7 @@ class AppController extends BaseController
|
||||
|
||||
$data = [
|
||||
'text' => 'Test email',
|
||||
'fromEmail' => $email
|
||||
];
|
||||
|
||||
try {
|
||||
@ -244,7 +245,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]);
|
||||
@ -254,6 +255,7 @@ class AppController extends BaseController
|
||||
Artisan::call('optimize', ['--force' => true]);
|
||||
} catch (Exception $e) {
|
||||
Utils::logError($e);
|
||||
|
||||
return Response::make($e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
@ -263,7 +265,7 @@ class AppController extends BaseController
|
||||
|
||||
public function update()
|
||||
{
|
||||
if (!Utils::isNinjaProd()) {
|
||||
if (! Utils::isNinjaProd()) {
|
||||
try {
|
||||
set_time_limit(60 * 5);
|
||||
Artisan::call('clear-compiled');
|
||||
@ -280,7 +282,7 @@ class AppController extends BaseController
|
||||
Event::fire(new UserSettingsChanged());
|
||||
|
||||
// legacy fix: check cipher is in .env file
|
||||
if ( ! env('APP_CIPHER')) {
|
||||
if (! env('APP_CIPHER')) {
|
||||
$fp = fopen(base_path().'/.env', 'a');
|
||||
fwrite($fp, "\nAPP_CIPHER=AES-256-CBC");
|
||||
fclose($fp);
|
||||
@ -293,6 +295,7 @@ class AppController extends BaseController
|
||||
Session::flash('warning', $message);
|
||||
} catch (Exception $e) {
|
||||
Utils::logError($e);
|
||||
|
||||
return Response::make($e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
@ -304,12 +307,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;
|
||||
@ -317,8 +322,9 @@ class AppController extends BaseController
|
||||
|
||||
public function stats()
|
||||
{
|
||||
if ( ! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) {
|
||||
if (! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) {
|
||||
sleep(3);
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -332,7 +338,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');
|
||||
}
|
||||
|
||||
@ -127,12 +131,12 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function postLoginWrapper(Request $request)
|
||||
{
|
||||
|
||||
$userId = Auth::check() ? Auth::user()->id : null;
|
||||
$user = User::where('email', '=', $request->input('email'))->first();
|
||||
|
||||
if ($user && $user->failed_logins >= MAX_FAILED_LOGINS) {
|
||||
Session::flash('error', trans('texts.invalid_credentials'));
|
||||
|
||||
return redirect()->to('login');
|
||||
}
|
||||
|
||||
@ -155,7 +159,6 @@ class AuthController extends Controller
|
||||
|
||||
$users = $this->accountRepo->loadAccounts(Auth::user()->id);
|
||||
Session::put(SESSION_USER_ACCOUNTS, $users);
|
||||
|
||||
} elseif ($user) {
|
||||
$user->failed_logins = $user->failed_logins + 1;
|
||||
$user->save();
|
||||
@ -169,10 +172,11 @@ 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);
|
||||
if ($account->company->accounts->count() == 1) {
|
||||
|
||||
if (! $account->hasMultipleAccounts()) {
|
||||
$account->company->forceDelete();
|
||||
}
|
||||
$account->forceDelete();
|
||||
@ -182,6 +186,10 @@ class AuthController extends Controller
|
||||
|
||||
Session::flush();
|
||||
|
||||
if ($reason = request()->reason) {
|
||||
Session::flash('warning', trans("texts.{$reason}_logout"));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -34,5 +35,4 @@ class PasswordController extends Controller
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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(
|
||||
@ -92,13 +94,13 @@ class BaseAPIController extends Controller
|
||||
}
|
||||
|
||||
if ($clientPublicId = Input::get('client_id')) {
|
||||
$filter = function($query) use ($clientPublicId) {
|
||||
$filter = function ($query) use ($clientPublicId) {
|
||||
$query->where('public_id', '=', $clientPublicId);
|
||||
};
|
||||
$query->whereHas('client', $filter);
|
||||
}
|
||||
|
||||
if ( ! Utils::hasPermission('view_all')){
|
||||
if (! Utils::hasPermission('view_all')) {
|
||||
if ($this->entityType == ENTITY_USER) {
|
||||
$query->where('id', '=', Auth::user()->id);
|
||||
} else {
|
||||
@ -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) {
|
||||
@ -174,14 +177,13 @@ class BaseAPIController extends Controller
|
||||
return Response::make($response, 200, $headers);
|
||||
}
|
||||
|
||||
protected function errorResponse($response, $httpErrorCode = 400)
|
||||
protected function errorResponse($response, $httpErrorCode = 400)
|
||||
{
|
||||
$error['error'] = $response;
|
||||
$error = json_encode($error, JSON_PRETTY_PRINT);
|
||||
$headers = Utils::getApiHeaders();
|
||||
|
||||
return Response::make($error, $httpErrorCode, $headers);
|
||||
|
||||
}
|
||||
|
||||
protected function getRequestIncludes($data)
|
||||
|
@ -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
|
||||
{
|
||||
@ -25,7 +27,7 @@ class BaseController extends Controller
|
||||
|
||||
protected function returnBulk($entityType, $action, $ids)
|
||||
{
|
||||
if ( ! is_array($ids)) {
|
||||
if (! is_array($ids)) {
|
||||
$ids = [$ids];
|
||||
}
|
||||
|
||||
|
@ -5,86 +5,89 @@ namespace App\Http\Controllers;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use URL;
|
||||
use Session;
|
||||
use URL;
|
||||
|
||||
class BlueVineController extends BaseController {
|
||||
public function signup() {
|
||||
$user = Auth::user();
|
||||
class BlueVineController extends BaseController
|
||||
{
|
||||
public function signup()
|
||||
{
|
||||
$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' ) ),
|
||||
'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,
|
||||
);
|
||||
$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,
|
||||
];
|
||||
|
||||
if ( ! empty( Input::get( 'quote_type_factoring' ) ) ) {
|
||||
$data['invoice_factoring_offer'] = true;
|
||||
$data['desired_credit_line'] = intval( Input::get( 'desired_credit_limit' )['invoice_factoring'] );
|
||||
}
|
||||
if (! empty(Input::get('quote_type_factoring'))) {
|
||||
$data['invoice_factoring_offer'] = true;
|
||||
$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['desired_credit_line_for_loc'] = intval( Input::get( 'desired_credit_limit' )['line_of_credit'] );
|
||||
}
|
||||
if (! empty(Input::get('quote_type_loc'))) {
|
||||
$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([
|
||||
'external_register_token' => env('BLUEVINE_PARTNER_TOKEN'),
|
||||
'c' => env('BLUEVINE_PARTNER_UNIQUE_ID'),
|
||||
'signup_parent_url' => URL::to('/bluevine/completed'),
|
||||
]), [
|
||||
'json' => $data,
|
||||
]
|
||||
);
|
||||
} catch (\GuzzleHttp\Exception\RequestException $ex) {
|
||||
if ($ex->getCode() == 403) {
|
||||
$response_body = $ex->getResponse()->getBody(true);
|
||||
$response_data = json_decode($response_body);
|
||||
|
||||
$api_client = new \GuzzleHttp\Client();
|
||||
try {
|
||||
$response = $api_client->request( 'POST',
|
||||
'https://app.bluevine.com/api/v1/user/register_external?' . http_build_query( array(
|
||||
'external_register_token' => env( 'BLUEVINE_PARTNER_TOKEN' ),
|
||||
'c' => env( 'BLUEVINE_PARTNER_UNIQUE_ID' ),
|
||||
'signup_parent_url' => URL::to( '/bluevine/completed' ),
|
||||
) ), array(
|
||||
'json' => $data
|
||||
)
|
||||
);
|
||||
} catch ( \GuzzleHttp\Exception\RequestException $ex ) {
|
||||
if ( $ex->getCode() == 403 ) {
|
||||
$response_body = $ex->getResponse()->getBody( true );
|
||||
$response_data = json_decode( $response_body );
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => $response_data->reason,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json( [
|
||||
'error' => true,
|
||||
'message' => $response_data->reason
|
||||
] );
|
||||
} else {
|
||||
return response()->json( [
|
||||
'error' => true
|
||||
] );
|
||||
}
|
||||
}
|
||||
$company = $user->account->company;
|
||||
$company->bluevine_status = 'signed_up';
|
||||
$company->save();
|
||||
|
||||
$company = $user->account->company;
|
||||
$company->bluevine_status = 'signed_up';
|
||||
$company->save();
|
||||
$quote_data = json_decode($response->getBody());
|
||||
|
||||
$quote_data = json_decode( $response->getBody() );
|
||||
return response()->json($quote_data);
|
||||
}
|
||||
|
||||
return response()->json( $quote_data );
|
||||
}
|
||||
public function hideMessage()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
public function hideMessage() {
|
||||
$user = Auth::user();
|
||||
if ($user) {
|
||||
$company = $user->account->company;
|
||||
$company->bluevine_status = 'ignored';
|
||||
$company->save();
|
||||
}
|
||||
|
||||
if ( $user ) {
|
||||
$company = $user->account->company;
|
||||
$company->bluevine_status = 'ignored';
|
||||
$company->save();
|
||||
}
|
||||
return 'success';
|
||||
}
|
||||
|
||||
return 'success';
|
||||
}
|
||||
public function handleCompleted()
|
||||
{
|
||||
Session::flash('message', trans('texts.bluevine_completed'));
|
||||
|
||||
public function handleCompleted() {
|
||||
Session::flash( 'message', trans( 'texts.bluevine_completed' ) );
|
||||
|
||||
return Redirect::to( '/dashboard' );
|
||||
}
|
||||
return Redirect::to('/dashboard');
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -29,7 +29,7 @@ class BotController extends Controller
|
||||
$input = Input::all();
|
||||
$botUserId = $input['from']['id'];
|
||||
|
||||
if ( ! $token = $this->authenticate($input)) {
|
||||
if (! $token = $this->authenticate($input)) {
|
||||
return SkypeResponse::message(trans('texts.not_authorized'));
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ class BotController extends Controller
|
||||
} elseif ($input['action'] === 'remove') {
|
||||
$this->removeBot($botUserId);
|
||||
$this->saveState($token, false);
|
||||
|
||||
return RESULT_SUCCESS;
|
||||
}
|
||||
} else {
|
||||
@ -71,7 +72,7 @@ class BotController extends Controller
|
||||
} elseif ($text == 'status') {
|
||||
$response = SkypeResponse::message(trans('texts.intent_not_supported'));
|
||||
} else {
|
||||
if ( ! $user = User::whereBotUserId($botUserId)->with('account')->first()) {
|
||||
if (! $user = User::whereBotUserId($botUserId)->with('account')->first()) {
|
||||
return SkypeResponse::message(trans('texts.not_authorized'));
|
||||
}
|
||||
|
||||
@ -102,7 +103,7 @@ class BotController extends Controller
|
||||
|
||||
if (Utils::isNinjaDev()) {
|
||||
// skip validation for testing
|
||||
} elseif ( ! $this->validateToken($token)) {
|
||||
} elseif (! $this->validateToken($token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ class BotController extends Controller
|
||||
|
||||
private function validateEmail($email, $botUserId)
|
||||
{
|
||||
if ( ! $email || ! $botUserId) {
|
||||
if (! $email || ! $botUserId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ class BotController extends Controller
|
||||
->whereNull('bot_user_id')
|
||||
->first();
|
||||
|
||||
if ( ! $user) {
|
||||
if (! $user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ class BotController extends Controller
|
||||
|
||||
private function validateCode($input, $botUserId)
|
||||
{
|
||||
if ( ! $input || ! $botUserId) {
|
||||
if (! $input || ! $botUserId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -230,13 +230,14 @@ class BotController extends Controller
|
||||
->where('attempts', '<', 5)
|
||||
->first();
|
||||
|
||||
if ( ! $code) {
|
||||
if (! $code) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! hash_equals($code->code, $input)) {
|
||||
if (! hash_equals($code->code, $input)) {
|
||||
$code->attempts += 1;
|
||||
$code->save();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -256,7 +257,7 @@ class BotController extends Controller
|
||||
|
||||
private function validateToken($token)
|
||||
{
|
||||
if ( ! $token) {
|
||||
if (! $token) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -273,17 +274,17 @@ class BotController extends Controller
|
||||
$sig_enc = $token_arr[2];
|
||||
|
||||
// 2 base 64 url decoding
|
||||
$headers_arr = json_decode($this->base64_url_decode($headers_enc), TRUE);
|
||||
$claims_arr = json_decode($this->base64_url_decode($claims_enc), TRUE);
|
||||
$headers_arr = json_decode($this->base64_url_decode($headers_enc), true);
|
||||
$claims_arr = json_decode($this->base64_url_decode($claims_enc), true);
|
||||
$sig = $this->base64_url_decode($sig_enc);
|
||||
|
||||
// 3 get key list
|
||||
$keylist = file_get_contents('https://api.aps.skype.com/v1/keys');
|
||||
$keylist_arr = json_decode($keylist, TRUE);
|
||||
foreach($keylist_arr['keys'] as $key => $value) {
|
||||
$keylist_arr = json_decode($keylist, true);
|
||||
foreach ($keylist_arr['keys'] as $key => $value) {
|
||||
|
||||
// 4 select one key (which matches)
|
||||
if($value['kid'] == $headers_arr['kid']) {
|
||||
if ($value['kid'] == $headers_arr['kid']) {
|
||||
|
||||
// 5 get public key from key info
|
||||
$cert_txt = '-----BEGIN CERTIFICATE-----' . "\n" . chunk_split($value['x5c'][0], 64) . '-----END CERTIFICATE-----';
|
||||
@ -298,10 +299,11 @@ class BotController extends Controller
|
||||
}
|
||||
|
||||
// 7 show result
|
||||
return ($token_valid == 1);
|
||||
return $token_valid == 1;
|
||||
}
|
||||
|
||||
private function base64_url_decode($arg) {
|
||||
private function base64_url_decode($arg)
|
||||
{
|
||||
$res = $arg;
|
||||
$res = str_replace('-', '+', $res);
|
||||
$res = str_replace('_', '/', $res);
|
||||
@ -309,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",
|
||||
@ -126,8 +124,9 @@ class ClientApiController extends BaseAPIController
|
||||
* description="an ""unexpected"" error"
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @param mixed $publicId
|
||||
*/
|
||||
|
||||
public function update(UpdateClientRequest $request, $publicId)
|
||||
{
|
||||
if ($request->action) {
|
||||
@ -143,7 +142,6 @@ class ClientApiController extends BaseAPIController
|
||||
return $this->itemResponse($client);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @SWG\Delete(
|
||||
* path="/clients/{client_id}",
|
||||
@ -165,7 +163,6 @@ class ClientApiController extends BaseAPIController
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
|
||||
public function destroy(UpdateClientRequest $request)
|
||||
{
|
||||
$client = $request->entity();
|
||||
@ -174,5 +171,4 @@ class ClientApiController extends BaseAPIController
|
||||
|
||||
return $this->itemResponse($client);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
@ -26,18 +28,9 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function showLoginForm()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$contactKey = session('contact_key');
|
||||
if ($contactKey) {
|
||||
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
||||
if ($contact && !$contact->is_deleted) {
|
||||
$account = $contact->account;
|
||||
|
||||
$data['account'] = $account;
|
||||
$data['clientFontUrl'] = $account->getFontsUrl();
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'clientauth' => true,
|
||||
];
|
||||
|
||||
return view('clientauth.login')->with($data);
|
||||
}
|
||||
@ -45,7 +38,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 +50,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 +61,7 @@ class AuthController extends Controller
|
||||
/**
|
||||
* Validate the user login request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -84,6 +77,6 @@ class AuthController extends Controller
|
||||
*/
|
||||
public function getSessionExpired()
|
||||
{
|
||||
return view('clientauth.sessionexpired');
|
||||
return view('clientauth.sessionexpired')->with(['clientauth' => true]);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -47,16 +48,11 @@ class PasswordController extends Controller
|
||||
*/
|
||||
public function showLinkRequestForm()
|
||||
{
|
||||
$data = [];
|
||||
$data = [
|
||||
'clientauth' => true,
|
||||
];
|
||||
$contactKey = session('contact_key');
|
||||
if ($contactKey) {
|
||||
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
||||
if ($contact && !$contact->is_deleted) {
|
||||
$account = $contact->account;
|
||||
$data['account'] = $account;
|
||||
$data['clientFontUrl'] = $account->getFontsUrl();
|
||||
}
|
||||
} else {
|
||||
if (!$contactKey) {
|
||||
return \Redirect::to('/client/sessionexpired');
|
||||
}
|
||||
|
||||
@ -66,7 +62,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 +74,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 && $contact->email) {
|
||||
$contactId = $contact->id;
|
||||
}
|
||||
}
|
||||
@ -102,9 +98,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)
|
||||
@ -113,25 +110,26 @@ class PasswordController extends Controller
|
||||
return $this->getEmail();
|
||||
}
|
||||
|
||||
$data = compact('token');
|
||||
$data = array(
|
||||
'token' => $token,
|
||||
'clientauth' => true,
|
||||
);
|
||||
|
||||
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)) {
|
||||
$data['account'] = $account;
|
||||
$data['clientFontUrl'] = $account->getFontsUrl();
|
||||
} else {
|
||||
if ( empty($account)) {
|
||||
return \Redirect::to('/client/sessionexpired');
|
||||
}
|
||||
}
|
||||
@ -139,15 +137,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 +156,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 +173,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,25 +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\Contact;
|
||||
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
|
||||
{
|
||||
@ -75,7 +76,8 @@ class ClientController extends BaseController
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function show(ClientRequest $request)
|
||||
@ -84,29 +86,29 @@ class ClientController extends BaseController
|
||||
$user = Auth::user();
|
||||
|
||||
$actionLinks = [];
|
||||
if ($user->can('create', ENTITY_INVOICE)){
|
||||
if ($user->can('create', ENTITY_INVOICE)) {
|
||||
$actionLinks[] = ['label' => trans('texts.new_invoice'), 'url' => URL::to('/invoices/create/'.$client->public_id)];
|
||||
}
|
||||
if ($user->can('create', ENTITY_TASK)){
|
||||
if ($user->can('create', ENTITY_TASK)) {
|
||||
$actionLinks[] = ['label' => trans('texts.new_task'), 'url' => URL::to('/tasks/create/'.$client->public_id)];
|
||||
}
|
||||
if (Utils::hasFeature(FEATURE_QUOTES) && $user->can('create', ENTITY_QUOTE)) {
|
||||
$actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => URL::to('/quotes/create/'.$client->public_id)];
|
||||
}
|
||||
|
||||
if(!empty($actionLinks)){
|
||||
if (! empty($actionLinks)) {
|
||||
$actionLinks[] = \DropdownButton::DIVIDER;
|
||||
}
|
||||
|
||||
if($user->can('create', ENTITY_PAYMENT)){
|
||||
if ($user->can('create', ENTITY_PAYMENT)) {
|
||||
$actionLinks[] = ['label' => trans('texts.enter_payment'), 'url' => URL::to('/payments/create/'.$client->public_id)];
|
||||
}
|
||||
|
||||
if($user->can('create', ENTITY_CREDIT)){
|
||||
if ($user->can('create', ENTITY_CREDIT)) {
|
||||
$actionLinks[] = ['label' => trans('texts.enter_credit'), 'url' => URL::to('/credits/create/'.$client->public_id)];
|
||||
}
|
||||
|
||||
if($user->can('create', ENTITY_EXPENSE)){
|
||||
if ($user->can('create', ENTITY_EXPENSE)) {
|
||||
$actionLinks[] = ['label' => trans('texts.enter_expense'), 'url' => URL::to('/expenses/create/0/'.$client->public_id)];
|
||||
}
|
||||
|
||||
@ -154,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)
|
||||
@ -185,7 +188,6 @@ class ClientController extends BaseController
|
||||
'data' => Input::old('data'),
|
||||
'account' => Auth::user()->account,
|
||||
'sizes' => Cache::get('sizes'),
|
||||
'paymentTerms' => Cache::get('paymentTerms'),
|
||||
'currencies' => Cache::get('currencies'),
|
||||
'customLabel1' => Auth::user()->account->custom_client_label1,
|
||||
'customLabel2' => Auth::user()->account->custom_client_label2,
|
||||
@ -195,7 +197,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,12 +48,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function view($invitationKey)
|
||||
{
|
||||
if (request()->silent) {
|
||||
session(['silent' => true]);
|
||||
return redirect(request()->url());
|
||||
}
|
||||
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -59,19 +56,21 @@ class ClientPortalController extends BaseController
|
||||
$client = $invoice->client;
|
||||
$account = $invoice->account;
|
||||
|
||||
if (!$account->checkSubdomain(Request::server('HTTP_HOST'))) {
|
||||
if (request()->silent) {
|
||||
session(['silent:' . $client->id => true]);
|
||||
return redirect(request()->url());
|
||||
}
|
||||
|
||||
if (! $account->checkSubdomain(Request::server('HTTP_HOST'))) {
|
||||
return response()->view('error', [
|
||||
'error' => trans('texts.invoice_not_found'),
|
||||
'hideHeader' => true,
|
||||
'clientViewCSS' => $account->clientViewCSS(),
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
]);
|
||||
}
|
||||
|
||||
$account->loadLocalizationSettings($client);
|
||||
|
||||
if (! Input::has('phantomjs') && ! session('silent') && ! Session::has($invitationKey)
|
||||
&& (!Auth::check() || Auth::user()->account_id != $invoice->account_id)) {
|
||||
if (! Input::has('phantomjs') && ! session('silent:' . $client->id) && ! Session::has($invitation->invitation_key)
|
||||
&& (! Auth::check() || Auth::user()->account_id != $invoice->account_id)) {
|
||||
if ($invoice->isType(INVOICE_TYPE_QUOTE)) {
|
||||
event(new QuoteInvitationWasViewed($invoice, $invitation));
|
||||
} else {
|
||||
@ -79,8 +78,8 @@ 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($invitation->invitation_key, true); // track this invitation has been seen
|
||||
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);
|
||||
@ -104,10 +103,13 @@ class ClientPortalController extends BaseController
|
||||
'phone',
|
||||
]);
|
||||
|
||||
// translate the client country name
|
||||
// translate the country names
|
||||
if ($invoice->client->country) {
|
||||
$invoice->client->country->name = trans('texts.country_' . $invoice->client->country->name);
|
||||
}
|
||||
if ($invoice->account->country) {
|
||||
$invoice->account->country->name = trans('texts.country_' . $invoice->account->country->name);
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$paymentTypes = $this->getPaymentTypes($account, $client, $invitation);
|
||||
@ -116,12 +118,12 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)){
|
||||
if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)) {
|
||||
$data['enableWePayACH'] = $wepayGateway->getAchEnabled();
|
||||
}
|
||||
|
||||
@ -137,7 +139,6 @@ class ClientPortalController extends BaseController
|
||||
'account' => $account,
|
||||
'showApprove' => $showApprove,
|
||||
'showBreadcrumbs' => false,
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'invoice' => $invoice->hidePrivateFields(),
|
||||
'invitation' => $invitation,
|
||||
'invoiceLabels' => $account->getInvoiceLabels(),
|
||||
@ -162,10 +163,10 @@ class ClientPortalController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
if($account->hasFeature(FEATURE_DOCUMENTS) && $this->canCreateZip()){
|
||||
if ($account->hasFeature(FEATURE_DOCUMENTS) && $this->canCreateZip()) {
|
||||
$zipDocs = $this->getInvoiceZipDocuments($invoice, $size);
|
||||
|
||||
if(count($zipDocs) > 1){
|
||||
if (count($zipDocs) > 1) {
|
||||
$data['documentsZipURL'] = URL::to("client/documents/{$invitation->invitation_key}");
|
||||
$data['documentsZipSize'] = $size;
|
||||
}
|
||||
@ -189,7 +190,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,
|
||||
@ -210,7 +211,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function sign($invitationKey)
|
||||
{
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
return RESULT_FAILURE;
|
||||
}
|
||||
|
||||
@ -228,24 +229,29 @@ 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
|
||||
} else if (!$contact = $this->getContact()) {
|
||||
Session::put('contact_key', $contactKey); // track current contact
|
||||
} elseif (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
$client = $contact->client;
|
||||
$account = $client->account;
|
||||
$account->loadLocalizationSettings($client);
|
||||
|
||||
if (request()->silent) {
|
||||
session(['silent:' . $client->id => true]);
|
||||
return redirect(request()->url());
|
||||
}
|
||||
|
||||
$account->loadLocalizationSettings($client);
|
||||
$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/');
|
||||
}
|
||||
|
||||
@ -258,7 +264,6 @@ class ClientPortalController extends BaseController
|
||||
'contact' => $contact,
|
||||
'account' => $account,
|
||||
'client' => $client,
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'gateway' => $account->getTokenGateway(),
|
||||
'paymentMethods' => $customer ? $customer->payment_methods : false,
|
||||
'transactionToken' => $paymentDriver ? $paymentDriver->createTransactionToken() : false,
|
||||
@ -269,7 +274,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function activityDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -279,7 +284,9 @@ class ClientPortalController extends BaseController
|
||||
$query->where('activities.adjustment', '!=', 0);
|
||||
|
||||
return Datatable::query($query)
|
||||
->addColumn('activities.id', function ($model) { return Utils::timestampToDateTimeString(strtotime($model->created_at)); })
|
||||
->addColumn('activities.id', function ($model) {
|
||||
return Utils::timestampToDateTimeString(strtotime($model->created_at));
|
||||
})
|
||||
->addColumn('activity_type_id', function ($model) {
|
||||
$data = [
|
||||
'client' => Utils::getClientDisplayName($model),
|
||||
@ -293,22 +300,26 @@ class ClientPortalController extends BaseController
|
||||
];
|
||||
|
||||
return trans("texts.activity_{$model->activity_type_id}", $data);
|
||||
})
|
||||
->addColumn('balance', function ($model) { return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id); })
|
||||
->addColumn('adjustment', function ($model) { return $model->adjustment != 0 ? Utils::wrapAdjustment($model->adjustment, $model->currency_id, $model->country_id) : ''; })
|
||||
})
|
||||
->addColumn('balance', function ($model) {
|
||||
return Utils::formatMoney($model->balance, $model->currency_id, $model->country_id);
|
||||
})
|
||||
->addColumn('adjustment', function ($model) {
|
||||
return $model->adjustment != 0 ? Utils::wrapAdjustment($model->adjustment, $model->currency_id, $model->country_id) : '';
|
||||
})
|
||||
->make();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -318,7 +329,6 @@ class ClientPortalController extends BaseController
|
||||
'color' => $color,
|
||||
'account' => $account,
|
||||
'client' => $contact->client,
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'title' => trans('texts.recurring_invoices'),
|
||||
'entityType' => ENTITY_RECURRING_INVOICE,
|
||||
'columns' => Utils::trans(['frequency', 'start_date', 'end_date', 'invoice_total', 'auto_bill']),
|
||||
@ -329,14 +339,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();
|
||||
}
|
||||
|
||||
@ -346,7 +356,6 @@ class ClientPortalController extends BaseController
|
||||
'color' => $color,
|
||||
'account' => $account,
|
||||
'client' => $contact->client,
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'title' => trans('texts.invoices'),
|
||||
'entityType' => ENTITY_INVOICE,
|
||||
'columns' => Utils::trans(['invoice_number', 'invoice_date', 'invoice_total', 'balance_due', 'due_date']),
|
||||
@ -357,7 +366,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function invoiceDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@ -366,24 +375,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();
|
||||
}
|
||||
|
||||
@ -392,10 +400,9 @@ class ClientPortalController extends BaseController
|
||||
$data = [
|
||||
'color' => $color,
|
||||
'account' => $account,
|
||||
'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);
|
||||
@ -403,19 +410,31 @@ 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'));
|
||||
|
||||
return Datatable::query($payments)
|
||||
->addColumn('invoice_number', function ($model) { return $model->invitation_key ? link_to('/view/'.$model->invitation_key, $model->invoice_number)->toHtml() : $model->invoice_number; })
|
||||
->addColumn('transaction_reference', function ($model) { 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>' : ''); })
|
||||
->addColumn('amount', function ($model) { return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id); })
|
||||
->addColumn('payment_date', function ($model) { return Utils::dateToString($model->payment_date); })
|
||||
->addColumn('status', function ($model) { return $this->getPaymentStatusLabel($model); })
|
||||
->orderColumns( 'invoice_number', 'transaction_reference', 'payment_type', 'amount', 'payment_date')
|
||||
->addColumn('invoice_number', function ($model) {
|
||||
return $model->invitation_key ? link_to('/view/'.$model->invitation_key, $model->invoice_number)->toHtml() : $model->invoice_number;
|
||||
})
|
||||
->addColumn('transaction_reference', function ($model) {
|
||||
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>' : '');
|
||||
})
|
||||
->addColumn('amount', function ($model) {
|
||||
return Utils::formatMoney($model->amount, $model->currency_id, $model->country_id);
|
||||
})
|
||||
->addColumn('payment_date', function ($model) {
|
||||
return Utils::dateToString($model->payment_date);
|
||||
})
|
||||
->addColumn('status', function ($model) {
|
||||
return $this->getPaymentStatusLabel($model);
|
||||
})
|
||||
->orderColumns('invoice_number', 'transaction_reference', 'payment_type', 'amount', 'payment_date')
|
||||
->make();
|
||||
}
|
||||
|
||||
@ -443,19 +462,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();
|
||||
}
|
||||
|
||||
@ -464,7 +484,6 @@ class ClientPortalController extends BaseController
|
||||
$data = [
|
||||
'color' => $color,
|
||||
'account' => $account,
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'title' => trans('texts.quotes'),
|
||||
'entityType' => ENTITY_QUOTE,
|
||||
'columns' => Utils::trans(['quote_number', 'quote_date', 'quote_total', 'due_date']),
|
||||
@ -473,10 +492,9 @@ class ClientPortalController extends BaseController
|
||||
return response()->view('public_list', $data);
|
||||
}
|
||||
|
||||
|
||||
public function quoteDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -485,14 +503,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();
|
||||
}
|
||||
|
||||
@ -501,7 +519,6 @@ class ClientPortalController extends BaseController
|
||||
$data = [
|
||||
'color' => $color,
|
||||
'account' => $account,
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'title' => trans('texts.credits'),
|
||||
'entityType' => ENTITY_CREDIT,
|
||||
'columns' => Utils::trans(['credit_date', 'credit_amount', 'credit_balance']),
|
||||
@ -512,7 +529,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function creditDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -521,14 +538,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();
|
||||
}
|
||||
|
||||
@ -537,7 +554,6 @@ class ClientPortalController extends BaseController
|
||||
$data = [
|
||||
'color' => $color,
|
||||
'account' => $account,
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'title' => trans('texts.documents'),
|
||||
'entityType' => ENTITY_DOCUMENT,
|
||||
'columns' => Utils::trans(['invoice_number', 'name', 'document_date', 'document_size']),
|
||||
@ -546,10 +562,9 @@ class ClientPortalController extends BaseController
|
||||
return response()->view('public_list', $data);
|
||||
}
|
||||
|
||||
|
||||
public function documentDatatable()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -565,50 +580,51 @@ class ClientPortalController extends BaseController
|
||||
]);
|
||||
}
|
||||
|
||||
private function getContact() {
|
||||
private function getContact()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
return $contact;
|
||||
}
|
||||
|
||||
public function getDocumentVFSJS($publicId, $name){
|
||||
if (!$contact = $this->getContact()) {
|
||||
public function getDocumentVFSJS($publicId, $name)
|
||||
{
|
||||
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){
|
||||
if ($document->expense && $document->expense->client_id == $contact->client_id) {
|
||||
$authorized = true;
|
||||
} else if($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');
|
||||
@ -617,14 +633,16 @@ class ClientPortalController extends BaseController
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function canCreateZip(){
|
||||
protected function canCreateZip()
|
||||
{
|
||||
return function_exists('gmp_init');
|
||||
}
|
||||
|
||||
protected function getInvoiceZipDocuments($invoice, &$size=0){
|
||||
protected function getInvoiceZipDocuments($invoice, &$size = 0)
|
||||
{
|
||||
$documents = $invoice->documents;
|
||||
|
||||
foreach($invoice->expenses as $expense){
|
||||
foreach ($invoice->expenses as $expense) {
|
||||
$documents = $documents->merge($expense->documents);
|
||||
}
|
||||
|
||||
@ -633,31 +651,31 @@ class ClientPortalController extends BaseController
|
||||
$size = 0;
|
||||
$maxSize = MAX_ZIP_DOCUMENTS_SIZE * 1000;
|
||||
$toZip = [];
|
||||
foreach($documents as $document){
|
||||
if($size + $document->size > $maxSize)break;
|
||||
foreach ($documents as $document) {
|
||||
if ($size + $document->size > $maxSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!empty($toZip[$document->name])){
|
||||
if (! empty($toZip[$document->name])) {
|
||||
// This name is taken
|
||||
if($toZip[$document->name]->hash != $document->hash){
|
||||
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])){
|
||||
if (empty($toZip[$name])) {
|
||||
$toZip[$name] = $document;
|
||||
$size += $document->size;
|
||||
break;
|
||||
} else if ($toZip[$name]->hash == $document->hash){
|
||||
} elseif ($toZip[$name]->hash == $document->hash) {
|
||||
// We're not adding this after all
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$toZip[$document->name] = $document;
|
||||
$size += $document->size;
|
||||
}
|
||||
@ -666,32 +684,35 @@ class ClientPortalController extends BaseController
|
||||
return $toZip;
|
||||
}
|
||||
|
||||
public function getInvoiceDocumentsZip($invitationKey){
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
public function getInvoiceDocumentsZip($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){
|
||||
|
||||
return Response::stream(function () use ($toZip, $zip) {
|
||||
foreach ($toZip as $name => $document) {
|
||||
$fileStream = $document->getStream();
|
||||
if($fileStream){
|
||||
$zip->init_file_stream_transfer($name, $document->size, ['time'=>$document->created_at->timestamp]);
|
||||
while ($buffer = fread($fileStream, 256000))$zip->stream_file_part($buffer);
|
||||
if ($fileStream) {
|
||||
$zip->init_file_stream_transfer($name, $document->size, ['time' => $document->created_at->timestamp]);
|
||||
while ($buffer = fread($fileStream, 256000)) {
|
||||
$zip->stream_file_part($buffer);
|
||||
}
|
||||
fclose($fileStream);
|
||||
$zip->complete_file_stream();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$zip->add_file($name, $document->getRaw());
|
||||
}
|
||||
}
|
||||
@ -699,25 +720,26 @@ class ClientPortalController extends BaseController
|
||||
}, 200);
|
||||
}
|
||||
|
||||
public function getDocument($invitationKey, $publicId){
|
||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||
public function getDocument($invitationKey, $publicId)
|
||||
{
|
||||
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();
|
||||
|
||||
$authorized = false;
|
||||
if($document->expense && $document->expense->client_id == $invitation->invoice->client_id){
|
||||
if ($document->expense && $document->expense->client_id == $invitation->invoice->client_id) {
|
||||
$authorized = true;
|
||||
} else if($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id){
|
||||
} elseif ($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id) {
|
||||
$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);
|
||||
@ -725,7 +747,7 @@ class ClientPortalController extends BaseController
|
||||
|
||||
public function paymentMethods()
|
||||
{
|
||||
if (!$contact = $this->getContact()) {
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -740,8 +762,6 @@ class ClientPortalController extends BaseController
|
||||
'contact' => $contact,
|
||||
'color' => $account->primary_color ? $account->primary_color : '#0b4d78',
|
||||
'client' => $client,
|
||||
'clientViewCSS' => $account->clientViewCSS(),
|
||||
'clientFontUrl' => $account->getFontsUrl(),
|
||||
'paymentMethods' => $customer ? $customer->payment_methods : false,
|
||||
'gateway' => $account->getTokenGateway(),
|
||||
'title' => trans('texts.payment_methods'),
|
||||
@ -757,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();
|
||||
}
|
||||
|
||||
@ -773,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();
|
||||
}
|
||||
|
||||
@ -797,11 +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()) {
|
||||
public function setDefaultPaymentMethod()
|
||||
{
|
||||
if (! $contact = $this->getContact()) {
|
||||
return $this->returnError();
|
||||
}
|
||||
|
||||
@ -810,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);
|
||||
@ -824,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)
|
||||
@ -839,8 +860,9 @@ class ClientPortalController extends BaseController
|
||||
Utils::logError("Payment Method Error [{$type}]: " . ($exception ? Utils::getErrorString($exception) : $message), 'PHP', true);
|
||||
}
|
||||
|
||||
public function setAutoBill(){
|
||||
if (!$contact = $this->getContact()) {
|
||||
public function setAutoBill()
|
||||
{
|
||||
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,9 +1,10 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Auth;
|
||||
use DB;
|
||||
use App\Ninja\Repositories\DashboardRepository;
|
||||
use App\Ninja\Transformers\ActivityTransformer;
|
||||
use Auth;
|
||||
|
||||
class DashboardApiController extends BaseAPIController
|
||||
{
|
||||
|
@ -1,17 +1,16 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use stdClass;
|
||||
use Auth;
|
||||
use DB;
|
||||
use View;
|
||||
use Utils;
|
||||
use App\Models\Client;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Expense;
|
||||
use App\Ninja\Repositories\DashboardRepository;
|
||||
use Auth;
|
||||
use Utils;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class DashboardController
|
||||
* Class DashboardController.
|
||||
*/
|
||||
class DashboardController extends BaseController
|
||||
{
|
||||
@ -40,13 +39,13 @@ class DashboardController extends BaseController
|
||||
$pastDue = $dashboardRepo->pastDue($accountId, $userId, $viewAll);
|
||||
$upcoming = $dashboardRepo->upcoming($accountId, $userId, $viewAll);
|
||||
$payments = $dashboardRepo->payments($accountId, $userId, $viewAll);
|
||||
$expenses = $dashboardRepo->expenses($accountId, $userId, $viewAll);
|
||||
$expenses = $dashboardRepo->expenses($account, $userId, $viewAll);
|
||||
$tasks = $dashboardRepo->tasks($accountId, $userId, $viewAll);
|
||||
|
||||
$showBlueVinePromo = $user->is_admin
|
||||
$showBlueVinePromo = $user->is_admin
|
||||
&& env('BLUEVINE_PARTNER_UNIQUE_ID')
|
||||
&& ! $account->company->bluevine_status
|
||||
&& $account->created_at <= date( 'Y-m-d', strtotime( '-1 month' ));
|
||||
&& $account->created_at <= date('Y-m-d', strtotime('-1 month'));
|
||||
|
||||
$showWhiteLabelExpired = Utils::isSelfHost() && $account->company->hasExpiredPlan(PLAN_WHITE_LABEL);
|
||||
|
||||
@ -60,8 +59,57 @@ class DashboardController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// check if the account has multiple curencies
|
||||
$data = [
|
||||
'account' => $user->account,
|
||||
'user' => $user,
|
||||
'paidToDate' => $paidToDate,
|
||||
'balances' => $balances,
|
||||
'averageInvoice' => $averageInvoice,
|
||||
'invoicesSent' => $metrics ? $metrics->invoices_sent : 0,
|
||||
'activeClients' => $metrics ? $metrics->active_clients : 0,
|
||||
'activities' => $activities,
|
||||
'pastDue' => $pastDue,
|
||||
'upcoming' => $upcoming,
|
||||
'payments' => $payments,
|
||||
'title' => trans('texts.dashboard'),
|
||||
'hasQuotes' => $hasQuotes,
|
||||
'showBreadcrumbs' => false,
|
||||
'currencies' => $this->getCurrencyCodes(),
|
||||
'expenses' => $expenses,
|
||||
'tasks' => $tasks,
|
||||
'showBlueVinePromo' => $showBlueVinePromo,
|
||||
'showWhiteLabelExpired' => $showWhiteLabelExpired,
|
||||
];
|
||||
|
||||
if ($showBlueVinePromo) {
|
||||
$usdLast12Months = 0;
|
||||
$pastYear = date('Y-m-d', strtotime('-1 year'));
|
||||
$paidLast12Months = $dashboardRepo->paidToDate($account, $userId, $viewAll, $pastYear);
|
||||
|
||||
foreach ($paidLast12Months as $item) {
|
||||
if ($item->currency_id == null) {
|
||||
$currency = $user->account->currency_id ?: DEFAULT_CURRENCY;
|
||||
} else {
|
||||
$currency = $item->currency_id;
|
||||
}
|
||||
|
||||
if ($currency == CURRENCY_DOLLAR) {
|
||||
$usdLast12Months += $item->value;
|
||||
}
|
||||
}
|
||||
|
||||
$data['usdLast12Months'] = $usdLast12Months;
|
||||
}
|
||||
|
||||
return View::make('dashboard', $data);
|
||||
}
|
||||
|
||||
private function getCurrencyCodes()
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
$currencyIds = $account->currency_id ? [$account->currency_id] : [DEFAULT_CURRENCY];
|
||||
|
||||
// get client/invoice currencies
|
||||
$data = Client::scope()
|
||||
->withArchived()
|
||||
->distinct()
|
||||
@ -75,54 +123,26 @@ class DashboardController extends BaseController
|
||||
}
|
||||
}, $data);
|
||||
|
||||
// get expense currencies
|
||||
$data = Expense::scope()
|
||||
->withArchived()
|
||||
->distinct()
|
||||
->get(['expense_currency_id'])
|
||||
->toArray();
|
||||
|
||||
array_map(function ($item) use (&$currencyIds) {
|
||||
$currencyId = intval($item['expense_currency_id']);
|
||||
if ($currencyId && ! in_array($currencyId, $currencyIds)) {
|
||||
$currencyIds[] = $currencyId;
|
||||
}
|
||||
}, $data);
|
||||
|
||||
$currencies = [];
|
||||
foreach ($currencyIds as $currencyId) {
|
||||
$currencies[$currencyId] = Utils::getFromCache($currencyId, 'currencies')->code;
|
||||
}
|
||||
|
||||
$data = [
|
||||
'account' => $user->account,
|
||||
'user' => $user,
|
||||
'paidToDate' => $paidToDate,
|
||||
'balances' => $balances,
|
||||
'averageInvoice' => $averageInvoice,
|
||||
'invoicesSent' => $metrics ? $metrics->invoices_sent : 0,
|
||||
'activeClients' => $metrics ? $metrics->active_clients : 0,
|
||||
'activities' => $activities,
|
||||
'pastDue' => $pastDue,
|
||||
'upcoming' => $upcoming,
|
||||
'payments' => $payments,
|
||||
'title' => trans('texts.dashboard'),
|
||||
'hasQuotes' => $hasQuotes,
|
||||
'showBreadcrumbs' => false,
|
||||
'currencies' => $currencies,
|
||||
'expenses' => $expenses,
|
||||
'tasks' => $tasks,
|
||||
'showBlueVinePromo' => $showBlueVinePromo,
|
||||
'showWhiteLabelExpired' => $showWhiteLabelExpired,
|
||||
];
|
||||
|
||||
if ($showBlueVinePromo) {
|
||||
$usdLast12Months = 0;
|
||||
$pastYear = date( 'Y-m-d', strtotime( '-1 year' ));
|
||||
$paidLast12Months = $dashboardRepo->paidToDate( $account, $userId, $viewAll, $pastYear );
|
||||
|
||||
foreach ( $paidLast12Months as $item ) {
|
||||
if ( $item->currency_id == null ) {
|
||||
$currency = $user->account->currency_id ?: DEFAULT_CURRENCY;
|
||||
} else {
|
||||
$currency = $item->currency_id;
|
||||
}
|
||||
|
||||
if ( $currency == CURRENCY_DOLLAR ) {
|
||||
$usdLast12Months += $item->value;
|
||||
}
|
||||
}
|
||||
|
||||
$data['usdLast12Months'] = $usdLast12Months;
|
||||
}
|
||||
|
||||
return View::make('dashboard', $data);
|
||||
return $currencies;
|
||||
}
|
||||
|
||||
public function chartData($groupBy, $startDate, $endDate, $currencyCode, $includeExpenses)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user