mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
php-cs-fixer clean up
This commit is contained in:
parent
371e842650
commit
1eb83a2642
@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
abstract class Command
|
abstract class Command
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,17 +71,17 @@ class ChargeRenewalInvoices extends Command
|
|||||||
// check if account has switched to free since the invoice was created
|
// check if account has switched to free since the invoice was created
|
||||||
$account = Account::find($invoice->client->public_id);
|
$account = Account::find($invoice->client->public_id);
|
||||||
|
|
||||||
if ( ! $account) {
|
if (! $account) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$company = $account->company;
|
$company = $account->company;
|
||||||
if ( ! $company->plan || $company->plan == PLAN_FREE) {
|
if (! $company->plan || $company->plan == PLAN_FREE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info("Charging invoice {$invoice->invoice_number}");
|
$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->info('Failed to auto-bill, emailing invoice');
|
||||||
$this->mailer->sendInvoice($invoice);
|
$this->mailer->sendInvoice($invoice);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@ Options:
|
|||||||
/**
|
/**
|
||||||
* Class CheckData
|
* Class CheckData
|
||||||
*/
|
*/
|
||||||
class CheckData extends Command {
|
class CheckData extends Command
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -250,7 +251,6 @@ class CheckData extends Command {
|
|||||||
//$this->logMessage(var_dump($activities));
|
//$this->logMessage(var_dump($activities));
|
||||||
|
|
||||||
foreach ($activities as $activity) {
|
foreach ($activities as $activity) {
|
||||||
|
|
||||||
$activityFix = false;
|
$activityFix = false;
|
||||||
|
|
||||||
if ($activity->invoice_id) {
|
if ($activity->invoice_id) {
|
||||||
@ -336,7 +336,7 @@ class CheckData extends Command {
|
|||||||
$foundProblem = true;
|
$foundProblem = true;
|
||||||
$clientFix -= $activity->adjustment;
|
$clientFix -= $activity->adjustment;
|
||||||
$activityFix = 0;
|
$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}");
|
$this->logMessage("Duplicate adjustment for updated invoice adjustment:{$activity->adjustment}");
|
||||||
$foundProblem = true;
|
$foundProblem = true;
|
||||||
$clientFix -= $activity->adjustment;
|
$clientFix -= $activity->adjustment;
|
||||||
@ -350,7 +350,7 @@ class CheckData extends Command {
|
|||||||
$clientFix += $lastBalance - $activity->balance;
|
$clientFix += $lastBalance - $activity->balance;
|
||||||
$activityFix = 0;
|
$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**
|
// **Fix for deleting payment after deleting invoice**
|
||||||
if ($activity->adjustment != 0 && $invoice->is_deleted && $activity->created_at > $invoice->deleted_at) {
|
if ($activity->adjustment != 0 && $invoice->is_deleted && $activity->created_at > $invoice->deleted_at) {
|
||||||
$this->logMessage("Incorrect adjustment for deleted payment adjustment:{$activity->adjustment}");
|
$this->logMessage("Incorrect adjustment for deleted payment adjustment:{$activity->adjustment}");
|
||||||
@ -423,5 +423,4 @@ class CheckData extends Command {
|
|||||||
['client_id', null, InputOption::VALUE_OPTIONAL, 'Client id', null],
|
['client_id', null, InputOption::VALUE_OPTIONAL, 'Client id', null],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,30 +6,30 @@ use Illuminate\Foundation\Inspiring;
|
|||||||
/**
|
/**
|
||||||
* Class Inspire
|
* Class Inspire
|
||||||
*/
|
*/
|
||||||
class Inspire extends Command {
|
class Inspire extends Command
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command name.
|
* The console command name.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $name = 'inspire';
|
protected $name = 'inspire';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Display an inspiring quote';
|
protected $description = 'Display an inspiring quote';
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ class MakeClass extends GeneratorCommand
|
|||||||
$str = '';
|
$str = '';
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if ( ! $field) {
|
if (! $field) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$field = explode(':', $field)[0];
|
$field = explode(':', $field)[0];
|
||||||
@ -120,7 +120,7 @@ class MakeClass extends GeneratorCommand
|
|||||||
$str = '';
|
$str = '';
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if ( ! $field) {
|
if (! $field) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$parts = explode(':', $field);
|
$parts = explode(':', $field);
|
||||||
@ -144,7 +144,7 @@ class MakeClass extends GeneratorCommand
|
|||||||
$str = '';
|
$str = '';
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if ( ! $field) {
|
if (! $field) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$field = explode(':', $field)[0];
|
$field = explode(':', $field)[0];
|
||||||
@ -161,7 +161,7 @@ class MakeClass extends GeneratorCommand
|
|||||||
$str = '';
|
$str = '';
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if ( ! $field) {
|
if (! $field) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$field = explode(':', $field)[0];
|
$field = explode(':', $field)[0];
|
||||||
@ -169,6 +169,5 @@ class MakeClass extends GeneratorCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
return rtrim($str);
|
return rtrim($str);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ class MakeModule extends Command
|
|||||||
|
|
||||||
// convert 'name:string,description:text' to 'name,description'
|
// convert 'name:string,description:text' to 'name,description'
|
||||||
$fillable = explode(',', $fields);
|
$fillable = explode(',', $fields);
|
||||||
$fillable = array_map(function($item) {
|
$fillable = array_map(function ($item) {
|
||||||
return explode(':', $item)[0];
|
return explode(':', $item)[0];
|
||||||
}, $fillable);
|
}, $fillable);
|
||||||
$fillable = join(',', $fillable);
|
$fillable = join(',', $fillable);
|
||||||
@ -94,5 +94,4 @@ class MakeModule extends Command
|
|||||||
array('migrate', null, InputOption::VALUE_OPTIONAL, 'The model attributes.', null),
|
array('migrate', null, InputOption::VALUE_OPTIONAL, 'The model attributes.', null),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class PruneData extends Command
|
|||||||
$results = DB::select($sql);
|
$results = DB::select($sql);
|
||||||
|
|
||||||
foreach ($results as $result) {
|
foreach ($results as $result) {
|
||||||
$this->info("Deleting {$result->id}");
|
$this->info("Deleting {$result->id}");
|
||||||
DB::table('accounts')
|
DB::table('accounts')
|
||||||
->where('id', '=', $result->id)
|
->where('id', '=', $result->id)
|
||||||
->delete();
|
->delete();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Console\Commands;
|
<?php namespace App\Console\Commands;
|
||||||
|
|
||||||
|
|
||||||
use Utils;
|
use Utils;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
@ -32,4 +31,4 @@ class ResetData extends Command
|
|||||||
Artisan::call('migrate');
|
Artisan::call('migrate');
|
||||||
Artisan::call('db:seed');
|
Artisan::call('db:seed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ class ResetInvoiceSchemaCounter extends Command
|
|||||||
$latestInvoice = $this->invoice->latest()->first();
|
$latestInvoice = $this->invoice->latest()->first();
|
||||||
$invoiceYear = Carbon::parse($latestInvoice->created_at)->year;
|
$invoiceYear = Carbon::parse($latestInvoice->created_at)->year;
|
||||||
|
|
||||||
if(Carbon::now()->year > $invoiceYear || $force) {
|
if (Carbon::now()->year > $invoiceYear || $force) {
|
||||||
$accounts->transform(function ($a) {
|
$accounts->transform(function ($a) {
|
||||||
/** @var Account $a */
|
/** @var Account $a */
|
||||||
$a->invoice_number_counter = 1;
|
$a->invoice_number_counter = 1;
|
||||||
|
@ -67,7 +67,7 @@ class SendRecurringInvoices extends Command
|
|||||||
$shouldSendToday = $recurInvoice->shouldSendToday();
|
$shouldSendToday = $recurInvoice->shouldSendToday();
|
||||||
$this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($shouldSendToday ? 'YES' : 'NO'));
|
$this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($shouldSendToday ? 'YES' : 'NO'));
|
||||||
|
|
||||||
if ( ! $shouldSendToday) {
|
if (! $shouldSendToday) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class SendRenewalInvoices extends Command
|
|||||||
$plan['price'] = min($company->pending_plan_price, Utils::getPlanPrice($plan));
|
$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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,4 +39,4 @@ class TestOFX extends Command
|
|||||||
{
|
{
|
||||||
$this->info(date('Y-m-d').' Running TestOFX...');
|
$this->info(date('Y-m-d').' Running TestOFX...');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!defined('APP_NAME'))
|
if (!defined('APP_NAME')) {
|
||||||
{
|
|
||||||
define('APP_NAME', env('APP_NAME', 'Invoice Ninja'));
|
define('APP_NAME', env('APP_NAME', 'Invoice Ninja'));
|
||||||
define('CONTACT_EMAIL', env('MAIL_FROM_ADDRESS', env('MAIL_USERNAME')));
|
define('CONTACT_EMAIL', env('MAIL_FROM_ADDRESS', env('MAIL_USERNAME')));
|
||||||
define('CONTACT_NAME', env('MAIL_FROM_NAME'));
|
define('CONTACT_NAME', env('MAIL_FROM_NAME'));
|
||||||
@ -44,7 +43,7 @@ if (!defined('APP_NAME'))
|
|||||||
|
|
||||||
define('PERSON_CONTACT', 'contact');
|
define('PERSON_CONTACT', 'contact');
|
||||||
define('PERSON_USER', 'user');
|
define('PERSON_USER', 'user');
|
||||||
define('PERSON_VENDOR_CONTACT','vendorcontact');
|
define('PERSON_VENDOR_CONTACT', 'vendorcontact');
|
||||||
|
|
||||||
define('BASIC_SETTINGS', 'basic_settings');
|
define('BASIC_SETTINGS', 'basic_settings');
|
||||||
define('ADVANCED_SETTINGS', 'advanced_settings');
|
define('ADVANCED_SETTINGS', 'advanced_settings');
|
||||||
@ -74,7 +73,7 @@ if (!defined('APP_NAME'))
|
|||||||
define('ACCOUNT_API_TOKENS', 'api_tokens');
|
define('ACCOUNT_API_TOKENS', 'api_tokens');
|
||||||
define('ACCOUNT_CUSTOMIZE_DESIGN', 'customize_design');
|
define('ACCOUNT_CUSTOMIZE_DESIGN', 'customize_design');
|
||||||
define('ACCOUNT_SYSTEM_SETTINGS', 'system_settings');
|
define('ACCOUNT_SYSTEM_SETTINGS', 'system_settings');
|
||||||
define('ACCOUNT_PAYMENT_TERMS','payment_terms');
|
define('ACCOUNT_PAYMENT_TERMS', 'payment_terms');
|
||||||
|
|
||||||
define('ACTION_RESTORE', 'restore');
|
define('ACTION_RESTORE', 'restore');
|
||||||
define('ACTION_ARCHIVE', 'archive');
|
define('ACTION_ARCHIVE', 'archive');
|
||||||
@ -485,7 +484,7 @@ if (!defined('APP_NAME'))
|
|||||||
define('WEPAY_AUTO_UPDATE', env('WEPAY_AUTO_UPDATE', false));
|
define('WEPAY_AUTO_UPDATE', env('WEPAY_AUTO_UPDATE', false));
|
||||||
define('WEPAY_ENVIRONMENT', env('WEPAY_ENVIRONMENT', WEPAY_PRODUCTION));
|
define('WEPAY_ENVIRONMENT', env('WEPAY_ENVIRONMENT', WEPAY_PRODUCTION));
|
||||||
define('WEPAY_ENABLE_CANADA', env('WEPAY_ENABLE_CANADA', false));
|
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_RECEIPT', 'message/card.receipt');
|
||||||
define('SKYPE_CARD_CAROUSEL', 'message/card.carousel');
|
define('SKYPE_CARD_CAROUSEL', 'message/card.carousel');
|
||||||
@ -564,12 +563,12 @@ if (!defined('APP_NAME'))
|
|||||||
// include modules in translations
|
// include modules in translations
|
||||||
function mtrans($entityType, $text = false)
|
function mtrans($entityType, $text = false)
|
||||||
{
|
{
|
||||||
if ( ! $text) {
|
if (! $text) {
|
||||||
$text = $entityType;
|
$text = $entityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if this has been translated in a module language file
|
// 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}";
|
$key = "{$module->getLowerName()}::texts.{$text}";
|
||||||
$value = trans($key);
|
$value = trans($key);
|
||||||
if ($key != $value) {
|
if ($key != $value) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@ -9,7 +8,6 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
*/
|
*/
|
||||||
class CreditWasArchived extends Event
|
class CreditWasArchived extends Event
|
||||||
{
|
{
|
||||||
|
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,5 +24,4 @@ class CreditWasArchived extends Event
|
|||||||
{
|
{
|
||||||
$this->credit = $credit;
|
$this->credit = $credit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
|
|
||||||
class CreditWasCreated extends Event
|
class CreditWasCreated extends Event
|
||||||
{
|
{
|
||||||
|
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,5 +21,4 @@ class CreditWasCreated extends Event
|
|||||||
{
|
{
|
||||||
$this->credit = $credit;
|
$this->credit = $credit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class CreditWasDeleted
|
* Class CreditWasDeleted
|
||||||
*/
|
*/
|
||||||
class CreditWasDeleted extends Event {
|
class CreditWasDeleted extends Event
|
||||||
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Credit
|
* @var Credit
|
||||||
@ -24,5 +24,4 @@ class CreditWasDeleted extends Event {
|
|||||||
{
|
{
|
||||||
$this->credit = $credit;
|
$this->credit = $credit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Credit;
|
use App\Models\Credit;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CreditWasRestored
|
* Class CreditWasRestored
|
||||||
*/
|
*/
|
||||||
class CreditWasRestored extends Event {
|
class CreditWasRestored extends Event
|
||||||
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Credit
|
* @var Credit
|
||||||
@ -25,5 +24,4 @@ class CreditWasRestored extends Event {
|
|||||||
{
|
{
|
||||||
$this->credit = $credit;
|
$this->credit = $credit;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,4 @@ class ExpenseWasArchived extends Event
|
|||||||
{
|
{
|
||||||
$this->expense = $expense;
|
$this->expense = $expense;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,4 @@ class ExpenseWasDeleted extends Event
|
|||||||
{
|
{
|
||||||
$this->expense = $expense;
|
$this->expense = $expense;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@ -25,5 +24,4 @@ class ExpenseWasRestored extends Event
|
|||||||
{
|
{
|
||||||
$this->expense = $expense;
|
$this->expense = $expense;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Invitation;
|
use App\Models\Invitation;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@ -9,7 +8,6 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
*/
|
*/
|
||||||
class InvoiceInvitationWasEmailed extends Event
|
class InvoiceInvitationWasEmailed extends Event
|
||||||
{
|
{
|
||||||
|
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,5 +30,4 @@ class InvoiceInvitationWasEmailed extends Event
|
|||||||
$this->invitation = $invitation;
|
$this->invitation = $invitation;
|
||||||
$this->notes = $notes;
|
$this->notes = $notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
/**
|
/**
|
||||||
* Class InvoiceInvitationWasViewed
|
* Class InvoiceInvitationWasViewed
|
||||||
*/
|
*/
|
||||||
class InvoiceInvitationWasViewed extends Event {
|
class InvoiceInvitationWasViewed extends Event
|
||||||
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Invoice
|
* @var Invoice
|
||||||
|
@ -24,5 +24,4 @@ class InvoiceWasArchived extends Event
|
|||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,4 @@ class InvoiceWasCreated extends Event
|
|||||||
{
|
{
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@ -29,5 +28,4 @@ class InvoiceWasRestored extends Event
|
|||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
$this->fromDeleted = $fromDeleted;
|
$this->fromDeleted = $fromDeleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,4 @@ class PaymentCompleted extends Event
|
|||||||
{
|
{
|
||||||
$this->payment = $payment;
|
$this->payment = $payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,4 @@ class PaymentWasArchived extends Event
|
|||||||
{
|
{
|
||||||
$this->payment = $payment;
|
$this->payment = $payment;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
*/
|
*/
|
||||||
class PaymentWasCreated extends Event
|
class PaymentWasCreated extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Payment
|
* @var Payment
|
||||||
|
@ -10,7 +10,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
*/
|
*/
|
||||||
class PaymentWasDeleted extends Event
|
class PaymentWasDeleted extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Payment
|
* @var Payment
|
||||||
@ -19,7 +19,7 @@ class PaymentWasDeleted extends Event
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event instance.
|
* Create a new event instance.
|
||||||
*
|
*
|
||||||
* @param Payment $payment
|
* @param Payment $payment
|
||||||
*/
|
*/
|
||||||
public function __construct(Payment $payment)
|
public function __construct(Payment $payment)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Invitation;
|
use App\Models\Invitation;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
@ -30,5 +30,4 @@ class QuoteInvitationWasEmailed extends Event
|
|||||||
$this->invitation = $invitation;
|
$this->invitation = $invitation;
|
||||||
$this->notes = $notes;
|
$this->notes = $notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use Illuminate\Queue\SerializesModels;
|
|||||||
*/
|
*/
|
||||||
class QuoteInvitationWasViewed extends Event
|
class QuoteInvitationWasViewed extends Event
|
||||||
{
|
{
|
||||||
use SerializesModels;
|
use SerializesModels;
|
||||||
|
|
||||||
public $quote;
|
public $quote;
|
||||||
|
|
||||||
|
@ -16,5 +16,4 @@ class QuoteWasArchived extends Event
|
|||||||
{
|
{
|
||||||
$this->quote = $quote;
|
$this->quote = $quote;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,4 @@ class QuoteWasUpdated extends Event
|
|||||||
{
|
{
|
||||||
$this->quote = $quote;
|
$this->quote = $quote;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,4 @@ class TaskWasArchived extends Event
|
|||||||
{
|
{
|
||||||
$this->task = $task;
|
$this->task = $task;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
@ -24,5 +24,4 @@ class TaskWasDeleted extends Event
|
|||||||
{
|
{
|
||||||
$this->task = $task;
|
$this->task = $task;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
@ -25,5 +24,4 @@ class TaskWasRestored extends Event
|
|||||||
{
|
{
|
||||||
$this->task = $task;
|
$this->task = $task;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Events;
|
<?php namespace App\Events;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Task;
|
use App\Models\Task;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
@ -14,24 +14,23 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
|
|||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Illuminate\Foundation\Validation\ValidationException;
|
use Illuminate\Foundation\Validation\ValidationException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Handler
|
* Class Handler
|
||||||
*/
|
*/
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of the exception types that should not be reported.
|
* A list of the exception types that should not be reported.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $dontReport = [
|
protected $dontReport = [
|
||||||
AuthorizationException::class,
|
AuthorizationException::class,
|
||||||
HttpException::class,
|
HttpException::class,
|
||||||
ModelNotFoundException::class,
|
ModelNotFoundException::class,
|
||||||
ValidationException::class,
|
ValidationException::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report or log an exception.
|
* Report or log an exception.
|
||||||
@ -41,8 +40,8 @@ class Handler extends ExceptionHandler
|
|||||||
* @param \Exception $e
|
* @param \Exception $e
|
||||||
* @return bool|void
|
* @return bool|void
|
||||||
*/
|
*/
|
||||||
public function report(Exception $e)
|
public function report(Exception $e)
|
||||||
{
|
{
|
||||||
// don't show these errors in the logs
|
// don't show these errors in the logs
|
||||||
if ($e instanceof NotFoundHttpException) {
|
if ($e instanceof NotFoundHttpException) {
|
||||||
if (Crawler::isCrawler()) {
|
if (Crawler::isCrawler()) {
|
||||||
@ -60,18 +59,19 @@ class Handler extends ExceptionHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an exception into an HTTP response.
|
* Render an exception into an HTTP response.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @param \Exception $e
|
* @param \Exception $e
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function render($request, Exception $e)
|
public function render($request, Exception $e)
|
||||||
{
|
{
|
||||||
if ($e instanceof ModelNotFoundException) {
|
if ($e instanceof ModelNotFoundException) {
|
||||||
return Redirect::to('/');
|
return Redirect::to('/');
|
||||||
} if ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
}
|
||||||
|
if ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
||||||
// prevent loop since the page auto-submits
|
// prevent loop since the page auto-submits
|
||||||
if ($request->path() != 'get_started') {
|
if ($request->path() != 'get_started') {
|
||||||
// https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e
|
// https://gist.github.com/jrmadsen67/bd0f9ad0ef1ed6bb594e
|
||||||
@ -84,13 +84,11 @@ class Handler extends ExceptionHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->isHttpException($e))
|
if ($this->isHttpException($e)) {
|
||||||
{
|
switch ($e->getStatusCode()) {
|
||||||
switch ($e->getStatusCode())
|
|
||||||
{
|
|
||||||
// not found
|
// not found
|
||||||
case 404:
|
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
|
//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'];
|
||||||
@ -98,13 +96,12 @@ class Handler extends ExceptionHandler
|
|||||||
$headers = Utils::getApiHeaders();
|
$headers = Utils::getApiHeaders();
|
||||||
|
|
||||||
return response()->make($error, 404, $headers);
|
return response()->make($error, 404, $headers);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// internal error
|
// internal error
|
||||||
case '500':
|
case '500':
|
||||||
if($request->header('X-Ninja-Token') != '') {
|
if ($request->header('X-Ninja-Token') != '') {
|
||||||
//API request which produces 500 error
|
//API request which produces 500 error
|
||||||
|
|
||||||
$error['error'] = ['message'=>'Internal Server Error'];
|
$error['error'] = ['message'=>'Internal Server Error'];
|
||||||
@ -132,5 +129,5 @@ class Handler extends ExceptionHandler
|
|||||||
} else {
|
} else {
|
||||||
return parent::render($request, $e);
|
return parent::render($request, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,47 +5,45 @@ use App\Ninja\Mailers\ContactMailer;
|
|||||||
|
|
||||||
class InvoiceEventHandler
|
class InvoiceEventHandler
|
||||||
{
|
{
|
||||||
protected $userMailer;
|
protected $userMailer;
|
||||||
protected $contactMailer;
|
protected $contactMailer;
|
||||||
|
|
||||||
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
|
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
|
||||||
{
|
{
|
||||||
$this->userMailer = $userMailer;
|
$this->userMailer = $userMailer;
|
||||||
$this->contactMailer = $contactMailer;
|
$this->contactMailer = $contactMailer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function subscribe($events)
|
public function subscribe($events)
|
||||||
{
|
{
|
||||||
$events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
|
$events->listen('invoice.sent', 'InvoiceEventHandler@onSent');
|
||||||
$events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
|
$events->listen('invoice.viewed', 'InvoiceEventHandler@onViewed');
|
||||||
$events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
|
$events->listen('invoice.paid', 'InvoiceEventHandler@onPaid');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSent($invoice)
|
public function onSent($invoice)
|
||||||
{
|
{
|
||||||
$this->sendNotifications($invoice, 'sent');
|
$this->sendNotifications($invoice, 'sent');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onViewed($invoice)
|
public function onViewed($invoice)
|
||||||
{
|
{
|
||||||
$this->sendNotifications($invoice, 'viewed');
|
$this->sendNotifications($invoice, 'viewed');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPaid($payment)
|
public function onPaid($payment)
|
||||||
{
|
{
|
||||||
$this->contactMailer->sendPaymentConfirmation($payment);
|
$this->contactMailer->sendPaymentConfirmation($payment);
|
||||||
|
|
||||||
$this->sendNotifications($payment->invoice, 'paid', $payment);
|
$this->sendNotifications($payment->invoice, 'paid', $payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sendNotifications($invoice, $type, $payment = null)
|
private function sendNotifications($invoice, $type, $payment = null)
|
||||||
{
|
{
|
||||||
foreach ($invoice->account->users as $user)
|
foreach ($invoice->account->users as $user) {
|
||||||
{
|
if ($user->{'notify_' . $type}) {
|
||||||
if ($user->{'notify_' . $type})
|
|
||||||
{
|
|
||||||
$this->userMailer->sendNotification($user, $invoice, $type, $payment);
|
$this->userMailer->sendNotification($user, $invoice, $type, $payment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,15 +31,15 @@ class AccountApiController extends BaseAPIController
|
|||||||
{
|
{
|
||||||
$headers = Utils::getApiHeaders();
|
$headers = Utils::getApiHeaders();
|
||||||
|
|
||||||
if(hash_equals(env(API_SECRET),$request->api_secret))
|
if (hash_equals(env(API_SECRET), $request->api_secret)) {
|
||||||
return Response::make(RESULT_SUCCESS, 200, $headers);
|
return Response::make(RESULT_SUCCESS, 200, $headers);
|
||||||
else
|
} else {
|
||||||
return $this->errorResponse(['message'=>'API Secret does not match .env variable'], 400);
|
return $this->errorResponse(['message'=>'API Secret does not match .env variable'], 400);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register(RegisterRequest $request)
|
public function register(RegisterRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password);
|
$account = $this->accountRepo->create($request->first_name, $request->last_name, $request->email, $request->password);
|
||||||
$user = $account->users()->first();
|
$user = $account->users()->first();
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ class AccountApiController extends BaseAPIController
|
|||||||
return $this->processLogin($request);
|
return $this->processLogin($request);
|
||||||
} else {
|
} else {
|
||||||
sleep(ERROR_DELAY);
|
sleep(ERROR_DELAY);
|
||||||
return $this->errorResponse(['message'=>'Invalid credentials'],401);
|
return $this->errorResponse(['message'=>'Invalid credentials'], 401);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,20 +117,19 @@ class AccountApiController extends BaseAPIController
|
|||||||
$account = Auth::user()->account;
|
$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)
|
//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++)
|
for ($x=0; $x<count($devices); $x++) {
|
||||||
{
|
if ($devices[$x]['email'] == Auth::user()->username) {
|
||||||
if ($devices[$x]['email'] == Auth::user()->username) {
|
$devices[$x]['token'] = $request->token; //update
|
||||||
$devices[$x]['token'] = $request->token; //update
|
|
||||||
$account->devices = json_encode($devices);
|
$account->devices = json_encode($devices);
|
||||||
$account->save();
|
$account->save();
|
||||||
$devices[$x]['account_key'] = $account->account_key;
|
$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
|
//User does not have a device, create new record
|
||||||
|
|
||||||
@ -139,10 +138,10 @@ class AccountApiController extends BaseAPIController
|
|||||||
'email' => $request->email,
|
'email' => $request->email,
|
||||||
'device' => $request->device,
|
'device' => $request->device,
|
||||||
'account_key' => $account->account_key,
|
'account_key' => $account->account_key,
|
||||||
'notify_sent' => TRUE,
|
'notify_sent' => true,
|
||||||
'notify_viewed' => TRUE,
|
'notify_viewed' => true,
|
||||||
'notify_approved' => TRUE,
|
'notify_approved' => true,
|
||||||
'notify_paid' => TRUE,
|
'notify_paid' => true,
|
||||||
];
|
];
|
||||||
|
|
||||||
$devices[] = $newDevice;
|
$devices[] = $newDevice;
|
||||||
@ -150,23 +149,20 @@ class AccountApiController extends BaseAPIController
|
|||||||
$account->save();
|
$account->save();
|
||||||
|
|
||||||
return $this->response($newDevice);
|
return $this->response($newDevice);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePushNotifications(Request $request)
|
public function updatePushNotifications(Request $request)
|
||||||
{
|
{
|
||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
|
|
||||||
$devices = json_decode($account->devices, TRUE);
|
$devices = json_decode($account->devices, true);
|
||||||
|
|
||||||
if(count($devices) < 1)
|
if (count($devices) < 1) {
|
||||||
return $this->errorResponse(['message'=>'No registered devices.'], 400);
|
return $this->errorResponse(['message'=>'No registered devices.'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
for($x=0; $x<count($devices); $x++)
|
for ($x=0; $x<count($devices); $x++) {
|
||||||
{
|
if ($devices[$x]['email'] == Auth::user()->username) {
|
||||||
if($devices[$x]['email'] == Auth::user()->username)
|
|
||||||
{
|
|
||||||
|
|
||||||
$newDevice = [
|
$newDevice = [
|
||||||
'token' => $devices[$x]['token'],
|
'token' => $devices[$x]['token'],
|
||||||
'email' => $devices[$x]['email'],
|
'email' => $devices[$x]['email'],
|
||||||
@ -185,7 +181,6 @@ class AccountApiController extends BaseAPIController
|
|||||||
return $this->response($newDevice);
|
return $this->response($newDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function oauthLogin(Request $request)
|
public function oauthLogin(Request $request)
|
||||||
|
@ -87,8 +87,7 @@ class AccountController extends BaseController
|
|||||||
ContactMailer $contactMailer,
|
ContactMailer $contactMailer,
|
||||||
ReferralRepository $referralRepository,
|
ReferralRepository $referralRepository,
|
||||||
PaymentService $paymentService
|
PaymentService $paymentService
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->accountRepo = $accountRepo;
|
$this->accountRepo = $accountRepo;
|
||||||
$this->userMailer = $userMailer;
|
$this->userMailer = $userMailer;
|
||||||
$this->contactMailer = $contactMailer;
|
$this->contactMailer = $contactMailer;
|
||||||
@ -161,7 +160,8 @@ class AccountController extends BaseController
|
|||||||
/**
|
/**
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function changePlan() {
|
public function changePlan()
|
||||||
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$account = $user->account;
|
$account = $user->account;
|
||||||
$company = $account->company;
|
$company = $account->company;
|
||||||
@ -171,7 +171,7 @@ class AccountController extends BaseController
|
|||||||
$numUsers = Input::get('num_users');
|
$numUsers = Input::get('num_users');
|
||||||
|
|
||||||
if ($plan != PLAN_ENTERPRISE) {
|
if ($plan != PLAN_ENTERPRISE) {
|
||||||
$numUsers = 1;
|
$numUsers = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$planDetails = $account->getPlanDetails(false, false);
|
$planDetails = $account->getPlanDetails(false, false);
|
||||||
@ -221,12 +221,11 @@ class AccountController extends BaseController
|
|||||||
if ($newPlan['price'] > $credit) {
|
if ($newPlan['price'] > $credit) {
|
||||||
$invitation = $this->accountRepo->enablePlan($newPlan, $credit);
|
$invitation = $this->accountRepo->enablePlan($newPlan, $credit);
|
||||||
if ($hasPaid) {
|
if ($hasPaid) {
|
||||||
return Redirect::to('view/' . $invitation->invitation_key);
|
return Redirect::to('view/' . $invitation->invitation_key);
|
||||||
} else {
|
} else {
|
||||||
return Redirect::to('payment/' . $invitation->invitation_key);
|
return Redirect::to('payment/' . $invitation->invitation_key);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if ($plan == PLAN_FREE) {
|
if ($plan == PLAN_FREE) {
|
||||||
$company->discount = 0;
|
$company->discount = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -290,7 +289,7 @@ class AccountController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function showSection($section = false)
|
public function showSection($section = false)
|
||||||
{
|
{
|
||||||
if ( ! Auth::user()->is_admin) {
|
if (! Auth::user()->is_admin) {
|
||||||
return Redirect::to('/settings/user_details');
|
return Redirect::to('/settings/user_details');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,7 +748,7 @@ class AccountController extends BaseController
|
|||||||
$account->live_preview = Input::get('live_preview') ? true : false;
|
$account->live_preview = Input::get('live_preview') ? true : false;
|
||||||
|
|
||||||
// Automatically disable live preview when using a large font
|
// Automatically disable live preview when using a large font
|
||||||
$fonts = Cache::get('fonts')->filter(function($font) use ($account) {
|
$fonts = Cache::get('fonts')->filter(function ($font) use ($account) {
|
||||||
if ($font->google_font) {
|
if ($font->google_font) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1036,14 +1035,13 @@ class AccountController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$extension = strtolower($uploaded->getClientOriginalExtension());
|
$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];
|
$documentType = Document::$extraExtensions[$extension];
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$documentType = $extension;
|
$documentType = $extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!in_array($documentType, ['jpeg', 'png', 'gif'])){
|
if (!in_array($documentType, ['jpeg', 'png', 'gif'])) {
|
||||||
Session::flash('warning', 'Unsupported file type');
|
Session::flash('warning', 'Unsupported file type');
|
||||||
} else {
|
} else {
|
||||||
$documentTypeData = Document::$types[$documentType];
|
$documentTypeData = Document::$types[$documentType];
|
||||||
@ -1051,7 +1049,7 @@ class AccountController extends BaseController
|
|||||||
$filePath = $uploaded->path();
|
$filePath = $uploaded->path();
|
||||||
$size = filesize($filePath);
|
$size = filesize($filePath);
|
||||||
|
|
||||||
if($size/1000 > MAX_DOCUMENT_SIZE){
|
if ($size/1000 > MAX_DOCUMENT_SIZE) {
|
||||||
Session::flash('warning', 'File too large');
|
Session::flash('warning', 'File too large');
|
||||||
} else {
|
} else {
|
||||||
if ($documentType != 'gif') {
|
if ($documentType != 'gif') {
|
||||||
@ -1128,7 +1126,7 @@ class AccountController extends BaseController
|
|||||||
$user->email = trim(strtolower(Input::get('email')));
|
$user->email = trim(strtolower(Input::get('email')));
|
||||||
$user->phone = trim(Input::get('phone'));
|
$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_sent = Input::get('notify_sent');
|
||||||
$user->notify_viewed = Input::get('notify_viewed');
|
$user->notify_viewed = Input::get('notify_viewed');
|
||||||
$user->notify_paid = Input::get('notify_paid');
|
$user->notify_paid = Input::get('notify_paid');
|
||||||
@ -1204,7 +1202,7 @@ class AccountController extends BaseController
|
|||||||
$gateway_type_id = intval(Input::get('gateway_type_id'));
|
$gateway_type_id = intval(Input::get('gateway_type_id'));
|
||||||
$gateway_settings = AccountGatewaySettings::scope()->where('gateway_type_id', '=', $gateway_type_id)->first();
|
$gateway_settings = AccountGatewaySettings::scope()->where('gateway_type_id', '=', $gateway_type_id)->first();
|
||||||
|
|
||||||
if ( ! $gateway_settings) {
|
if (! $gateway_settings) {
|
||||||
$gateway_settings = AccountGatewaySettings::createNew();
|
$gateway_settings = AccountGatewaySettings::createNew();
|
||||||
$gateway_settings->gateway_type_id = $gateway_type_id;
|
$gateway_settings->gateway_type_id = $gateway_type_id;
|
||||||
}
|
}
|
||||||
@ -1232,7 +1230,7 @@ class AccountController extends BaseController
|
|||||||
{
|
{
|
||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
if ($account->hasLogo()) {
|
if ($account->hasLogo()) {
|
||||||
if ( ! Utils::isNinjaProd()) {
|
if (! Utils::isNinjaProd()) {
|
||||||
$account->getLogoDisk()->delete($account->logo);
|
$account->getLogoDisk()->delete($account->logo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1349,7 +1347,7 @@ class AccountController extends BaseController
|
|||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
\Log::info("Canceled Account: {$account->name} - {$user->email}");
|
\Log::info("Canceled Account: {$account->name} - {$user->email}");
|
||||||
|
|
||||||
Document::scope()->each(function($item, $key) {
|
Document::scope()->each(function ($item, $key) {
|
||||||
$item->delete();
|
$item->delete();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1416,7 +1414,7 @@ class AccountController extends BaseController
|
|||||||
->withTrashed()
|
->withTrashed()
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ( ! $invoice) {
|
if (! $invoice) {
|
||||||
return trans('texts.create_invoice_for_sample');
|
return trans('texts.create_invoice_for_sample');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class AccountGatewayController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
if ( ! \Request::secure() && ! Utils::isNinjaDev()) {
|
if (! \Request::secure() && ! Utils::isNinjaDev()) {
|
||||||
Session::flash('warning', trans('texts.enable_https'));
|
Session::flash('warning', trans('texts.enable_https'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ class AccountGatewayController extends BaseController
|
|||||||
$accountGatewaysIds = $account->gatewayIds();
|
$accountGatewaysIds = $account->gatewayIds();
|
||||||
$otherProviders = Input::get('other_providers');
|
$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;
|
$otherProviders = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ class AccountGatewayController extends BaseController
|
|||||||
|
|
||||||
foreach ($gateways as $gateway) {
|
foreach ($gateways as $gateway) {
|
||||||
$fields = $gateway->getFields();
|
$fields = $gateway->getFields();
|
||||||
if ( ! $gateway->isCustom()) {
|
if (! $gateway->isCustom()) {
|
||||||
asort($fields);
|
asort($fields);
|
||||||
}
|
}
|
||||||
$gateway->fields = $gateway->id == GATEWAY_WEPAY ? [] : $fields;
|
$gateway->fields = $gateway->id == GATEWAY_WEPAY ? [] : $fields;
|
||||||
@ -231,7 +231,7 @@ class AccountGatewayController extends BaseController
|
|||||||
$accountGateway->gateway_id = $gatewayId;
|
$accountGateway->gateway_id = $gatewayId;
|
||||||
|
|
||||||
if ($gatewayId == GATEWAY_WEPAY) {
|
if ($gatewayId == GATEWAY_WEPAY) {
|
||||||
if(!$this->setupWePay($accountGateway, $wepayResponse)) {
|
if (!$this->setupWePay($accountGateway, $wepayResponse)) {
|
||||||
return $wepayResponse;
|
return $wepayResponse;
|
||||||
}
|
}
|
||||||
$oldConfig = $accountGateway->getConfig();
|
$oldConfig = $accountGateway->getConfig();
|
||||||
@ -255,7 +255,7 @@ class AccountGatewayController extends BaseController
|
|||||||
$config->$field = $value;
|
$config->$field = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif($oldConfig) {
|
} elseif ($oldConfig) {
|
||||||
$config = clone $oldConfig;
|
$config = clone $oldConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +383,7 @@ class AccountGatewayController extends BaseController
|
|||||||
->withInput();
|
->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try {
|
||||||
$wepay = Utils::setupWePay();
|
$wepay = Utils::setupWePay();
|
||||||
|
|
||||||
$userDetails = [
|
$userDetails = [
|
||||||
@ -428,9 +428,9 @@ class AccountGatewayController extends BaseController
|
|||||||
try {
|
try {
|
||||||
$wepay->request('user/send_confirmation/', []);
|
$wepay->request('user/send_confirmation/', []);
|
||||||
$confirmationRequired = true;
|
$confirmationRequired = true;
|
||||||
} catch(\WePayException $ex){
|
} catch (\WePayException $ex) {
|
||||||
if ($ex->getMessage() == 'This access_token is already approved.') {
|
if ($ex->getMessage() == 'This access_token is already approved.') {
|
||||||
$confirmationRequired = false;
|
$confirmationRequired = false;
|
||||||
} else {
|
} else {
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
@ -488,5 +488,4 @@ class AccountGatewayController extends BaseController
|
|||||||
|
|
||||||
return Redirect::to("gateways/{$accountGateway->public_id}/edit");
|
return Redirect::to("gateways/{$accountGateway->public_id}/edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ class AppController extends BaseController
|
|||||||
return Redirect::to('/');
|
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>');
|
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');
|
return Redirect::to('/settings/system_settings');
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ class AppController extends BaseController
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (preg_match('/\s/', $val)) {
|
if (preg_match('/\s/', $val)) {
|
||||||
$val = "'{$val}'";
|
$val = "'{$val}'";
|
||||||
}
|
}
|
||||||
$config .= "{$key}={$val}\n";
|
$config .= "{$key}={$val}\n";
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ class AppController extends BaseController
|
|||||||
Event::fire(new UserSettingsChanged());
|
Event::fire(new UserSettingsChanged());
|
||||||
|
|
||||||
// legacy fix: check cipher is in .env file
|
// legacy fix: check cipher is in .env file
|
||||||
if ( ! env('APP_CIPHER')) {
|
if (! env('APP_CIPHER')) {
|
||||||
$fp = fopen(base_path().'/.env', 'a');
|
$fp = fopen(base_path().'/.env', 'a');
|
||||||
fwrite($fp, "\nAPP_CIPHER=AES-256-CBC");
|
fwrite($fp, "\nAPP_CIPHER=AES-256-CBC");
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
@ -314,7 +314,7 @@ class AppController extends BaseController
|
|||||||
|
|
||||||
public function stats()
|
public function stats()
|
||||||
{
|
{
|
||||||
if ( ! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) {
|
if (! hash_equals(Input::get('password'), env('RESELLER_PASSWORD'))) {
|
||||||
sleep(3);
|
sleep(3);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,6 @@ class AuthController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function postLoginWrapper(Request $request)
|
public function postLoginWrapper(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$userId = Auth::check() ? Auth::user()->id : null;
|
$userId = Auth::check() ? Auth::user()->id : null;
|
||||||
$user = User::where('email', '=', $request->input('email'))->first();
|
$user = User::where('email', '=', $request->input('email'))->first();
|
||||||
|
|
||||||
@ -155,7 +154,6 @@ class AuthController extends Controller
|
|||||||
|
|
||||||
$users = $this->accountRepo->loadAccounts(Auth::user()->id);
|
$users = $this->accountRepo->loadAccounts(Auth::user()->id);
|
||||||
Session::put(SESSION_USER_ACCOUNTS, $users);
|
Session::put(SESSION_USER_ACCOUNTS, $users);
|
||||||
|
|
||||||
} elseif ($user) {
|
} elseif ($user) {
|
||||||
$user->failed_logins = $user->failed_logins + 1;
|
$user->failed_logins = $user->failed_logins + 1;
|
||||||
$user->save();
|
$user->save();
|
||||||
@ -173,7 +171,7 @@ class AuthController extends Controller
|
|||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
$this->accountRepo->unlinkAccount($account);
|
$this->accountRepo->unlinkAccount($account);
|
||||||
|
|
||||||
if ( ! $account->hasMultipleAccounts()) {
|
if (! $account->hasMultipleAccounts()) {
|
||||||
$account->company->forceDelete();
|
$account->company->forceDelete();
|
||||||
}
|
}
|
||||||
$account->forceDelete();
|
$account->forceDelete();
|
||||||
|
@ -34,5 +34,4 @@ class PasswordController extends Controller
|
|||||||
{
|
{
|
||||||
$this->middleware('guest');
|
$this->middleware('guest');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -92,13 +92,13 @@ class BaseAPIController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($clientPublicId = Input::get('client_id')) {
|
if ($clientPublicId = Input::get('client_id')) {
|
||||||
$filter = function($query) use ($clientPublicId) {
|
$filter = function ($query) use ($clientPublicId) {
|
||||||
$query->where('public_id', '=', $clientPublicId);
|
$query->where('public_id', '=', $clientPublicId);
|
||||||
};
|
};
|
||||||
$query->whereHas('client', $filter);
|
$query->whereHas('client', $filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! Utils::hasPermission('view_all')){
|
if (! Utils::hasPermission('view_all')) {
|
||||||
if ($this->entityType == ENTITY_USER) {
|
if ($this->entityType == ENTITY_USER) {
|
||||||
$query->where('id', '=', Auth::user()->id);
|
$query->where('id', '=', Auth::user()->id);
|
||||||
} else {
|
} else {
|
||||||
@ -174,14 +174,13 @@ class BaseAPIController extends Controller
|
|||||||
return Response::make($response, 200, $headers);
|
return Response::make($response, 200, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function errorResponse($response, $httpErrorCode = 400)
|
protected function errorResponse($response, $httpErrorCode = 400)
|
||||||
{
|
{
|
||||||
$error['error'] = $response;
|
$error['error'] = $response;
|
||||||
$error = json_encode($error, JSON_PRETTY_PRINT);
|
$error = json_encode($error, JSON_PRETTY_PRINT);
|
||||||
$headers = Utils::getApiHeaders();
|
$headers = Utils::getApiHeaders();
|
||||||
|
|
||||||
return Response::make($error, $httpErrorCode, $headers);
|
return Response::make($error, $httpErrorCode, $headers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getRequestIncludes($data)
|
protected function getRequestIncludes($data)
|
||||||
|
@ -25,7 +25,7 @@ class BaseController extends Controller
|
|||||||
|
|
||||||
protected function returnBulk($entityType, $action, $ids)
|
protected function returnBulk($entityType, $action, $ids)
|
||||||
{
|
{
|
||||||
if ( ! is_array($ids)) {
|
if (! is_array($ids)) {
|
||||||
$ids = [$ids];
|
$ids = [$ids];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,83 +8,87 @@ use Redirect;
|
|||||||
use URL;
|
use URL;
|
||||||
use Session;
|
use Session;
|
||||||
|
|
||||||
class BlueVineController extends BaseController {
|
class BlueVineController extends BaseController
|
||||||
public function signup() {
|
{
|
||||||
$user = Auth::user();
|
public function signup()
|
||||||
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'personal_user_full_name' => Input::get( 'name' ),
|
'personal_user_full_name' => Input::get('name'),
|
||||||
'business_phone_number' => Input::get( 'phone' ),
|
'business_phone_number' => Input::get('phone'),
|
||||||
'email' => Input::get( 'email' ),
|
'email' => Input::get('email'),
|
||||||
'personal_fico_score' => intval( Input::get( 'fico_score' ) ),
|
'personal_fico_score' => intval(Input::get('fico_score')),
|
||||||
'business_annual_revenue' => intval( Input::get( 'annual_revenue' ) ),
|
'business_annual_revenue' => intval(Input::get('annual_revenue')),
|
||||||
'business_monthly_average_bank_balance' => intval( Input::get( 'average_bank_balance' ) ),
|
'business_monthly_average_bank_balance' => intval(Input::get('average_bank_balance')),
|
||||||
'business_inception_date' => date( 'Y-m-d', strtotime( Input::get( 'business_inception' ) ) ),
|
'business_inception_date' => date('Y-m-d', strtotime(Input::get('business_inception'))),
|
||||||
'partner_internal_business_id' => 'ninja_account_' . $user->account_id,
|
'partner_internal_business_id' => 'ninja_account_' . $user->account_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( ! empty( Input::get( 'quote_type_factoring' ) ) ) {
|
if (! empty(Input::get('quote_type_factoring'))) {
|
||||||
$data['invoice_factoring_offer'] = true;
|
$data['invoice_factoring_offer'] = true;
|
||||||
$data['desired_credit_line'] = intval( Input::get( 'desired_credit_limit' )['invoice_factoring'] );
|
$data['desired_credit_line'] = intval(Input::get('desired_credit_limit')['invoice_factoring']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( Input::get( 'quote_type_loc' ) ) ) {
|
if (! empty(Input::get('quote_type_loc'))) {
|
||||||
$data['line_of_credit_offer'] = true;
|
$data['line_of_credit_offer'] = true;
|
||||||
$data['desired_credit_line_for_loc'] = intval( Input::get( 'desired_credit_limit' )['line_of_credit'] );
|
$data['desired_credit_line_for_loc'] = intval(Input::get('desired_credit_limit')['line_of_credit']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$api_client = new \GuzzleHttp\Client();
|
$api_client = new \GuzzleHttp\Client();
|
||||||
try {
|
try {
|
||||||
$response = $api_client->request( 'POST',
|
$response = $api_client->request('POST',
|
||||||
'https://app.bluevine.com/api/v1/user/register_external?' . http_build_query( array(
|
'https://app.bluevine.com/api/v1/user/register_external?' . http_build_query(array(
|
||||||
'external_register_token' => env( 'BLUEVINE_PARTNER_TOKEN' ),
|
'external_register_token' => env('BLUEVINE_PARTNER_TOKEN'),
|
||||||
'c' => env( 'BLUEVINE_PARTNER_UNIQUE_ID' ),
|
'c' => env('BLUEVINE_PARTNER_UNIQUE_ID'),
|
||||||
'signup_parent_url' => URL::to( '/bluevine/completed' ),
|
'signup_parent_url' => URL::to('/bluevine/completed'),
|
||||||
) ), array(
|
)), array(
|
||||||
'json' => $data
|
'json' => $data
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch ( \GuzzleHttp\Exception\RequestException $ex ) {
|
} catch (\GuzzleHttp\Exception\RequestException $ex) {
|
||||||
if ( $ex->getCode() == 403 ) {
|
if ($ex->getCode() == 403) {
|
||||||
$response_body = $ex->getResponse()->getBody( true );
|
$response_body = $ex->getResponse()->getBody(true);
|
||||||
$response_data = json_decode( $response_body );
|
$response_data = json_decode($response_body);
|
||||||
|
|
||||||
return response()->json( [
|
return response()->json([
|
||||||
'error' => true,
|
'error' => true,
|
||||||
'message' => $response_data->reason
|
'message' => $response_data->reason
|
||||||
] );
|
]);
|
||||||
} else {
|
} else {
|
||||||
return response()->json( [
|
return response()->json([
|
||||||
'error' => true
|
'error' => true
|
||||||
] );
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$company = $user->account->company;
|
$company = $user->account->company;
|
||||||
$company->bluevine_status = 'signed_up';
|
$company->bluevine_status = 'signed_up';
|
||||||
$company->save();
|
$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() {
|
public function hideMessage()
|
||||||
$user = Auth::user();
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
if ( $user ) {
|
if ($user) {
|
||||||
$company = $user->account->company;
|
$company = $user->account->company;
|
||||||
$company->bluevine_status = 'ignored';
|
$company->bluevine_status = 'ignored';
|
||||||
$company->save();
|
$company->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'success';
|
return 'success';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleCompleted() {
|
public function handleCompleted()
|
||||||
Session::flash( 'message', trans( 'texts.bluevine_completed' ) );
|
{
|
||||||
|
Session::flash('message', trans('texts.bluevine_completed'));
|
||||||
|
|
||||||
return Redirect::to( '/dashboard' );
|
return Redirect::to('/dashboard');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class BotController extends Controller
|
|||||||
$input = Input::all();
|
$input = Input::all();
|
||||||
$botUserId = $input['from']['id'];
|
$botUserId = $input['from']['id'];
|
||||||
|
|
||||||
if ( ! $token = $this->authenticate($input)) {
|
if (! $token = $this->authenticate($input)) {
|
||||||
return SkypeResponse::message(trans('texts.not_authorized'));
|
return SkypeResponse::message(trans('texts.not_authorized'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class BotController extends Controller
|
|||||||
} elseif ($text == 'status') {
|
} elseif ($text == 'status') {
|
||||||
$response = SkypeResponse::message(trans('texts.intent_not_supported'));
|
$response = SkypeResponse::message(trans('texts.intent_not_supported'));
|
||||||
} else {
|
} else {
|
||||||
if ( ! $user = User::whereBotUserId($botUserId)->with('account')->first()) {
|
if (! $user = User::whereBotUserId($botUserId)->with('account')->first()) {
|
||||||
return SkypeResponse::message(trans('texts.not_authorized'));
|
return SkypeResponse::message(trans('texts.not_authorized'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ class BotController extends Controller
|
|||||||
|
|
||||||
if (Utils::isNinjaDev()) {
|
if (Utils::isNinjaDev()) {
|
||||||
// skip validation for testing
|
// skip validation for testing
|
||||||
} elseif ( ! $this->validateToken($token)) {
|
} elseif (! $this->validateToken($token)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class BotController extends Controller
|
|||||||
|
|
||||||
private function validateEmail($email, $botUserId)
|
private function validateEmail($email, $botUserId)
|
||||||
{
|
{
|
||||||
if ( ! $email || ! $botUserId) {
|
if (! $email || ! $botUserId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ class BotController extends Controller
|
|||||||
->whereNull('bot_user_id')
|
->whereNull('bot_user_id')
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ( ! $user) {
|
if (! $user) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ class BotController extends Controller
|
|||||||
|
|
||||||
private function validateCode($input, $botUserId)
|
private function validateCode($input, $botUserId)
|
||||||
{
|
{
|
||||||
if ( ! $input || ! $botUserId) {
|
if (! $input || ! $botUserId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,11 +230,11 @@ class BotController extends Controller
|
|||||||
->where('attempts', '<', 5)
|
->where('attempts', '<', 5)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ( ! $code) {
|
if (! $code) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! hash_equals($code->code, $input)) {
|
if (! hash_equals($code->code, $input)) {
|
||||||
$code->attempts += 1;
|
$code->attempts += 1;
|
||||||
$code->save();
|
$code->save();
|
||||||
return false;
|
return false;
|
||||||
@ -256,7 +256,7 @@ class BotController extends Controller
|
|||||||
|
|
||||||
private function validateToken($token)
|
private function validateToken($token)
|
||||||
{
|
{
|
||||||
if ( ! $token) {
|
if (! $token) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,17 +273,17 @@ class BotController extends Controller
|
|||||||
$sig_enc = $token_arr[2];
|
$sig_enc = $token_arr[2];
|
||||||
|
|
||||||
// 2 base 64 url decoding
|
// 2 base 64 url decoding
|
||||||
$headers_arr = json_decode($this->base64_url_decode($headers_enc), TRUE);
|
$headers_arr = json_decode($this->base64_url_decode($headers_enc), true);
|
||||||
$claims_arr = json_decode($this->base64_url_decode($claims_enc), TRUE);
|
$claims_arr = json_decode($this->base64_url_decode($claims_enc), true);
|
||||||
$sig = $this->base64_url_decode($sig_enc);
|
$sig = $this->base64_url_decode($sig_enc);
|
||||||
|
|
||||||
// 3 get key list
|
// 3 get key list
|
||||||
$keylist = file_get_contents('https://api.aps.skype.com/v1/keys');
|
$keylist = file_get_contents('https://api.aps.skype.com/v1/keys');
|
||||||
$keylist_arr = json_decode($keylist, TRUE);
|
$keylist_arr = json_decode($keylist, true);
|
||||||
foreach($keylist_arr['keys'] as $key => $value) {
|
foreach ($keylist_arr['keys'] as $key => $value) {
|
||||||
|
|
||||||
// 4 select one key (which matches)
|
// 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
|
// 5 get public key from key info
|
||||||
$cert_txt = '-----BEGIN CERTIFICATE-----' . "\n" . chunk_split($value['x5c'][0], 64) . '-----END CERTIFICATE-----';
|
$cert_txt = '-----BEGIN CERTIFICATE-----' . "\n" . chunk_split($value['x5c'][0], 64) . '-----END CERTIFICATE-----';
|
||||||
@ -301,7 +301,8 @@ class BotController extends Controller
|
|||||||
return ($token_valid == 1);
|
return ($token_valid == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function base64_url_decode($arg) {
|
private function base64_url_decode($arg)
|
||||||
|
{
|
||||||
$res = $arg;
|
$res = $arg;
|
||||||
$res = str_replace('-', '+', $res);
|
$res = str_replace('-', '+', $res);
|
||||||
$res = str_replace('_', '/', $res);
|
$res = str_replace('_', '/', $res);
|
||||||
|
@ -174,5 +174,4 @@ class ClientApiController extends BaseAPIController
|
|||||||
|
|
||||||
return $this->itemResponse($client);
|
return $this->itemResponse($client);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class PasswordController extends Controller
|
|||||||
* Send a reset link to the given user.
|
* Send a reset link to the given user.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function sendResetLinkEmail(Request $request)
|
public function sendResetLinkEmail(Request $request)
|
||||||
|
@ -84,29 +84,29 @@ class ClientController extends BaseController
|
|||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
|
||||||
$actionLinks = [];
|
$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)];
|
$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)];
|
$actionLinks[] = ['label' => trans('texts.new_task'), 'url' => URL::to('/tasks/create/'.$client->public_id)];
|
||||||
}
|
}
|
||||||
if (Utils::hasFeature(FEATURE_QUOTES) && $user->can('create', ENTITY_QUOTE)) {
|
if (Utils::hasFeature(FEATURE_QUOTES) && $user->can('create', ENTITY_QUOTE)) {
|
||||||
$actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => URL::to('/quotes/create/'.$client->public_id)];
|
$actionLinks[] = ['label' => trans('texts.new_quote'), 'url' => URL::to('/quotes/create/'.$client->public_id)];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($actionLinks)){
|
if (!empty($actionLinks)) {
|
||||||
$actionLinks[] = \DropdownButton::DIVIDER;
|
$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)];
|
$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)];
|
$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)];
|
$actionLinks[] = ['label' => trans('texts.enter_expense'), 'url' => URL::to('/expenses/create/0/'.$client->public_id)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class ClientPortalController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)){
|
if ($wepayGateway = $account->getGatewayConfig(GATEWAY_WEPAY)) {
|
||||||
$data['enableWePayACH'] = $wepayGateway->getAchEnabled();
|
$data['enableWePayACH'] = $wepayGateway->getAchEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,10 +157,10 @@ class ClientPortalController extends BaseController
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($account->hasFeature(FEATURE_DOCUMENTS) && $this->canCreateZip()){
|
if ($account->hasFeature(FEATURE_DOCUMENTS) && $this->canCreateZip()) {
|
||||||
$zipDocs = $this->getInvoiceZipDocuments($invoice, $size);
|
$zipDocs = $this->getInvoiceZipDocuments($invoice, $size);
|
||||||
|
|
||||||
if(count($zipDocs) > 1){
|
if (count($zipDocs) > 1) {
|
||||||
$data['documentsZipURL'] = URL::to("client/documents/{$invitation->invitation_key}");
|
$data['documentsZipURL'] = URL::to("client/documents/{$invitation->invitation_key}");
|
||||||
$data['documentsZipSize'] = $size;
|
$data['documentsZipSize'] = $size;
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ class ClientPortalController extends BaseController
|
|||||||
return $this->returnError();
|
return $this->returnError();
|
||||||
}
|
}
|
||||||
Session::put('contact_key', $contactKey);// track current contact
|
Session::put('contact_key', $contactKey);// track current contact
|
||||||
} else if (!$contact = $this->getContact()) {
|
} elseif (!$contact = $this->getContact()) {
|
||||||
return $this->returnError();
|
return $this->returnError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +274,9 @@ class ClientPortalController extends BaseController
|
|||||||
$query->where('activities.adjustment', '!=', 0);
|
$query->where('activities.adjustment', '!=', 0);
|
||||||
|
|
||||||
return Datatable::query($query)
|
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) {
|
->addColumn('activity_type_id', function ($model) {
|
||||||
$data = [
|
$data = [
|
||||||
'client' => Utils::getClientDisplayName($model),
|
'client' => Utils::getClientDisplayName($model),
|
||||||
@ -288,9 +290,13 @@ class ClientPortalController extends BaseController
|
|||||||
];
|
];
|
||||||
|
|
||||||
return trans("texts.activity_{$model->activity_type_id}", $data);
|
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('balance', function ($model) {
|
||||||
->addColumn('adjustment', function ($model) { return $model->adjustment != 0 ? Utils::wrapAdjustment($model->adjustment, $model->currency_id, $model->country_id) : ''; })
|
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();
|
->make();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,13 +410,25 @@ class ClientPortalController extends BaseController
|
|||||||
$payments = $this->paymentRepo->findForContact($contact->id, Input::get('sSearch'));
|
$payments = $this->paymentRepo->findForContact($contact->id, Input::get('sSearch'));
|
||||||
|
|
||||||
return Datatable::query($payments)
|
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('invoice_number', function ($model) {
|
||||||
->addColumn('transaction_reference', function ($model) { return $model->transaction_reference ? $model->transaction_reference : '<i>'.trans('texts.manual_entry').'</i>'; })
|
return $model->invitation_key ? link_to('/view/'.$model->invitation_key, $model->invoice_number)->toHtml() : $model->invoice_number;
|
||||||
->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('transaction_reference', function ($model) {
|
||||||
->addColumn('payment_date', function ($model) { return Utils::dateToString($model->payment_date); })
|
return $model->transaction_reference ? $model->transaction_reference : '<i>'.trans('texts.manual_entry').'</i>';
|
||||||
->addColumn('status', function ($model) { return $this->getPaymentStatusLabel($model); })
|
})
|
||||||
->orderColumns( 'invoice_number', 'transaction_reference', 'payment_type', 'amount', 'payment_date')
|
->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();
|
->make();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,7 +578,8 @@ class ClientPortalController extends BaseController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getContact() {
|
private function getContact()
|
||||||
|
{
|
||||||
$contactKey = session('contact_key');
|
$contactKey = session('contact_key');
|
||||||
|
|
||||||
if (!$contactKey) {
|
if (!$contactKey) {
|
||||||
@ -576,7 +595,8 @@ class ClientPortalController extends BaseController
|
|||||||
return $contact;
|
return $contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDocumentVFSJS($publicId, $name){
|
public function getDocumentVFSJS($publicId, $name)
|
||||||
|
{
|
||||||
if (!$contact = $this->getContact()) {
|
if (!$contact = $this->getContact()) {
|
||||||
return $this->returnError();
|
return $this->returnError();
|
||||||
}
|
}
|
||||||
@ -584,22 +604,22 @@ class ClientPortalController extends BaseController
|
|||||||
$document = Document::scope($publicId, $contact->account_id)->first();
|
$document = Document::scope($publicId, $contact->account_id)->first();
|
||||||
|
|
||||||
|
|
||||||
if(!$document->isPDFEmbeddable()){
|
if (!$document->isPDFEmbeddable()) {
|
||||||
return Response::view('error', ['error'=>'Image does not exist!'], 404);
|
return Response::view('error', ['error'=>'Image does not exist!'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$authorized = false;
|
$authorized = false;
|
||||||
if($document->expense && $document->expense->client_id == $contact->client_id){
|
if ($document->expense && $document->expense->client_id == $contact->client_id) {
|
||||||
$authorized = true;
|
$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;
|
$authorized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$authorized){
|
if (!$authorized) {
|
||||||
return Response::view('error', ['error'=>'Not authorized'], 403);
|
return Response::view('error', ['error'=>'Not authorized'], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(substr($name, -3)=='.js'){
|
if (substr($name, -3)=='.js') {
|
||||||
$name = substr($name, 0, -3);
|
$name = substr($name, 0, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -612,14 +632,16 @@ class ClientPortalController extends BaseController
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function canCreateZip(){
|
protected function canCreateZip()
|
||||||
|
{
|
||||||
return function_exists('gmp_init');
|
return function_exists('gmp_init');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getInvoiceZipDocuments($invoice, &$size=0){
|
protected function getInvoiceZipDocuments($invoice, &$size=0)
|
||||||
|
{
|
||||||
$documents = $invoice->documents;
|
$documents = $invoice->documents;
|
||||||
|
|
||||||
foreach($invoice->expenses as $expense){
|
foreach ($invoice->expenses as $expense) {
|
||||||
$documents = $documents->merge($expense->documents);
|
$documents = $documents->merge($expense->documents);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,31 +650,31 @@ class ClientPortalController extends BaseController
|
|||||||
$size = 0;
|
$size = 0;
|
||||||
$maxSize = MAX_ZIP_DOCUMENTS_SIZE * 1000;
|
$maxSize = MAX_ZIP_DOCUMENTS_SIZE * 1000;
|
||||||
$toZip = [];
|
$toZip = [];
|
||||||
foreach($documents as $document){
|
foreach ($documents as $document) {
|
||||||
if($size + $document->size > $maxSize)break;
|
if ($size + $document->size > $maxSize) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(!empty($toZip[$document->name])){
|
if (!empty($toZip[$document->name])) {
|
||||||
// This name is taken
|
// 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
|
// 2 different files with the same name
|
||||||
$nameInfo = pathinfo($document->name);
|
$nameInfo = pathinfo($document->name);
|
||||||
|
|
||||||
for($i = 1;; $i++){
|
for ($i = 1;; $i++) {
|
||||||
$name = $nameInfo['filename'].' ('.$i.').'.$nameInfo['extension'];
|
$name = $nameInfo['filename'].' ('.$i.').'.$nameInfo['extension'];
|
||||||
|
|
||||||
if(empty($toZip[$name])){
|
if (empty($toZip[$name])) {
|
||||||
$toZip[$name] = $document;
|
$toZip[$name] = $document;
|
||||||
$size += $document->size;
|
$size += $document->size;
|
||||||
break;
|
break;
|
||||||
} else if ($toZip[$name]->hash == $document->hash){
|
} elseif ($toZip[$name]->hash == $document->hash) {
|
||||||
// We're not adding this after all
|
// We're not adding this after all
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$toZip[$document->name] = $document;
|
$toZip[$document->name] = $document;
|
||||||
$size += $document->size;
|
$size += $document->size;
|
||||||
}
|
}
|
||||||
@ -661,7 +683,8 @@ class ClientPortalController extends BaseController
|
|||||||
return $toZip;
|
return $toZip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getInvoiceDocumentsZip($invitationKey){
|
public function getInvoiceDocumentsZip($invitationKey)
|
||||||
|
{
|
||||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||||
return $this->returnError();
|
return $this->returnError();
|
||||||
}
|
}
|
||||||
@ -672,21 +695,22 @@ class ClientPortalController extends BaseController
|
|||||||
|
|
||||||
$toZip = $this->getInvoiceZipDocuments($invoice);
|
$toZip = $this->getInvoiceZipDocuments($invoice);
|
||||||
|
|
||||||
if(!count($toZip)){
|
if (!count($toZip)) {
|
||||||
return Response::view('error', ['error'=>'No documents small enough'], 404);
|
return Response::view('error', ['error'=>'No documents small enough'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$zip = new ZipArchive($invitation->account->name.' Invoice '.$invoice->invoice_number.'.zip');
|
$zip = new ZipArchive($invitation->account->name.' Invoice '.$invoice->invoice_number.'.zip');
|
||||||
return Response::stream(function() use ($toZip, $zip) {
|
return Response::stream(function () use ($toZip, $zip) {
|
||||||
foreach($toZip as $name=>$document){
|
foreach ($toZip as $name=>$document) {
|
||||||
$fileStream = $document->getStream();
|
$fileStream = $document->getStream();
|
||||||
if($fileStream){
|
if ($fileStream) {
|
||||||
$zip->init_file_stream_transfer($name, $document->size, ['time'=>$document->created_at->timestamp]);
|
$zip->init_file_stream_transfer($name, $document->size, ['time'=>$document->created_at->timestamp]);
|
||||||
while ($buffer = fread($fileStream, 256000))$zip->stream_file_part($buffer);
|
while ($buffer = fread($fileStream, 256000)) {
|
||||||
|
$zip->stream_file_part($buffer);
|
||||||
|
}
|
||||||
fclose($fileStream);
|
fclose($fileStream);
|
||||||
$zip->complete_file_stream();
|
$zip->complete_file_stream();
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$zip->add_file($name, $document->getRaw());
|
$zip->add_file($name, $document->getRaw());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -694,7 +718,8 @@ class ClientPortalController extends BaseController
|
|||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDocument($invitationKey, $publicId){
|
public function getDocument($invitationKey, $publicId)
|
||||||
|
{
|
||||||
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||||
return $this->returnError();
|
return $this->returnError();
|
||||||
}
|
}
|
||||||
@ -705,13 +730,13 @@ class ClientPortalController extends BaseController
|
|||||||
$document = Document::scope($publicId, $invitation->account_id)->firstOrFail();
|
$document = Document::scope($publicId, $invitation->account_id)->firstOrFail();
|
||||||
|
|
||||||
$authorized = false;
|
$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;
|
$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;
|
$authorized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$authorized){
|
if (!$authorized) {
|
||||||
return Response::view('error', ['error'=>'Not authorized'], 403);
|
return Response::view('error', ['error'=>'Not authorized'], 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,7 +820,8 @@ class ClientPortalController extends BaseController
|
|||||||
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(){
|
public function setDefaultPaymentMethod()
|
||||||
|
{
|
||||||
if (!$contact = $this->getContact()) {
|
if (!$contact = $this->getContact()) {
|
||||||
return $this->returnError();
|
return $this->returnError();
|
||||||
}
|
}
|
||||||
@ -834,7 +860,8 @@ class ClientPortalController extends BaseController
|
|||||||
Utils::logError("Payment Method Error [{$type}]: " . ($exception ? Utils::getErrorString($exception) : $message), 'PHP', true);
|
Utils::logError("Payment Method Error [{$type}]: " . ($exception ? Utils::getErrorString($exception) : $message), 'PHP', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAutoBill(){
|
public function setAutoBill()
|
||||||
|
{
|
||||||
if (!$contact = $this->getContact()) {
|
if (!$contact = $this->getContact()) {
|
||||||
return $this->returnError();
|
return $this->returnError();
|
||||||
}
|
}
|
||||||
|
@ -43,10 +43,10 @@ class DashboardController extends BaseController
|
|||||||
$expenses = $dashboardRepo->expenses($accountId, $userId, $viewAll);
|
$expenses = $dashboardRepo->expenses($accountId, $userId, $viewAll);
|
||||||
$tasks = $dashboardRepo->tasks($accountId, $userId, $viewAll);
|
$tasks = $dashboardRepo->tasks($accountId, $userId, $viewAll);
|
||||||
|
|
||||||
$showBlueVinePromo = $user->is_admin
|
$showBlueVinePromo = $user->is_admin
|
||||||
&& env('BLUEVINE_PARTNER_UNIQUE_ID')
|
&& env('BLUEVINE_PARTNER_UNIQUE_ID')
|
||||||
&& ! $account->company->bluevine_status
|
&& ! $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);
|
$showWhiteLabelExpired = Utils::isSelfHost() && $account->company->hasExpiredPlan(PLAN_WHITE_LABEL);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ class DashboardController extends BaseController
|
|||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'account' => $user->account,
|
'account' => $user->account,
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'paidToDate' => $paidToDate,
|
'paidToDate' => $paidToDate,
|
||||||
'balances' => $balances,
|
'balances' => $balances,
|
||||||
'averageInvoice' => $averageInvoice,
|
'averageInvoice' => $averageInvoice,
|
||||||
@ -98,29 +98,29 @@ class DashboardController extends BaseController
|
|||||||
'currencies' => $currencies,
|
'currencies' => $currencies,
|
||||||
'expenses' => $expenses,
|
'expenses' => $expenses,
|
||||||
'tasks' => $tasks,
|
'tasks' => $tasks,
|
||||||
'showBlueVinePromo' => $showBlueVinePromo,
|
'showBlueVinePromo' => $showBlueVinePromo,
|
||||||
'showWhiteLabelExpired' => $showWhiteLabelExpired,
|
'showWhiteLabelExpired' => $showWhiteLabelExpired,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($showBlueVinePromo) {
|
if ($showBlueVinePromo) {
|
||||||
$usdLast12Months = 0;
|
$usdLast12Months = 0;
|
||||||
$pastYear = date( 'Y-m-d', strtotime( '-1 year' ));
|
$pastYear = date('Y-m-d', strtotime('-1 year'));
|
||||||
$paidLast12Months = $dashboardRepo->paidToDate( $account, $userId, $viewAll, $pastYear );
|
$paidLast12Months = $dashboardRepo->paidToDate($account, $userId, $viewAll, $pastYear);
|
||||||
|
|
||||||
foreach ( $paidLast12Months as $item ) {
|
foreach ($paidLast12Months as $item) {
|
||||||
if ( $item->currency_id == null ) {
|
if ($item->currency_id == null) {
|
||||||
$currency = $user->account->currency_id ?: DEFAULT_CURRENCY;
|
$currency = $user->account->currency_id ?: DEFAULT_CURRENCY;
|
||||||
} else {
|
} else {
|
||||||
$currency = $item->currency_id;
|
$currency = $item->currency_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $currency == CURRENCY_DOLLAR ) {
|
if ($currency == CURRENCY_DOLLAR) {
|
||||||
$usdLast12Months += $item->value;
|
$usdLast12Months += $item->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['usdLast12Months'] = $usdLast12Months;
|
$data['usdLast12Months'] = $usdLast12Months;
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('dashboard', $data);
|
return View::make('dashboard', $data);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,6 @@ class DocumentAPIController extends BaseAPIController
|
|||||||
$documents = Document::scope();
|
$documents = Document::scope();
|
||||||
|
|
||||||
return $this->listResponse($documents);
|
return $this->listResponse($documents);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,10 +64,11 @@ class DocumentAPIController extends BaseAPIController
|
|||||||
{
|
{
|
||||||
$document = $request->entity();
|
$document = $request->entity();
|
||||||
|
|
||||||
if(array_key_exists($document->type, Document::$types))
|
if (array_key_exists($document->type, Document::$types)) {
|
||||||
return DocumentController::getDownloadResponse($document);
|
return DocumentController::getDownloadResponse($document);
|
||||||
else
|
} else {
|
||||||
return $this->errorResponse(['error'=>'Invalid mime type'],400);
|
return $this->errorResponse(['error'=>'Invalid mime type'], 400);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +94,6 @@ class DocumentAPIController extends BaseAPIController
|
|||||||
*/
|
*/
|
||||||
public function store(CreateDocumentRequest $request)
|
public function store(CreateDocumentRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$document = $this->documentRepo->upload($request->all());
|
$document = $this->documentRepo->upload($request->all());
|
||||||
|
|
||||||
return $this->itemResponse($document);
|
return $this->itemResponse($document);
|
||||||
|
@ -26,25 +26,25 @@ class DocumentController extends BaseController
|
|||||||
return static::getDownloadResponse($request->entity());
|
return static::getDownloadResponse($request->entity());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getDownloadResponse($document){
|
public static function getDownloadResponse($document)
|
||||||
|
{
|
||||||
$direct_url = $document->getDirectUrl();
|
$direct_url = $document->getDirectUrl();
|
||||||
if($direct_url){
|
if ($direct_url) {
|
||||||
return redirect($direct_url);
|
return redirect($direct_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stream = $document->getStream();
|
$stream = $document->getStream();
|
||||||
|
|
||||||
if($stream){
|
if ($stream) {
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Type' => Document::$types[$document->type]['mime'],
|
'Content-Type' => Document::$types[$document->type]['mime'],
|
||||||
'Content-Length' => $document->size,
|
'Content-Length' => $document->size,
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = Response::stream(function() use ($stream) {
|
$response = Response::stream(function () use ($stream) {
|
||||||
fpassthru($stream);
|
fpassthru($stream);
|
||||||
}, 200, $headers);
|
}, 200, $headers);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$response = Response::make($document->getRaw(), 200);
|
$response = Response::make($document->getRaw(), 200);
|
||||||
$response->header('content-type', Document::$types[$document->type]['mime']);
|
$response->header('content-type', Document::$types[$document->type]['mime']);
|
||||||
}
|
}
|
||||||
@ -56,12 +56,12 @@ class DocumentController extends BaseController
|
|||||||
{
|
{
|
||||||
$document = $request->entity();
|
$document = $request->entity();
|
||||||
|
|
||||||
if(empty($document->preview)){
|
if (empty($document->preview)) {
|
||||||
return Response::view('error', ['error'=>'Preview does not exist!'], 404);
|
return Response::view('error', ['error'=>'Preview does not exist!'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$direct_url = $document->getDirectPreviewUrl();
|
$direct_url = $document->getDirectPreviewUrl();
|
||||||
if($direct_url){
|
if ($direct_url) {
|
||||||
return redirect($direct_url);
|
return redirect($direct_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,11 +76,11 @@ class DocumentController extends BaseController
|
|||||||
{
|
{
|
||||||
$document = $request->entity();
|
$document = $request->entity();
|
||||||
|
|
||||||
if(substr($name, -3)=='.js'){
|
if (substr($name, -3)=='.js') {
|
||||||
$name = substr($name, 0, -3);
|
$name = substr($name, 0, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$document->isPDFEmbeddable()){
|
if (!$document->isPDFEmbeddable()) {
|
||||||
return Response::view('error', ['error'=>'Image does not exist!'], 404);
|
return Response::view('error', ['error'=>'Image does not exist!'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,13 +97,13 @@ class DocumentController extends BaseController
|
|||||||
{
|
{
|
||||||
$result = $this->documentRepo->upload($request->all(), $doc_array);
|
$result = $this->documentRepo->upload($request->all(), $doc_array);
|
||||||
|
|
||||||
if(is_string($result)){
|
if (is_string($result)) {
|
||||||
return Response::json([
|
return Response::json([
|
||||||
'error' => $result,
|
'error' => $result,
|
||||||
'code' => 400
|
'code' => 400
|
||||||
], 400);
|
], 400);
|
||||||
} else {
|
} else {
|
||||||
return Response::json([
|
return Response::json([
|
||||||
'error' => false,
|
'error' => false,
|
||||||
'document' => $doc_array,
|
'document' => $doc_array,
|
||||||
'code' => 200
|
'code' => 200
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
|
||||||
use App\Models\Expense;
|
use App\Models\Expense;
|
||||||
use App\Ninja\Repositories\ExpenseRepository;
|
use App\Ninja\Repositories\ExpenseRepository;
|
||||||
use App\Services\ExpenseService;
|
use App\Services\ExpenseService;
|
||||||
@ -45,7 +44,7 @@ class ExpenseApiController extends BaseAPIController
|
|||||||
$expenses = Expense::scope()
|
$expenses = Expense::scope()
|
||||||
->withTrashed()
|
->withTrashed()
|
||||||
->with('client', 'invoice', 'vendor', 'expense_category')
|
->with('client', 'invoice', 'vendor', 'expense_category')
|
||||||
->orderBy('created_at','desc');
|
->orderBy('created_at', 'desc');
|
||||||
|
|
||||||
return $this->listResponse($expenses);
|
return $this->listResponse($expenses);
|
||||||
}
|
}
|
||||||
@ -145,8 +144,4 @@ class ExpenseApiController extends BaseAPIController
|
|||||||
|
|
||||||
return $this->itemResponse($expense);
|
return $this->itemResponse($expense);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,5 +100,4 @@ class ExpenseCategoryController extends BaseController
|
|||||||
|
|
||||||
return redirect()->to('/expense_categories');
|
return redirect()->to('/expense_categories');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,6 @@ class ExpenseController extends BaseController
|
|||||||
foreach ($invoices as $invoice) {
|
foreach ($invoices as $invoice) {
|
||||||
$actions[] = ['url' => 'javascript:submitAction("add_to_invoice", '.$invoice->public_id.')', 'label' => trans('texts.add_to_invoice', ['invoice' => $invoice->invoice_number])];
|
$actions[] = ['url' => 'javascript:submitAction("add_to_invoice", '.$invoice->public_id.')', 'label' => trans('texts.add_to_invoice', ['invoice' => $invoice->invoice_number])];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$actions[] = \DropdownButton::DIVIDER;
|
$actions[] = \DropdownButton::DIVIDER;
|
||||||
@ -181,8 +180,7 @@ class ExpenseController extends BaseController
|
|||||||
$action = Input::get('action');
|
$action = Input::get('action');
|
||||||
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
|
$ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids');
|
||||||
|
|
||||||
switch($action)
|
switch ($action) {
|
||||||
{
|
|
||||||
case 'invoice':
|
case 'invoice':
|
||||||
case 'add_to_invoice':
|
case 'add_to_invoice':
|
||||||
$expenses = Expense::scope($ids)->with('client')->get();
|
$expenses = Expense::scope($ids)->with('client')->get();
|
||||||
@ -190,8 +188,7 @@ class ExpenseController extends BaseController
|
|||||||
$currencyId = null;
|
$currencyId = null;
|
||||||
|
|
||||||
// Validate that either all expenses do not have a client or if there is a client, it is the same client
|
// Validate that either all expenses do not have a client or if there is a client, it is the same client
|
||||||
foreach ($expenses as $expense)
|
foreach ($expenses as $expense) {
|
||||||
{
|
|
||||||
if ($expense->client) {
|
if ($expense->client) {
|
||||||
if (!$clientPublicId) {
|
if (!$clientPublicId) {
|
||||||
$clientPublicId = $expense->client->public_id;
|
$clientPublicId = $expense->client->public_id;
|
||||||
@ -223,7 +220,6 @@ class ExpenseController extends BaseController
|
|||||||
return Redirect::to("invoices/{$invoiceId}/edit")
|
return Redirect::to("invoices/{$invoiceId}/edit")
|
||||||
->with('expenseCurrencyId', $currencyId)
|
->with('expenseCurrencyId', $currencyId)
|
||||||
->with('expenses', $ids);
|
->with('expenses', $ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class ExportController extends BaseController
|
|||||||
} else {
|
} else {
|
||||||
$fields = $request->all();
|
$fields = $request->all();
|
||||||
$fields = array_filter(array_map(function ($key) {
|
$fields = array_filter(array_map(function ($key) {
|
||||||
if ( ! in_array($key, ['format', 'include', '_token'])) {
|
if (! in_array($key, ['format', 'include', '_token'])) {
|
||||||
return $key;
|
return $key;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
@ -74,11 +74,11 @@ class ExportController extends BaseController
|
|||||||
|
|
||||||
// eager load data, include archived but exclude deleted
|
// eager load data, include archived but exclude deleted
|
||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
$account->load(['clients' => function($query) {
|
$account->load(['clients' => function ($query) {
|
||||||
$query->withArchived()
|
$query->withArchived()
|
||||||
->with(['contacts', 'invoices' => function($query) {
|
->with(['contacts', 'invoices' => function ($query) {
|
||||||
$query->withArchived()
|
$query->withArchived()
|
||||||
->with(['invoice_items', 'payments' => function($query) {
|
->with(['invoice_items', 'payments' => function ($query) {
|
||||||
$query->withArchived();
|
$query->withArchived();
|
||||||
}]);
|
}]);
|
||||||
}]);
|
}]);
|
||||||
@ -102,8 +102,8 @@ class ExportController extends BaseController
|
|||||||
{
|
{
|
||||||
$data = $this->getData($request);
|
$data = $this->getData($request);
|
||||||
|
|
||||||
return Excel::create($fileName, function($excel) use ($data) {
|
return Excel::create($fileName, function ($excel) use ($data) {
|
||||||
$excel->sheet('', function($sheet) use ($data) {
|
$excel->sheet('', function ($sheet) use ($data) {
|
||||||
$sheet->loadView('export', $data);
|
$sheet->loadView('export', $data);
|
||||||
});
|
});
|
||||||
})->download('csv');
|
})->download('csv');
|
||||||
@ -120,8 +120,7 @@ class ExportController extends BaseController
|
|||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$data = $this->getData($request);
|
$data = $this->getData($request);
|
||||||
|
|
||||||
return Excel::create($fileName, function($excel) use ($user, $data) {
|
return Excel::create($fileName, function ($excel) use ($user, $data) {
|
||||||
|
|
||||||
$excel->setTitle($data['title'])
|
$excel->setTitle($data['title'])
|
||||||
->setCreator($user->getDisplayName())
|
->setCreator($user->getDisplayName())
|
||||||
->setLastModifiedBy($user->getDisplayName())
|
->setLastModifiedBy($user->getDisplayName())
|
||||||
@ -140,7 +139,7 @@ class ExportController extends BaseController
|
|||||||
$key = 'recurring_invoices';
|
$key = 'recurring_invoices';
|
||||||
}
|
}
|
||||||
$label = trans("texts.{$key}");
|
$label = trans("texts.{$key}");
|
||||||
$excel->sheet($label, function($sheet) use ($key, $data) {
|
$excel->sheet($label, function ($sheet) use ($key, $data) {
|
||||||
if ($key === 'quotes') {
|
if ($key === 'quotes') {
|
||||||
$key = 'invoices';
|
$key = 'invoices';
|
||||||
$data['entityType'] = ENTITY_QUOTE;
|
$data['entityType'] = ENTITY_QUOTE;
|
||||||
|
@ -136,7 +136,7 @@ class HomeController extends BaseController
|
|||||||
{
|
{
|
||||||
Mail::raw(request()->message, function ($message) {
|
Mail::raw(request()->message, function ($message) {
|
||||||
$subject = 'Customer Message';
|
$subject = 'Customer Message';
|
||||||
if ( ! Utils::isNinja()) {
|
if (! Utils::isNinja()) {
|
||||||
$subject .= ': v' . NINJA_VERSION;
|
$subject .= ': v' . NINJA_VERSION;
|
||||||
}
|
}
|
||||||
$message->to(CONTACT_EMAIL)
|
$message->to(CONTACT_EMAIL)
|
||||||
|
@ -31,7 +31,7 @@ class ImportController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! count($files)) {
|
if (! count($files)) {
|
||||||
Session::flash('error', trans('texts.select_file'));
|
Session::flash('error', trans('texts.select_file'));
|
||||||
return Redirect::to('/settings/' . ACCOUNT_IMPORT_EXPORT);
|
return Redirect::to('/settings/' . ACCOUNT_IMPORT_EXPORT);
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
|
|
||||||
if (isset($data['email'])) {
|
if (isset($data['email'])) {
|
||||||
$email = $data['email'];
|
$email = $data['email'];
|
||||||
$client = Client::scope()->whereHas('contacts', function($query) use ($email) {
|
$client = Client::scope()->whereHas('contacts', function ($query) use ($email) {
|
||||||
$query->where('email', '=', $email);
|
$query->where('email', '=', $email);
|
||||||
})->first();
|
})->first();
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
|
|
||||||
$client = $this->clientRepo->save($clientData);
|
$client = $this->clientRepo->save($clientData);
|
||||||
}
|
}
|
||||||
} else if (isset($data['client_id'])) {
|
} elseif (isset($data['client_id'])) {
|
||||||
$client = Client::scope($data['client_id'])->firstOrFail();
|
$client = Client::scope($data['client_id'])->firstOrFail();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
if ($invoice->isInvoice()) {
|
if ($invoice->isInvoice()) {
|
||||||
if ($isAutoBill) {
|
if ($isAutoBill) {
|
||||||
$payment = $this->paymentService->autoBillInvoice($invoice);
|
$payment = $this->paymentService->autoBillInvoice($invoice);
|
||||||
} else if ($isPaid) {
|
} elseif ($isPaid) {
|
||||||
$payment = $this->paymentRepo->save([
|
$payment = $this->paymentRepo->save([
|
||||||
'invoice_id' => $invoice->id,
|
'invoice_id' => $invoice->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
@ -187,7 +187,7 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
if ($payment) {
|
if ($payment) {
|
||||||
app('App\Ninja\Mailers\ContactMailer')->sendPaymentConfirmation($payment);
|
app('App\Ninja\Mailers\ContactMailer')->sendPaymentConfirmation($payment);
|
||||||
//$this->dispatch(new SendPaymentEmail($payment));
|
//$this->dispatch(new SendPaymentEmail($payment));
|
||||||
} elseif ( ! $invoice->is_recurring) {
|
} elseif (! $invoice->is_recurring) {
|
||||||
app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice);
|
app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice);
|
||||||
//$this->dispatch(new SendInvoiceEmail($invoice));
|
//$this->dispatch(new SendInvoiceEmail($invoice));
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
$lastSent = ($invoice->is_recurring && $invoice->last_sent_date) ? $invoice->recurring_invoices->last() : null;
|
$lastSent = ($invoice->is_recurring && $invoice->last_sent_date) ? $invoice->recurring_invoices->last() : null;
|
||||||
|
|
||||||
if(!Auth::user()->hasPermission('view_all')){
|
if (!Auth::user()->hasPermission('view_all')) {
|
||||||
$clients = $clients->where('clients.user_id', '=', Auth::user()->id);
|
$clients = $clients->where('clients.user_id', '=', Auth::user()->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ class InvoiceController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the invitation data on the client's contacts
|
// Set the invitation data on the client's contacts
|
||||||
if ( ! $clone) {
|
if (! $clone) {
|
||||||
$clients = $data['clients'];
|
$clients = $data['clients'];
|
||||||
foreach ($clients as $client) {
|
foreach ($clients as $client) {
|
||||||
if ($client->id != $invoice->client->id) {
|
if ($client->id != $invoice->client->id) {
|
||||||
@ -247,9 +247,12 @@ class InvoiceController extends BaseController
|
|||||||
];
|
];
|
||||||
|
|
||||||
$ends = ['th','st','nd','rd','th','th','th','th','th','th'];
|
$ends = ['th','st','nd','rd','th','th','th','th','th','th'];
|
||||||
for($i = 1; $i < 31; $i++){
|
for ($i = 1; $i < 31; $i++) {
|
||||||
if ($i >= 11 && $i <= 13) $ordinal = $i. 'th';
|
if ($i >= 11 && $i <= 13) {
|
||||||
else $ordinal = $i . $ends[$i % 10];
|
$ordinal = $i. 'th';
|
||||||
|
} else {
|
||||||
|
$ordinal = $i . $ends[$i % 10];
|
||||||
|
}
|
||||||
|
|
||||||
$dayStr = str_pad($i, 2, '0', STR_PAD_LEFT);
|
$dayStr = str_pad($i, 2, '0', STR_PAD_LEFT);
|
||||||
$str = trans('texts.day_of_month', ['ordinal'=>$ordinal]);
|
$str = trans('texts.day_of_month', ['ordinal'=>$ordinal]);
|
||||||
@ -268,8 +271,8 @@ class InvoiceController extends BaseController
|
|||||||
trans('texts.friday'),
|
trans('texts.friday'),
|
||||||
trans('texts.saturday'),
|
trans('texts.saturday'),
|
||||||
];
|
];
|
||||||
foreach(['1st','2nd','3rd','4th'] as $i=>$ordinal){
|
foreach (['1st','2nd','3rd','4th'] as $i=>$ordinal) {
|
||||||
foreach($daysOfWeek as $j=>$dayOfWeek){
|
foreach ($daysOfWeek as $j=>$dayOfWeek) {
|
||||||
$str = trans('texts.day_of_week_after', ['ordinal' => $ordinal, 'day' => $dayOfWeek]);
|
$str = trans('texts.day_of_week_after', ['ordinal' => $ordinal, 'day' => $dayOfWeek]);
|
||||||
|
|
||||||
$day = $i * 7 + $j + 1;
|
$day = $i * 7 + $j + 1;
|
||||||
@ -327,7 +330,6 @@ class InvoiceController extends BaseController
|
|||||||
'expenseCurrencyId' => Session::get('expenseCurrencyId') ?: null,
|
'expenseCurrencyId' => Session::get('expenseCurrencyId') ?: null,
|
||||||
'expenses' => Session::get('expenses') ? Expense::scope(Session::get('expenses'))->with('documents', 'expense_category')->get() : [],
|
'expenses' => Session::get('expenses') ? Expense::scope(Session::get('expenses'))->with('documents', 'expense_category')->get() : [],
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -467,7 +469,8 @@ class InvoiceController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function bulk($entityType = ENTITY_INVOICE)
|
public function bulk($entityType = ENTITY_INVOICE)
|
||||||
{
|
{
|
||||||
$action = Input::get('bulk_action') ?: Input::get('action');;
|
$action = Input::get('bulk_action') ?: Input::get('action');
|
||||||
|
;
|
||||||
$ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
|
$ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
|
||||||
$count = $this->invoiceService->bulk($ids, $action);
|
$count = $this->invoiceService->bulk($ids, $action);
|
||||||
|
|
||||||
@ -554,7 +557,7 @@ class InvoiceController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show the current version as the last in the history
|
// Show the current version as the last in the history
|
||||||
if ( ! $paymentId) {
|
if (! $paymentId) {
|
||||||
$versionsSelect[$lastId] = Utils::timestampToDateTimeString(strtotime($invoice->created_at)) . ' - ' . $invoice->user->getDisplayName();
|
$versionsSelect[$lastId] = Utils::timestampToDateTimeString(strtotime($invoice->created_at)) . ' - ' . $invoice->user->getDisplayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,5 +589,4 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
return $count ? RESULT_FAILURE : RESULT_SUCCESS;
|
return $count ? RESULT_FAILURE : RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ class NinjaController extends BaseController
|
|||||||
|
|
||||||
if (Input::has('product_id')) {
|
if (Input::has('product_id')) {
|
||||||
Session::set('product_id', Input::get('product_id'));
|
Session::set('product_id', Input::get('product_id'));
|
||||||
} else if (!Session::has('product_id')) {
|
} elseif (!Session::has('product_id')) {
|
||||||
Session::set('product_id', PRODUCT_ONE_CLICK_INSTALL);
|
Session::set('product_id', PRODUCT_ONE_CLICK_INSTALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +284,6 @@ class NinjaController extends BaseController
|
|||||||
$company->plan = null;
|
$company->plan = null;
|
||||||
$company->save();
|
$company->save();
|
||||||
|
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,14 +64,14 @@ class OnlinePaymentController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function showPayment($invitationKey, $gatewayTypeAlias = false, $sourceId = false)
|
public function showPayment($invitationKey, $gatewayTypeAlias = false, $sourceId = false)
|
||||||
{
|
{
|
||||||
if ( ! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
if (! $invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) {
|
||||||
return response()->view('error', [
|
return response()->view('error', [
|
||||||
'error' => trans('texts.invoice_not_found'),
|
'error' => trans('texts.invoice_not_found'),
|
||||||
'hideHeader' => true,
|
'hideHeader' => true,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $invitation->invoice->canBePaid()) {
|
if (! $invitation->invoice->canBePaid()) {
|
||||||
return redirect()->to('view/' . $invitation->invitation_key);
|
return redirect()->to('view/' . $invitation->invitation_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class OnlinePaymentController extends BaseController
|
|||||||
|
|
||||||
$account->loadLocalizationSettings($invitation->invoice->client);
|
$account->loadLocalizationSettings($invitation->invoice->client);
|
||||||
|
|
||||||
if ( ! $gatewayTypeAlias) {
|
if (! $gatewayTypeAlias) {
|
||||||
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
||||||
} elseif ($gatewayTypeAlias != GATEWAY_TYPE_TOKEN) {
|
} elseif ($gatewayTypeAlias != GATEWAY_TYPE_TOKEN) {
|
||||||
$gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias);
|
$gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias);
|
||||||
@ -111,7 +111,7 @@ class OnlinePaymentController extends BaseController
|
|||||||
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
||||||
$paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId);
|
$paymentDriver = $invitation->account->paymentDriver($invitation, $gatewayTypeId);
|
||||||
|
|
||||||
if ( ! $invitation->invoice->canBePaid()) {
|
if (! $invitation->invoice->canBePaid()) {
|
||||||
return redirect()->to('view/' . $invitation->invitation_key);
|
return redirect()->to('view/' . $invitation->invitation_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class OnlinePaymentController extends BaseController
|
|||||||
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')
|
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')
|
||||||
->where('invitation_key', '=', $invitationKey)->firstOrFail();
|
->where('invitation_key', '=', $invitationKey)->firstOrFail();
|
||||||
|
|
||||||
if ( ! $gatewayTypeAlias) {
|
if (! $gatewayTypeAlias) {
|
||||||
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
$gatewayTypeId = Session::get($invitation->id . 'gateway_type');
|
||||||
} elseif ($gatewayTypeAlias != GATEWAY_TYPE_TOKEN) {
|
} elseif ($gatewayTypeAlias != GATEWAY_TYPE_TOKEN) {
|
||||||
$gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias);
|
$gatewayTypeId = GatewayType::getIdFromAlias($gatewayTypeAlias);
|
||||||
@ -210,7 +210,8 @@ class OnlinePaymentController extends BaseController
|
|||||||
* @param $routingNumber
|
* @param $routingNumber
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function getBankInfo($routingNumber) {
|
public function getBankInfo($routingNumber)
|
||||||
|
{
|
||||||
if (strlen($routingNumber) != 9 || !preg_match('/\d{9}/', $routingNumber)) {
|
if (strlen($routingNumber) != 9 || !preg_match('/\d{9}/', $routingNumber)) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'message' => 'Invalid routing number',
|
'message' => 'Invalid routing number',
|
||||||
@ -278,14 +279,14 @@ class OnlinePaymentController extends BaseController
|
|||||||
$redirectUrl = Input::get('redirect_url');
|
$redirectUrl = Input::get('redirect_url');
|
||||||
$failureUrl = URL::previous();
|
$failureUrl = URL::previous();
|
||||||
|
|
||||||
if ( ! $account || ! $account->enable_buy_now_buttons || ! $account->hasFeature(FEATURE_BUY_NOW_BUTTONS)) {
|
if (! $account || ! $account->enable_buy_now_buttons || ! $account->hasFeature(FEATURE_BUY_NOW_BUTTONS)) {
|
||||||
return redirect()->to("{$failureUrl}/?error=invalid account");
|
return redirect()->to("{$failureUrl}/?error=invalid account");
|
||||||
}
|
}
|
||||||
|
|
||||||
Auth::onceUsingId($account->users[0]->id);
|
Auth::onceUsingId($account->users[0]->id);
|
||||||
$product = Product::scope(Input::get('product_id'))->first();
|
$product = Product::scope(Input::get('product_id'))->first();
|
||||||
|
|
||||||
if ( ! $product) {
|
if (! $product) {
|
||||||
return redirect()->to("{$failureUrl}/?error=invalid product");
|
return redirect()->to("{$failureUrl}/?error=invalid product");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +297,7 @@ class OnlinePaymentController extends BaseController
|
|||||||
$query->where('contact_key', $contactKey);
|
$query->where('contact_key', $contactKey);
|
||||||
})->first();
|
})->first();
|
||||||
}
|
}
|
||||||
if ( ! $client) {
|
if (! $client) {
|
||||||
$rules = [
|
$rules = [
|
||||||
'first_name' => 'string|max:100',
|
'first_name' => 'string|max:100',
|
||||||
'last_name' => 'string|max:100',
|
'last_name' => 'string|max:100',
|
||||||
|
@ -150,5 +150,4 @@ class PaymentApiController extends BaseAPIController
|
|||||||
|
|
||||||
return $this->itemResponse($payment);
|
return $this->itemResponse($payment);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,7 @@ class PaymentController extends BaseController
|
|||||||
PaymentRepository $paymentRepo,
|
PaymentRepository $paymentRepo,
|
||||||
ContactMailer $contactMailer,
|
ContactMailer $contactMailer,
|
||||||
PaymentService $paymentService
|
PaymentService $paymentService
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
$this->paymentRepo = $paymentRepo;
|
$this->paymentRepo = $paymentRepo;
|
||||||
$this->contactMailer = $contactMailer;
|
$this->contactMailer = $contactMailer;
|
||||||
$this->paymentService = $paymentService;
|
$this->paymentService = $paymentService;
|
||||||
@ -130,7 +129,7 @@ class PaymentController extends BaseController
|
|||||||
}
|
}
|
||||||
$actions[] = ['url' => url("/invoices/{$payment->invoice->public_id}/edit"), 'label' => trans('texts.edit_invoice')];
|
$actions[] = ['url' => url("/invoices/{$payment->invoice->public_id}/edit"), 'label' => trans('texts.edit_invoice')];
|
||||||
$actions[] = DropdownButton::DIVIDER;
|
$actions[] = DropdownButton::DIVIDER;
|
||||||
if ( ! $payment->trashed()) {
|
if (! $payment->trashed()) {
|
||||||
$actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans('texts.archive_payment')];
|
$actions[] = ['url' => 'javascript:submitAction("archive")', 'label' => trans('texts.archive_payment')];
|
||||||
$actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans('texts.delete_payment')];
|
$actions[] = ['url' => 'javascript:onDeleteClick()', 'label' => trans('texts.delete_payment')];
|
||||||
} else {
|
} else {
|
||||||
|
@ -126,5 +126,4 @@ class PaymentTermController extends BaseController
|
|||||||
|
|
||||||
return Redirect::to('settings/' . ACCOUNT_PAYMENT_TERMS);
|
return Redirect::to('settings/' . ACCOUNT_PAYMENT_TERMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,5 +109,4 @@ class ProjectController extends BaseController
|
|||||||
|
|
||||||
return redirect()->to('/projects');
|
return redirect()->to('/projects');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,5 +43,4 @@ class QuoteApiController extends BaseAPIController
|
|||||||
|
|
||||||
return $this->listResponse($invoices);
|
return $this->listResponse($invoices);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,8 @@ class QuoteController extends BaseController
|
|||||||
|
|
||||||
public function bulk()
|
public function bulk()
|
||||||
{
|
{
|
||||||
$action = Input::get('bulk_action') ?: Input::get('action');;
|
$action = Input::get('bulk_action') ?: Input::get('action');
|
||||||
|
;
|
||||||
$ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
|
$ids = Input::get('bulk_public_id') ?: (Input::get('public_id') ?: Input::get('ids'));
|
||||||
|
|
||||||
if ($action == 'convert') {
|
if ($action == 'convert') {
|
||||||
|
@ -38,5 +38,4 @@ class RecurringInvoiceController extends BaseController
|
|||||||
|
|
||||||
return response()->view('list_wrapper', $data);
|
return response()->view('list_wrapper', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,5 @@ class TaskApiController extends BaseAPIController
|
|||||||
$task = $this->taskRepo->save($task->public_id, \Illuminate\Support\Facades\Input::all());
|
$task = $this->taskRepo->save($task->public_id, \Illuminate\Support\Facades\Input::all());
|
||||||
|
|
||||||
return $this->itemResponse($task);
|
return $this->itemResponse($task);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,7 @@ class TaskController extends BaseController
|
|||||||
TaskRepository $taskRepo,
|
TaskRepository $taskRepo,
|
||||||
InvoiceRepository $invoiceRepo,
|
InvoiceRepository $invoiceRepo,
|
||||||
TaskService $taskService
|
TaskService $taskService
|
||||||
)
|
) {
|
||||||
{
|
|
||||||
// parent::__construct();
|
// parent::__construct();
|
||||||
|
|
||||||
$this->taskRepo = $taskRepo;
|
$this->taskRepo = $taskRepo;
|
||||||
@ -227,7 +226,7 @@ class TaskController extends BaseController
|
|||||||
|
|
||||||
$task = $this->taskRepo->save($publicId, Input::all());
|
$task = $this->taskRepo->save($publicId, Input::all());
|
||||||
|
|
||||||
if($publicId) {
|
if ($publicId) {
|
||||||
Session::flash('message', trans('texts.updated_task'));
|
Session::flash('message', trans('texts.updated_task'));
|
||||||
} else {
|
} else {
|
||||||
Session::flash('message', trans('texts.created_task'));
|
Session::flash('message', trans('texts.created_task'));
|
||||||
@ -252,7 +251,7 @@ class TaskController extends BaseController
|
|||||||
$this->taskRepo->save($ids, ['action' => $action]);
|
$this->taskRepo->save($ids, ['action' => $action]);
|
||||||
Session::flash('message', trans('texts.stopped_task'));
|
Session::flash('message', trans('texts.stopped_task'));
|
||||||
return Redirect::to('tasks');
|
return Redirect::to('tasks');
|
||||||
} else if ($action == 'invoice' || $action == 'add_to_invoice') {
|
} elseif ($action == 'invoice' || $action == 'add_to_invoice') {
|
||||||
$tasks = Task::scope($ids)->with('client')->orderBy('project_id', 'id')->get();
|
$tasks = Task::scope($ids)->with('client')->orderBy('project_id', 'id')->get();
|
||||||
$clientPublicId = false;
|
$clientPublicId = false;
|
||||||
$data = [];
|
$data = [];
|
||||||
@ -262,7 +261,7 @@ class TaskController extends BaseController
|
|||||||
if ($task->client) {
|
if ($task->client) {
|
||||||
if (!$clientPublicId) {
|
if (!$clientPublicId) {
|
||||||
$clientPublicId = $task->client->public_id;
|
$clientPublicId = $task->client->public_id;
|
||||||
} else if ($clientPublicId != $task->client->public_id) {
|
} elseif ($clientPublicId != $task->client->public_id) {
|
||||||
Session::flash('error', trans('texts.task_error_multiple_clients'));
|
Session::flash('error', trans('texts.task_error_multiple_clients'));
|
||||||
return Redirect::to('tasks');
|
return Redirect::to('tasks');
|
||||||
}
|
}
|
||||||
@ -271,7 +270,7 @@ class TaskController extends BaseController
|
|||||||
if ($task->is_running) {
|
if ($task->is_running) {
|
||||||
Session::flash('error', trans('texts.task_error_running'));
|
Session::flash('error', trans('texts.task_error_running'));
|
||||||
return Redirect::to('tasks');
|
return Redirect::to('tasks');
|
||||||
} else if ($task->invoice_id) {
|
} elseif ($task->invoice_id) {
|
||||||
Session::flash('error', trans('texts.task_error_invoiced'));
|
Session::flash('error', trans('texts.task_error_invoiced'));
|
||||||
return Redirect::to('tasks');
|
return Redirect::to('tasks');
|
||||||
}
|
}
|
||||||
|
@ -157,5 +157,4 @@ class TokenController extends BaseController
|
|||||||
|
|
||||||
return Redirect::to('settings/' . ACCOUNT_API_TOKENS);
|
return Redirect::to('settings/' . ACCOUNT_API_TOKENS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,4 +64,4 @@ class UserApiController extends BaseAPIController
|
|||||||
|
|
||||||
return $this->response($data);
|
return $this->response($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,12 +95,12 @@ class UserController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
if ( ! Auth::user()->registered) {
|
if (! Auth::user()->registered) {
|
||||||
Session::flash('error', trans('texts.register_to_add_user'));
|
Session::flash('error', trans('texts.register_to_add_user'));
|
||||||
return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT);
|
return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! Auth::user()->confirmed) {
|
if (! Auth::user()->confirmed) {
|
||||||
Session::flash('error', trans('texts.confirmation_required'));
|
Session::flash('error', trans('texts.confirmation_required'));
|
||||||
return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT);
|
return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT);
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ class UserController extends BaseController
|
|||||||
if ($action === 'archive') {
|
if ($action === 'archive') {
|
||||||
$user->delete();
|
$user->delete();
|
||||||
} else {
|
} else {
|
||||||
if ( ! Auth::user()->caddAddUsers()) {
|
if (! Auth::user()->caddAddUsers()) {
|
||||||
return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT)
|
return Redirect::to('settings/' . ACCOUNT_USER_MANAGEMENT)
|
||||||
->with('error', trans('texts.max_users_reached'));
|
->with('error', trans('texts.max_users_reached'));
|
||||||
}
|
}
|
||||||
@ -326,7 +326,7 @@ class UserController extends BaseController
|
|||||||
{
|
{
|
||||||
$user = $this->accountRepo->findUser(Auth::user(), $accountKey);
|
$user = $this->accountRepo->findUser(Auth::user(), $accountKey);
|
||||||
|
|
||||||
if ( ! $user) {
|
if (! $user) {
|
||||||
return redirect()->to('/');
|
return redirect()->to('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
// vendor
|
// vendor
|
||||||
use App\Http\Requests\UpdateVendorRequest;
|
use App\Http\Requests\UpdateVendorRequest;
|
||||||
use App\Http\Requests\VendorRequest;
|
use App\Http\Requests\VendorRequest;
|
||||||
|
@ -2,37 +2,37 @@
|
|||||||
|
|
||||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||||
|
|
||||||
class Kernel extends HttpKernel {
|
class Kernel extends HttpKernel
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The application's global HTTP middleware stack.
|
* The application's global HTTP middleware stack.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $middleware = [
|
protected $middleware = [
|
||||||
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
|
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
|
||||||
'Illuminate\Cookie\Middleware\EncryptCookies',
|
'Illuminate\Cookie\Middleware\EncryptCookies',
|
||||||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
||||||
'Illuminate\Session\Middleware\StartSession',
|
'Illuminate\Session\Middleware\StartSession',
|
||||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||||
'App\Http\Middleware\VerifyCsrfToken',
|
'App\Http\Middleware\VerifyCsrfToken',
|
||||||
'App\Http\Middleware\DuplicateSubmissionCheck',
|
'App\Http\Middleware\DuplicateSubmissionCheck',
|
||||||
'App\Http\Middleware\QueryLogging',
|
'App\Http\Middleware\QueryLogging',
|
||||||
'App\Http\Middleware\StartupCheck',
|
'App\Http\Middleware\StartupCheck',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The application's route middleware.
|
* The application's route middleware.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $routeMiddleware = [
|
protected $routeMiddleware = [
|
||||||
'auth' => 'App\Http\Middleware\Authenticate',
|
'auth' => 'App\Http\Middleware\Authenticate',
|
||||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||||
'permissions.required' => 'App\Http\Middleware\PermissionsRequired',
|
'permissions.required' => 'App\Http\Middleware\PermissionsRequired',
|
||||||
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
||||||
'api' => 'App\Http\Middleware\ApiCheck',
|
'api' => 'App\Http\Middleware\ApiCheck',
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,8 @@ use App\Models\AccountToken;
|
|||||||
/**
|
/**
|
||||||
* Class ApiCheck
|
* Class ApiCheck
|
||||||
*/
|
*/
|
||||||
class ApiCheck {
|
class ApiCheck
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
@ -38,7 +39,7 @@ class ApiCheck {
|
|||||||
|
|
||||||
if ($loggingIn) {
|
if ($loggingIn) {
|
||||||
// check API secret
|
// check API secret
|
||||||
if ( ! $hasApiSecret) {
|
if (! $hasApiSecret) {
|
||||||
sleep(ERROR_DELAY);
|
sleep(ERROR_DELAY);
|
||||||
$error['error'] = ['message'=>'Invalid value for API_SECRET'];
|
$error['error'] = ['message'=>'Invalid value for API_SECRET'];
|
||||||
return Response::json($error, 403, $headers);
|
return Response::json($error, 403, $headers);
|
||||||
@ -81,7 +82,7 @@ class ApiCheck {
|
|||||||
$new_hour_throttle = $hour_throttle - $last_api_diff;
|
$new_hour_throttle = $hour_throttle - $last_api_diff;
|
||||||
$new_hour_throttle = $new_hour_throttle < 0 ? 0 : $new_hour_throttle;
|
$new_hour_throttle = $new_hour_throttle < 0 ? 0 : $new_hour_throttle;
|
||||||
$new_hour_throttle += $hour / $hour_limit;
|
$new_hour_throttle += $hour / $hour_limit;
|
||||||
$hour_hits_remaining = floor(( $hour - $new_hour_throttle ) * $hour_limit / $hour);
|
$hour_hits_remaining = floor(($hour - $new_hour_throttle) * $hour_limit / $hour);
|
||||||
$hour_hits_remaining = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0;
|
$hour_hits_remaining = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,5 +98,4 @@ class ApiCheck {
|
|||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ class PermissionsRequired
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
static protected $actions = [];
|
protected static $actions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle an incoming request.
|
* Handle an incoming request.
|
||||||
|
@ -47,5 +47,4 @@ class RedirectIfAuthenticated
|
|||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -122,9 +122,9 @@ class StartupCheck
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user is claiming a license (ie, additional invoices, white label, etc.)
|
// Check if the user is claiming a license (ie, additional invoices, white label, etc.)
|
||||||
if ( ! Utils::isNinjaProd() && isset($_SERVER['REQUEST_URI'])) {
|
if (! Utils::isNinjaProd() && isset($_SERVER['REQUEST_URI'])) {
|
||||||
$claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
|
$claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
|
||||||
if ( ! $claimingLicense && Input::has('license_key') && Input::has('product_id')) {
|
if (! $claimingLicense && Input::has('license_key') && Input::has('product_id')) {
|
||||||
$licenseKey = Input::get('license_key');
|
$licenseKey = Input::get('license_key');
|
||||||
$productId = Input::get('product_id');
|
$productId = Input::get('product_id');
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ class StartupCheck
|
|||||||
foreach ($cachedTables as $name => $class) {
|
foreach ($cachedTables as $name => $class) {
|
||||||
if (Input::has('clear_cache') || !Cache::has($name)) {
|
if (Input::has('clear_cache') || !Cache::has($name)) {
|
||||||
// check that the table exists in case the migration is pending
|
// check that the table exists in case the migration is pending
|
||||||
if ( ! Schema::hasTable((new $class)->getTable())) {
|
if (! Schema::hasTable((new $class)->getTable())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($name == 'paymentTerms') {
|
if ($name == 'paymentTerms') {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
class ClientRequest extends EntityRequest {
|
class ClientRequest extends EntityRequest
|
||||||
|
{
|
||||||
protected $entityType = ENTITY_CLIENT;
|
protected $entityType = ENTITY_CLIENT;
|
||||||
|
|
||||||
public function entity()
|
public function entity()
|
||||||
@ -15,4 +15,4 @@ class ClientRequest extends EntityRequest {
|
|||||||
|
|
||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CreateBankAccountRequest extends Request
|
class CreateBankAccountRequest extends Request
|
||||||
{
|
{
|
||||||
// Expenses
|
// Expenses
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
*
|
*
|
||||||
|
@ -17,7 +17,7 @@ class CreateDocumentRequest extends DocumentRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
if ( ! $this->user()->hasFeature(FEATURE_DOCUMENTS)) {
|
if (! $this->user()->hasFeature(FEATURE_DOCUMENTS)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,5 +43,4 @@ class CreateDocumentRequest extends DocumentRequest
|
|||||||
//'file' => 'mimes:jpg'
|
//'file' => 'mimes:jpg'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
class CreateExpenseRequest extends ExpenseRequest
|
class CreateExpenseRequest extends ExpenseRequest
|
||||||
{
|
{
|
||||||
// Expenses
|
// Expenses
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
*
|
*
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CreatePaymentAPIRequest extends PaymentRequest
|
class CreatePaymentAPIRequest extends PaymentRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -26,7 +24,7 @@ class CreatePaymentAPIRequest extends PaymentRequest
|
|||||||
*/
|
*/
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
if ( ! $this->invoice_id || ! $this->amount) {
|
if (! $this->invoice_id || ! $this->amount) {
|
||||||
return [
|
return [
|
||||||
'invoice_id' => 'required|numeric|min:1',
|
'invoice_id' => 'required|numeric|min:1',
|
||||||
'amount' => 'required|numeric|min:0.01',
|
'amount' => 'required|numeric|min:0.01',
|
||||||
@ -52,7 +50,4 @@ class CreatePaymentAPIRequest extends PaymentRequest
|
|||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ class CreatePaymentRequest extends PaymentRequest
|
|||||||
'payment_date' => 'required',
|
'payment_date' => 'required',
|
||||||
];
|
];
|
||||||
|
|
||||||
if ( ! empty($input['payment_type_id']) && $input['payment_type_id'] == PAYMENT_TYPE_CREDIT) {
|
if (! empty($input['payment_type_id']) && $input['payment_type_id'] == PAYMENT_TYPE_CREDIT) {
|
||||||
$rules['payment_type_id'] = 'has_credit:'.$input['client'].','.$input['amount'];
|
$rules['payment_type_id'] = 'has_credit:'.$input['client'].','.$input['amount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CreateTaxRateRequest extends TaxRateRequest
|
class CreateTaxRateRequest extends TaxRateRequest
|
||||||
{
|
{
|
||||||
// Expenses
|
// Expenses
|
||||||
/**
|
/**
|
||||||
* Determine if the user is authorized to make this request.
|
* Determine if the user is authorized to make this request.
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
class CreditRequest extends EntityRequest {
|
class CreditRequest extends EntityRequest
|
||||||
|
{
|
||||||
protected $entityType = ENTITY_CREDIT;
|
protected $entityType = ENTITY_CREDIT;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
class DocumentRequest extends EntityRequest {
|
class DocumentRequest extends EntityRequest
|
||||||
|
{
|
||||||
protected $entityType = ENTITY_DOCUMENT;
|
protected $entityType = ENTITY_DOCUMENT;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -5,8 +5,8 @@ use Utils;
|
|||||||
use App\Libraries\HistoryUtils;
|
use App\Libraries\HistoryUtils;
|
||||||
use App\Models\EntityModel;
|
use App\Models\EntityModel;
|
||||||
|
|
||||||
class EntityRequest extends Request {
|
class EntityRequest extends Request
|
||||||
|
{
|
||||||
protected $entityType;
|
protected $entityType;
|
||||||
private $entity;
|
private $entity;
|
||||||
|
|
||||||
@ -19,19 +19,19 @@ class EntityRequest extends Request {
|
|||||||
// The entity id can appear as invoices, invoice_id, public_id or id
|
// The entity id can appear as invoices, invoice_id, public_id or id
|
||||||
$publicId = false;
|
$publicId = false;
|
||||||
$field = $this->entityType . '_id';
|
$field = $this->entityType . '_id';
|
||||||
if ( ! empty($this->$field)) {
|
if (! empty($this->$field)) {
|
||||||
$publicId = $this->$field;
|
$publicId = $this->$field;
|
||||||
}
|
}
|
||||||
if ( ! $publicId) {
|
if (! $publicId) {
|
||||||
$field = Utils::pluralizeEntityType($this->entityType);
|
$field = Utils::pluralizeEntityType($this->entityType);
|
||||||
if ( ! empty($this->$field)) {
|
if (! empty($this->$field)) {
|
||||||
$publicId = $this->$field;
|
$publicId = $this->$field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! $publicId) {
|
if (! $publicId) {
|
||||||
$publicId = Input::get('public_id') ?: Input::get('id');
|
$publicId = Input::get('public_id') ?: Input::get('id');
|
||||||
}
|
}
|
||||||
if ( ! $publicId) {
|
if (! $publicId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,5 +67,4 @@ class EntityRequest extends Request {
|
|||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
class ExpenseCategoryRequest extends EntityRequest {
|
class ExpenseCategoryRequest extends EntityRequest
|
||||||
|
{
|
||||||
protected $entityType = ENTITY_EXPENSE_CATEGORY;
|
protected $entityType = ENTITY_EXPENSE_CATEGORY;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
use App\Models\ExpenseCategory;
|
use App\Models\ExpenseCategory;
|
||||||
|
|
||||||
|
class ExpenseRequest extends EntityRequest
|
||||||
class ExpenseRequest extends EntityRequest {
|
{
|
||||||
|
|
||||||
protected $entityType = ENTITY_EXPENSE;
|
protected $entityType = ENTITY_EXPENSE;
|
||||||
|
|
||||||
public function entity()
|
public function entity()
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
|
||||||
class InvoiceRequest extends EntityRequest {
|
class InvoiceRequest extends EntityRequest
|
||||||
|
{
|
||||||
protected $entityType = ENTITY_INVOICE;
|
protected $entityType = ENTITY_INVOICE;
|
||||||
|
|
||||||
public function entity()
|
public function entity()
|
||||||
@ -25,5 +25,4 @@ class InvoiceRequest extends EntityRequest {
|
|||||||
|
|
||||||
return $invoice;
|
return $invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php namespace App\Http\Requests;
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
class PaymentRequest extends EntityRequest {
|
class PaymentRequest extends EntityRequest
|
||||||
|
{
|
||||||
protected $entityType = ENTITY_PAYMENT;
|
protected $entityType = ENTITY_PAYMENT;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user