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