mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
commit
08c54d031c
19
.env.example
Normal file
19
.env.example
Normal file
@ -0,0 +1,19 @@
|
||||
APP_ENV=development
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://ninja.dev
|
||||
APP_CIPHER=rijndael-128
|
||||
APP_KEY=
|
||||
|
||||
DB_TYPE=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=ninja
|
||||
DB_USERNAME=
|
||||
DB_PASSWORD=
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_PORT=587
|
||||
MAIL_ENCRYPTION=tls
|
||||
MAIL_HOST=
|
||||
MAIL_USERNAME=
|
||||
MAIL_FROM_NAME=
|
||||
MAIL_PASSWORD=
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1 +1,3 @@
|
||||
* text=auto
|
||||
*.css linguist-vendored
|
||||
*.less linguist-vendored
|
||||
|
24
.gitignore
vendored
24
.gitignore
vendored
@ -1,10 +1,9 @@
|
||||
/app/config/staging
|
||||
/app/config/development
|
||||
/app/config/production
|
||||
/app/config/fortrabbit
|
||||
/app/config/ubuntu
|
||||
/app/config/packages/anahkiasen/rocketeer/
|
||||
/app/storage
|
||||
/config/staging
|
||||
/config/development
|
||||
/config/production
|
||||
/config/fortrabbit
|
||||
/config/ubuntu
|
||||
/config/packages/anahkiasen/rocketeer/
|
||||
/public/logo
|
||||
/public/build
|
||||
/public/packages
|
||||
@ -12,13 +11,16 @@
|
||||
/bootstrap/compiled.php
|
||||
/bootstrap/environment.php
|
||||
/vendor
|
||||
/node_modules
|
||||
.env
|
||||
/.DS_Store
|
||||
/Thumbs.db
|
||||
/ninja.sublime-project
|
||||
/ninja.sublime-workspace
|
||||
/tests/_log
|
||||
.env.development.php
|
||||
.env.php
|
||||
.idea
|
||||
.project
|
||||
/nbproject/private/
|
||||
error_log
|
||||
public/error_log
|
||||
/ninja.sublime-project
|
||||
/ninja.sublime-workspace
|
||||
auth.json
|
||||
|
@ -61,7 +61,7 @@ module.exports = function(grunt) {
|
||||
'public/js/bootstrap-combobox.js',
|
||||
'public/js/script.js',
|
||||
],
|
||||
dest: 'public/built.js',
|
||||
dest: 'public/js/built.js',
|
||||
nonull: true
|
||||
},
|
||||
js_public: {
|
||||
@ -92,7 +92,7 @@ module.exports = function(grunt) {
|
||||
//'public/vendor/handsontable/dist/jquery.handsontable.full.css',
|
||||
'public/css/style.css',
|
||||
],
|
||||
dest: 'public/built.css',
|
||||
dest: 'public/css/built.css',
|
||||
nonull: true,
|
||||
options: {
|
||||
process: false
|
||||
@ -108,7 +108,7 @@ module.exports = function(grunt) {
|
||||
'public/vendor/datatables/media/css/jquery.dataTables.css',
|
||||
'public/vendor/datatables-bootstrap3/BS3/assets/css/datatables.css',
|
||||
],
|
||||
dest: 'public/built.public.css',
|
||||
dest: 'public/css/built.public.css',
|
||||
nonull: true,
|
||||
options: {
|
||||
process: false
|
||||
|
40
LICENSE
40
LICENSE
@ -1,40 +0,0 @@
|
||||
Attribution Assurance License
|
||||
Copyright (c) 2014 by Hillel Coren
|
||||
http://www.hillelcoren.com
|
||||
|
||||
All Rights Reserved
|
||||
ATTRIBUTION ASSURANCE LICENSE (adapted from the original BSD license)
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the conditions below are met.
|
||||
These conditions require a modest attribution to InvoiceNinja.com. The hope
|
||||
is that its promotional value may help justify the thousands of dollars in
|
||||
otherwise billable time invested in writing this and other freely available,
|
||||
open-source software.
|
||||
|
||||
1. Redistributions of source code, in whole or part and with or without
|
||||
modification requires the express permission of the author and must prominently
|
||||
display "Powered by InvoiceNinja" or the Invoice Ninja logo in verifiable form
|
||||
with hyperlink to said site.
|
||||
2. Neither the name nor any trademark of the Author may be used to
|
||||
endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
3. Users are entirely responsible, to the exclusion of the Author and
|
||||
any other persons, for compliance with (1) regulations set by owners or
|
||||
administrators of employed equipment, (2) licensing terms of any other
|
||||
software, and (3) local regulations regarding use, including those
|
||||
regarding import, export, and use of encryption software.
|
||||
|
||||
THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS;
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
14351
_ide_helper.php
14351
_ide_helper.php
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
7
app/Commands/Command.php
Normal file
7
app/Commands/Command.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php namespace App\Commands;
|
||||
|
||||
abstract class Command {
|
||||
|
||||
//
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
32
app/Console/Commands/Inspire.php
Normal file
32
app/Console/Commands/Inspire.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php namespace InvoiceNinja\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
|
||||
class Inspire extends Command {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
10
app/commands/SendRecurringInvoices.php → app/Console/Commands/SendRecurringInvoices.php
Executable file → Normal file
10
app/commands/SendRecurringInvoices.php → app/Console/Commands/SendRecurringInvoices.php
Executable file → Normal file
@ -1,9 +1,15 @@
|
||||
<?php
|
||||
<?php namespace App\Console\Commands;
|
||||
|
||||
use DateTime;
|
||||
use Carbon;
|
||||
use Utils;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use ninja\mailers\ContactMailer as Mailer;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\InvoiceItem;
|
||||
use App\Models\Invitation;
|
||||
|
||||
class SendRecurringInvoices extends Command
|
||||
{
|
33
app/Console/Kernel.php
Normal file
33
app/Console/Kernel.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel {
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\SendRecurringInvoices',
|
||||
'App\Console\Commands\CreateRandomData',
|
||||
'App\Console\Commands\ResetData',
|
||||
'App\Console\Commands\ImportTimesheetData',
|
||||
'App\Console\Commands\CheckData',
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
}
|
7
app/Events/Event.php
Normal file
7
app/Events/Event.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php namespace App\Events;
|
||||
|
||||
abstract class Event {
|
||||
|
||||
//
|
||||
|
||||
}
|
23
app/Events/InvoicePaid.php
Normal file
23
app/Events/InvoicePaid.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class InvoicePaid extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
public $payment;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($payment)
|
||||
{
|
||||
$this->payment = $payment;
|
||||
}
|
||||
|
||||
}
|
23
app/Events/InvoiceSent.php
Normal file
23
app/Events/InvoiceSent.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class InvoiceSent extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
public $invoice;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($invoice)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
}
|
23
app/Events/InvoiceViewed.php
Normal file
23
app/Events/InvoiceViewed.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class InvoiceViewed extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
public $invoice;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($invoice)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
}
|
23
app/Events/QuoteApproved.php
Normal file
23
app/Events/QuoteApproved.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class QuoteApproved extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
public $invoice;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($invoice)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
}
|
||||
|
||||
}
|
21
app/Events/UserLoggedIn.php
Normal file
21
app/Events/UserLoggedIn.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UserLoggedIn extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
21
app/Events/UserSettingsChanged.php
Normal file
21
app/Events/UserSettingsChanged.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class UserSettingsChanged extends Event {
|
||||
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
44
app/Exceptions/Handler.php
Normal file
44
app/Exceptions/Handler.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php namespace App\Exceptions;
|
||||
|
||||
use Utils;
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler {
|
||||
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
'Symfony\Component\HttpKernel\Exception\HttpException'
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
Utils::logError(Utils::getErrorString($e));
|
||||
return false;
|
||||
//return parent::report($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
0
app/commands/.gitkeep → app/Handlers/Commands/.gitkeep
Executable file → Normal file
0
app/commands/.gitkeep → app/Handlers/Commands/.gitkeep
Executable file → Normal file
0
app/config/packages/.gitkeep → app/Handlers/Events/.gitkeep
Executable file → Normal file
0
app/config/packages/.gitkeep → app/Handlers/Events/.gitkeep
Executable file → Normal file
6
app/handlers/InvoiceEventHandler.php → app/Handlers/InvoiceEventHandler.php
Executable file → Normal file
6
app/handlers/InvoiceEventHandler.php → app/Handlers/InvoiceEventHandler.php
Executable file → Normal file
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
<?php namespace App\Handlers;
|
||||
|
||||
use ninja\mailers\UserMailer;
|
||||
use ninja\mailers\ContactMailer;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
|
||||
class InvoiceEventHandler
|
||||
{
|
0
app/config/packages/zizaco/confide/.gitkeep → app/Http/Controllers/.gitkeep
Executable file → Normal file
0
app/config/packages/zizaco/confide/.gitkeep → app/Http/Controllers/.gitkeep
Executable file → Normal file
95
app/controllers/AccountController.php → app/Http/Controllers/AccountController.php
Executable file → Normal file
95
app/controllers/AccountController.php → app/Http/Controllers/AccountController.php
Executable file → Normal file
@ -1,10 +1,37 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\AccountRepository;
|
||||
use ninja\mailers\UserMailer;
|
||||
use ninja\mailers\ContactMailer;
|
||||
use Auth;
|
||||
use Event;
|
||||
use File;
|
||||
use Image;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use Utils;
|
||||
use Validator;
|
||||
use View;
|
||||
use stdClass;
|
||||
use Cache;
|
||||
|
||||
class AccountController extends \BaseController
|
||||
use App\Models\User;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Account;
|
||||
use App\Models\Country;
|
||||
use App\Models\Currency;
|
||||
use App\Models\DateFormat;
|
||||
use App\Models\DatetimeFormat;
|
||||
use App\Models\Language;
|
||||
use App\Models\Size;
|
||||
use App\Models\Timezone;
|
||||
use App\Models\Industry;
|
||||
use App\Models\InvoiceDesign;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
use App\Events\UserLoggedIn;
|
||||
use App\Events\UserSettingsChanged;
|
||||
|
||||
class AccountController extends BaseController
|
||||
{
|
||||
protected $accountRepo;
|
||||
protected $userMailer;
|
||||
@ -62,7 +89,7 @@ class AccountController extends \BaseController
|
||||
}
|
||||
|
||||
Auth::login($user, true);
|
||||
Event::fire('user.login');
|
||||
Event::fire(new UserLoggedIn());
|
||||
|
||||
return Redirect::to('invoices/create')->with('sign_up', Input::get('sign_up'));
|
||||
}
|
||||
@ -105,14 +132,14 @@ class AccountController extends \BaseController
|
||||
if ($section == ACCOUNT_DETAILS) {
|
||||
$data = [
|
||||
'account' => Account::with('users')->findOrFail(Auth::user()->account_id),
|
||||
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'timezones' => Timezone::remember(DEFAULT_QUERY_CACHE)->orderBy('location')->get(),
|
||||
'dateFormats' => DateFormat::remember(DEFAULT_QUERY_CACHE)->get(),
|
||||
'datetimeFormats' => DatetimeFormat::remember(DEFAULT_QUERY_CACHE)->get(),
|
||||
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'languages' => Language::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'countries' => Cache::get('countries'),
|
||||
'sizes' => Cache::get('sizes'),
|
||||
'industries' => Cache::get('industries'),
|
||||
'timezones' => Cache::get('timezones'),
|
||||
'dateFormats' => Cache::get('dateFormats'),
|
||||
'datetimeFormats' => Cache::get('datetimeFormats'),
|
||||
'currencies' => Cache::get('currencies'),
|
||||
'languages' => Cache::get('languages'),
|
||||
'showUser' => Auth::user()->id === Auth::user()->account->users()->first()->id,
|
||||
];
|
||||
|
||||
@ -170,8 +197,7 @@ class AccountController extends \BaseController
|
||||
$invoice->invoice_items = [$invoiceItem];
|
||||
|
||||
$data['invoice'] = $invoice;
|
||||
$data['invoiceDesigns'] = InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())
|
||||
->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get();
|
||||
$data['invoiceDesigns'] = InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get();
|
||||
} else if ($subSection == ACCOUNT_EMAIL_TEMPLATES) {
|
||||
$data['invoiceEmail'] = $account->getEmailTemplate(ENTITY_INVOICE);
|
||||
$data['quoteEmail'] = $account->getEmailTemplate(ENTITY_QUOTE);
|
||||
@ -264,6 +290,8 @@ class AccountController extends \BaseController
|
||||
$account->quote_number_prefix = Input::get('quote_number_prefix');
|
||||
$account->share_counter = Input::get('share_counter') ? true : false;
|
||||
|
||||
$account->pdf_email_attachment = Input::get('pdf_email_attachment') ? true : false;
|
||||
|
||||
if (!$account->share_counter) {
|
||||
$account->quote_number_counter = Input::get('quote_number_counter');
|
||||
}
|
||||
@ -348,7 +376,7 @@ class AccountController extends \BaseController
|
||||
$count = 0;
|
||||
$hasHeaders = Input::get('header_checkbox');
|
||||
|
||||
$countries = Country::remember(DEFAULT_QUERY_CACHE)->get();
|
||||
$countries = Cache::get('countries');
|
||||
$countryMap = [];
|
||||
|
||||
foreach ($countries as $country) {
|
||||
@ -424,7 +452,7 @@ class AccountController extends \BaseController
|
||||
|
||||
$name = $file->getRealPath();
|
||||
|
||||
require_once app_path().'/includes/parsecsv.lib.php';
|
||||
require_once app_path().'/Includes/parsecsv.lib.php';
|
||||
$csv = new parseCSV();
|
||||
$csv->heading = false;
|
||||
$csv->auto($name);
|
||||
@ -526,6 +554,7 @@ class AccountController extends \BaseController
|
||||
$user->notify_sent = Input::get('notify_sent');
|
||||
$user->notify_viewed = Input::get('notify_viewed');
|
||||
$user->notify_paid = Input::get('notify_paid');
|
||||
$user->notify_approved = Input::get('notify_approved');
|
||||
$user->save();
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
@ -590,18 +619,17 @@ class AccountController extends \BaseController
|
||||
$image = Image::make($path);
|
||||
$mimeType = $file->getMimeType();
|
||||
|
||||
if ($image->width == 200 && $mimeType == 'image/jpeg') {
|
||||
if ($image->width() == 200 && $mimeType == 'image/jpeg') {
|
||||
$file->move('logo/', $account->account_key . '.jpg');
|
||||
} else {
|
||||
$image->resize(200, 120, true, false);
|
||||
Image::canvas($image->width, $image->height, '#FFFFFF')->insert($image)->save($account->getLogoPath());
|
||||
$image->resize(200, 120, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
});
|
||||
Image::canvas($image->width(), $image->height(), '#FFFFFF')->insert($image)->save($account->getLogoPath());
|
||||
}
|
||||
}
|
||||
|
||||
//$image = Image::make($path)->resize(200, 120, true, false);
|
||||
//Image::canvas($image->width, $image->height, '#FFFFFF')->insert($image)->save($account->getLogoPath());
|
||||
}
|
||||
|
||||
Event::fire('user.refresh');
|
||||
Event::fire(new UserSettingsChanged());
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
|
||||
return Redirect::to('company/details');
|
||||
@ -648,10 +676,9 @@ class AccountController extends \BaseController
|
||||
$user->last_name = trim(Input::get('new_last_name'));
|
||||
$user->email = trim(strtolower(Input::get('new_email')));
|
||||
$user->username = $user->email;
|
||||
$user->password = trim(Input::get('new_password'));
|
||||
$user->password_confirmation = trim(Input::get('new_password'));
|
||||
$user->password = bcrypt(trim(Input::get('new_password')));
|
||||
$user->registered = true;
|
||||
$user->amend();
|
||||
$user->save();
|
||||
|
||||
if (Utils::isNinja()) {
|
||||
$this->userMailer->sendConfirmation($user);
|
||||
@ -708,8 +735,16 @@ class AccountController extends \BaseController
|
||||
$account = Auth::user()->account;
|
||||
$account->forceDelete();
|
||||
|
||||
Confide::logout();
|
||||
Auth::logout();
|
||||
|
||||
return Redirect::to('/')->with('clearGuestKey', true);
|
||||
}
|
||||
|
||||
public function resendConfirmation()
|
||||
{
|
||||
$user = Auth::user();
|
||||
$this->userMailer->sendConfirmation($user);
|
||||
|
||||
return Redirect::to('/company/details')->with('message', trans('texts.confirmation_resent'));
|
||||
}
|
||||
}
|
61
app/controllers/AccountGatewayController.php → app/Http/Controllers/AccountGatewayController.php
Executable file → Normal file
61
app/controllers/AccountGatewayController.php → app/Http/Controllers/AccountGatewayController.php
Executable file → Normal file
@ -1,24 +1,30 @@
|
||||
<?php
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confide Controller Template
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the default Confide controller template for controlling user
|
||||
| authentication. Feel free to change to your needs.
|
||||
|
|
||||
*/
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\AccountRepository;
|
||||
use Auth;
|
||||
use Datatable;
|
||||
use DB;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use View;
|
||||
use Validator;
|
||||
use stdClass;
|
||||
use URL;
|
||||
|
||||
use App\Models\Gateway;
|
||||
use App\Models\Account;
|
||||
use App\Models\AccountGateway;
|
||||
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
|
||||
class AccountGatewayController extends BaseController
|
||||
{
|
||||
public function getDatatable()
|
||||
{
|
||||
$query = \DB::table('account_gateways')
|
||||
$query = DB::table('account_gateways')
|
||||
->join('gateways', 'gateways.id', '=', 'account_gateways.gateway_id')
|
||||
->where('account_gateways.deleted_at', '=', null)
|
||||
->where('account_gateways.account_id', '=', \Auth::user()->account_id)
|
||||
->where('account_gateways.account_id', '=', Auth::user()->account_id)
|
||||
->select('account_gateways.public_id', 'gateways.name', 'account_gateways.deleted_at');
|
||||
|
||||
return Datatable::query($query)
|
||||
@ -95,22 +101,6 @@ class AccountGatewayController extends BaseController
|
||||
$selectedCards = $accountGateway ? $accountGateway->accepted_credit_cards : 0;
|
||||
$account = Auth::user()->account;
|
||||
|
||||
$recommendedGateways = Gateway::remember(DEFAULT_QUERY_CACHE)
|
||||
->where('recommended', '=', '1')
|
||||
->orderBy('sort_order')
|
||||
->get();
|
||||
$recommendedGatewayArray = array();
|
||||
|
||||
foreach ($recommendedGateways as $recommendedGateway) {
|
||||
$arrayItem = array(
|
||||
'value' => $recommendedGateway->id,
|
||||
'other' => 'false',
|
||||
'data-imageUrl' => asset($recommendedGateway->getLogoUrl()),
|
||||
'data-siteUrl' => $recommendedGateway->site_url,
|
||||
);
|
||||
$recommendedGatewayArray[$recommendedGateway->name] = $arrayItem;
|
||||
}
|
||||
|
||||
$creditCardsArray = unserialize(CREDIT_CARDS);
|
||||
$creditCards = [];
|
||||
foreach ($creditCardsArray as $card => $name) {
|
||||
@ -121,14 +111,6 @@ class AccountGatewayController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$otherItem = array(
|
||||
'value' => 1000000,
|
||||
'other' => 'true',
|
||||
'data-imageUrl' => '',
|
||||
'data-siteUrl' => '',
|
||||
);
|
||||
$recommendedGatewayArray['Other Options'] = $otherItem;
|
||||
|
||||
$account->load('account_gateways');
|
||||
$currentGateways = $account->account_gateways;
|
||||
$gateways = Gateway::where('payment_library_id', '=', 1)->orderBy('name');
|
||||
@ -165,7 +147,6 @@ class AccountGatewayController extends BaseController
|
||||
'accountGateway' => $accountGateway,
|
||||
'config' => false,
|
||||
'gateways' => $gateways,
|
||||
'recommendedGateways' => $recommendedGatewayArray,
|
||||
'creditCardTypes' => $creditCards,
|
||||
'tokenBillingOptions' => $tokenBillingOptions,
|
||||
'showBreadcrumbs' => false,
|
||||
@ -193,9 +174,7 @@ class AccountGatewayController extends BaseController
|
||||
public function save($accountGatewayPublicId = false)
|
||||
{
|
||||
$rules = array();
|
||||
$recommendedId = Input::get('recommendedGateway_id');
|
||||
|
||||
$gatewayId = ($recommendedId == 1000000 ? Input::get('gateway_id') : $recommendedId);
|
||||
$gatewayId = Input::get('gateway_id');
|
||||
|
||||
if (!$gatewayId) {
|
||||
Session::flash('error', trans('validation.required', ['attribute' => 'gateway']));
|
9
app/controllers/ActivityController.php → app/Http/Controllers/ActivityController.php
Executable file → Normal file
9
app/controllers/ActivityController.php → app/Http/Controllers/ActivityController.php
Executable file → Normal file
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class ActivityController extends \BaseController
|
||||
use Auth;
|
||||
use DB;
|
||||
use Datatable;
|
||||
use Utils;
|
||||
|
||||
class ActivityController extends BaseController
|
||||
{
|
||||
public function getDatatable($clientPublicId)
|
||||
{
|
@ -1,7 +1,18 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\mailers\Mailer;
|
||||
use ninja\repositories\AccountRepository;
|
||||
use Auth;
|
||||
use Artisan;
|
||||
use Cache;
|
||||
use Config;
|
||||
use DB;
|
||||
use Exception;
|
||||
use Input;
|
||||
use Utils;
|
||||
use View;
|
||||
use App\Models\User;
|
||||
use App\Ninja\Mailers\Mailer;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use Redirect;
|
||||
|
||||
class AppController extends BaseController
|
||||
{
|
||||
@ -36,12 +47,10 @@ class AppController extends BaseController
|
||||
|
||||
$app = Input::get('app');
|
||||
$app['key'] = str_random(RANDOM_KEY_LENGTH);
|
||||
$app['debug'] = false;
|
||||
|
||||
$database = Input::get('database');
|
||||
$dbType = $database['default'];
|
||||
$database['connections'] = [$dbType => $database['type']];
|
||||
unset($database['type']);
|
||||
|
||||
$mail = Input::get('mail');
|
||||
$email = $mail['username'];
|
||||
@ -59,42 +68,45 @@ class AppController extends BaseController
|
||||
return Redirect::to('/setup')->withInput();
|
||||
}
|
||||
|
||||
$content = "<?php return 'production';";
|
||||
$fp = fopen(base_path()."/bootstrap/environment.php", 'w');
|
||||
fwrite($fp, $content);
|
||||
// == ENV Settings (Production) == //
|
||||
$config = "APP_ENV=development\n".
|
||||
"APP_DEBUG=true\n".
|
||||
"APP_URL={$app['url']}\n".
|
||||
"APP_KEY={$app['key']}\n\n".
|
||||
"DB_TYPE={$dbType}\n".
|
||||
"DB_HOST={$database['type']['host']}\n".
|
||||
"DB_DATABASE={$database['type']['database']}\n".
|
||||
"DB_USERNAME={$database['type']['username']}\n".
|
||||
"DB_PASSWORD={$database['type']['password']}\n\n".
|
||||
"MAIL_DRIVER={$mail['driver']}\n".
|
||||
"MAIL_PORT={$mail['port']}\n".
|
||||
"MAIL_ENCRYPTION={$mail['encryption']}\n".
|
||||
"MAIL_HOST={$mail['host']}\n".
|
||||
"MAIL_USERNAME={$mail['username']}\n".
|
||||
"MAIL_FROM_NAME={$mail['from']['name']}\n".
|
||||
"MAIL_PASSWORD={$mail['password']}\n";
|
||||
|
||||
// Write Config Settings
|
||||
$fp = fopen(base_path()."/.env", 'w');
|
||||
fwrite($fp, $config);
|
||||
fclose($fp);
|
||||
|
||||
$configDir = app_path().'/config/production';
|
||||
if (!file_exists($configDir)) {
|
||||
mkdir($configDir);
|
||||
}
|
||||
// == DB Migrate & Seed == //
|
||||
// Artisan::call('migrate:rollback', array('--force' => true)); // Debug Purposes
|
||||
Artisan::call('migrate', array('--force' => true));
|
||||
Artisan::call('db:seed', array('--force' => true));
|
||||
|
||||
foreach (['app' => $app, 'database' => $database, 'mail' => $mail] as $key => $config) {
|
||||
$content = '<?php return '.var_export($config, true).';';
|
||||
$fp = fopen(app_path()."/config/production/{$key}.php", 'w');
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
Artisan::call('migrate');
|
||||
Artisan::call('db:seed');
|
||||
|
||||
$account = $this->accountRepo->create();
|
||||
$firstName = trim(Input::get('first_name'));
|
||||
$lastName = trim(Input::get('last_name'));
|
||||
$email = trim(strtolower(Input::get('email')));
|
||||
$password = trim(Input::get('password'));
|
||||
$account = $this->accountRepo->create($firstName, $lastName, $email, $password);
|
||||
$user = $account->users()->first();
|
||||
|
||||
$user->first_name = trim(Input::get('first_name'));
|
||||
$user->last_name = trim(Input::get('last_name'));
|
||||
$user->email = trim(strtolower(Input::get('email')));
|
||||
$user->username = $user->email;
|
||||
$user->password = trim(Input::get('password'));
|
||||
$user->password_confirmation = trim(Input::get('password'));
|
||||
$user->registered = true;
|
||||
$user->amend();
|
||||
|
||||
//Auth::login($user, true);
|
||||
$this->accountRepo->registerUser($user);
|
||||
|
||||
return Redirect::to('/invoices/create');
|
||||
return Redirect::to('/login');
|
||||
}
|
||||
|
||||
private function testDatabase($database)
|
||||
@ -145,8 +157,8 @@ class AppController extends BaseController
|
||||
{
|
||||
if (!Utils::isNinja() && !Utils::isDatabaseSetup()) {
|
||||
try {
|
||||
Artisan::call('migrate');
|
||||
Artisan::call('db:seed');
|
||||
Artisan::call('migrate', array('--force' => true));
|
||||
Artisan::call('db:seed', array('--force' => true));
|
||||
} catch (Exception $e) {
|
||||
Response::make($e->getMessage(), 500);
|
||||
}
|
||||
@ -159,7 +171,7 @@ class AppController extends BaseController
|
||||
{
|
||||
if (!Utils::isNinja()) {
|
||||
try {
|
||||
Artisan::call('migrate');
|
||||
Artisan::call('migrate', array('--force' => true));
|
||||
Cache::flush();
|
||||
} catch (Exception $e) {
|
||||
Response::make($e->getMessage(), 500);
|
57
app/Http/Controllers/Auth/AuthController.php
Normal file
57
app/Http/Controllers/Auth/AuthController.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Auth;
|
||||
use Event;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Events\UserLoggedIn;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\Registrar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
|
||||
class AuthController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Registration & Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users, as well as the
|
||||
| authentication of existing users. By default, this controller uses
|
||||
| a simple trait to add these behaviors. Why don't you explore it?
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
|
||||
protected $loginPath = '/login';
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/**
|
||||
* Create a new authentication controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\Registrar $registrar
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, Registrar $registrar)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->registrar = $registrar;
|
||||
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
}
|
||||
|
||||
public function postLoginWrapper(Request $request)
|
||||
{
|
||||
$response = self::postLogin($request);
|
||||
|
||||
if (Auth::check()) {
|
||||
Event::fire(new UserLoggedIn());
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
40
app/Http/Controllers/Auth/PasswordController.php
Normal file
40
app/Http/Controllers/Auth/PasswordController.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class PasswordController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
protected $redirectTo = '/dashboard';
|
||||
|
||||
/**
|
||||
* Create a new password controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, PasswordBroker $passwords)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->passwords = $passwords;
|
||||
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
}
|
2
app/controllers/BaseController.php → app/Http/Controllers/BaseController.php
Executable file → Normal file
2
app/controllers/BaseController.php → app/Http/Controllers/BaseController.php
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class BaseController extends Controller
|
||||
{
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\ClientRepository;
|
||||
use Utils;
|
||||
use Response;
|
||||
use Input;
|
||||
use App\Models\Client;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
|
||||
class ClientApiController extends Controller
|
||||
{
|
45
app/controllers/ClientController.php → app/Http/Controllers/ClientController.php
Executable file → Normal file
45
app/controllers/ClientController.php → app/Http/Controllers/ClientController.php
Executable file → Normal file
@ -1,8 +1,29 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\ClientRepository;
|
||||
use Auth;
|
||||
use Datatable;
|
||||
use Utils;
|
||||
use View;
|
||||
use URL;
|
||||
use Validator;
|
||||
use Input;
|
||||
use Session;
|
||||
use Redirect;
|
||||
use Cache;
|
||||
|
||||
class ClientController extends \BaseController
|
||||
use App\Models\Activity;
|
||||
use App\Models\Client;
|
||||
use App\Models\Contact;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Size;
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Models\Industry;
|
||||
use App\Models\Currency;
|
||||
use App\Models\Country;
|
||||
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
|
||||
class ClientController extends BaseController
|
||||
{
|
||||
protected $clientRepo;
|
||||
|
||||
@ -90,13 +111,13 @@ class ClientController extends \BaseController
|
||||
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT);
|
||||
|
||||
$actionLinks = [
|
||||
[trans('texts.create_invoice'), URL::to('invoices/create/'.$client->public_id)],
|
||||
[trans('texts.enter_payment'), URL::to('payments/create/'.$client->public_id)],
|
||||
[trans('texts.enter_credit'), URL::to('credits/create/'.$client->public_id)],
|
||||
['label' => trans('texts.create_invoice'), 'url' => URL::to('invoices/create/'.$client->public_id)],
|
||||
['label' => trans('texts.enter_payment'), 'url' => URL::to('payments/create/'.$client->public_id)],
|
||||
['label' => trans('texts.enter_credit'), 'url' => URL::to('credits/create/'.$client->public_id)],
|
||||
];
|
||||
|
||||
if (Utils::isPro()) {
|
||||
array_unshift($actionLinks, [trans('texts.create_quote'), URL::to('quotes/create/'.$client->public_id)]);
|
||||
array_unshift($actionLinks, ['label' => trans('texts.create_quote'), 'url' => URL::to('quotes/create/'.$client->public_id)]);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
@ -159,11 +180,11 @@ class ClientController extends \BaseController
|
||||
private static function getViewModel()
|
||||
{
|
||||
return [
|
||||
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
||||
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'sizes' => Cache::get('sizes'),
|
||||
'paymentTerms' => Cache::get('paymentTerms'),
|
||||
'industries' => Cache::get('industries'),
|
||||
'currencies' => Cache::get('currencies'),
|
||||
'countries' => Cache::get('countries'),
|
||||
'customLabel1' => Auth::user()->account->custom_client_label1,
|
||||
'customLabel2' => Auth::user()->account->custom_client_label2,
|
||||
];
|
11
app/Http/Controllers/Controller.php
Normal file
11
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesCommands;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
|
||||
abstract class Controller extends BaseController {
|
||||
|
||||
use DispatchesCommands, ValidatesRequests;
|
||||
|
||||
}
|
17
app/controllers/CreditController.php → app/Http/Controllers/CreditController.php
Executable file → Normal file
17
app/controllers/CreditController.php → app/Http/Controllers/CreditController.php
Executable file → Normal file
@ -1,8 +1,17 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\CreditRepository;
|
||||
use Datatable;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use Utils;
|
||||
use View;
|
||||
use Validator;
|
||||
use App\Models\Client;
|
||||
|
||||
class CreditController extends \BaseController
|
||||
use App\Ninja\Repositories\CreditRepository;
|
||||
|
||||
class CreditController extends BaseController
|
||||
{
|
||||
protected $creditRepo;
|
||||
|
||||
@ -74,7 +83,6 @@ class CreditController extends \BaseController
|
||||
'method' => 'POST',
|
||||
'url' => 'credits',
|
||||
'title' => trans('texts.new_credit'),
|
||||
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
//'invoices' => Invoice::scope()->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
|
||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
||||
|
||||
@ -92,7 +100,6 @@ class CreditController extends \BaseController
|
||||
'method' => 'PUT',
|
||||
'url' => 'credits/'.$publicId,
|
||||
'title' => 'Edit Credit',
|
||||
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
||||
|
||||
return View::make('credit.edit', $data);
|
@ -1,6 +1,12 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class DashboardController extends \BaseController
|
||||
use Auth;
|
||||
use DB;
|
||||
use View;
|
||||
use App\Models\Activity;
|
||||
use App\Models\Invoice;
|
||||
|
||||
class DashboardController extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
11
app/controllers/HomeController.php → app/Http/Controllers/HomeController.php
Executable file → Normal file
11
app/controllers/HomeController.php → app/Http/Controllers/HomeController.php
Executable file → Normal file
@ -1,6 +1,13 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\mailers\Mailer;
|
||||
use Redirect;
|
||||
use Auth;
|
||||
use View;
|
||||
use Input;
|
||||
use Session;
|
||||
use App\Models\Account;
|
||||
use App\Libraries\Utils;
|
||||
use App\Ninja\Mailers\Mailer;
|
||||
|
||||
class HomeController extends BaseController
|
||||
{
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Utils;
|
||||
|
||||
class IntegrationController extends Controller
|
||||
{
|
@ -1,7 +1,15 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\InvoiceRepository;
|
||||
use ninja\mailers\ContactMailer as Mailer;
|
||||
use Auth;
|
||||
use Utils;
|
||||
use Response;
|
||||
use Input;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Client;
|
||||
use App\Models\Product;
|
||||
use App\Models\Invitation;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
|
||||
class InvoiceApiController extends Controller
|
||||
{
|
||||
@ -15,7 +23,16 @@ class InvoiceApiController extends Controller
|
||||
|
||||
public function index()
|
||||
{
|
||||
$invoices = Invoice::scope()->where('invoices.is_quote', '=', false)->orderBy('created_at', 'desc')->get();
|
||||
$invoices = Invoice::scope()->with('invitations')->where('invoices.is_quote', '=', false)->orderBy('created_at', 'desc')->get();
|
||||
|
||||
// Add the first invitation link to the data
|
||||
foreach ($invoices as $key => $invoice) {
|
||||
foreach ($invoice->invitations as $subKey => $invitation) {
|
||||
$invoices[$key]['link'] = $invitation->getLink();
|
||||
}
|
||||
unset($invoice['invitations']);
|
||||
}
|
||||
|
||||
$invoices = Utils::remapPublicIds($invoices->toArray());
|
||||
|
||||
$response = json_encode($invoices, JSON_PRETTY_PRINT);
|
79
app/controllers/InvoiceController.php → app/Http/Controllers/InvoiceController.php
Executable file → Normal file
79
app/controllers/InvoiceController.php → app/Http/Controllers/InvoiceController.php
Executable file → Normal file
@ -1,11 +1,38 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\mailers\ContactMailer as Mailer;
|
||||
use ninja\repositories\InvoiceRepository;
|
||||
use ninja\repositories\ClientRepository;
|
||||
use ninja\repositories\TaxRateRepository;
|
||||
use Auth;
|
||||
use Session;
|
||||
use Utils;
|
||||
use View;
|
||||
use Input;
|
||||
use Cache;
|
||||
use Redirect;
|
||||
use DB;
|
||||
use Event;
|
||||
use URL;
|
||||
|
||||
class InvoiceController extends \BaseController
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Client;
|
||||
use App\Models\Account;
|
||||
use App\Models\Product;
|
||||
use App\Models\Country;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\Currency;
|
||||
use App\Models\Size;
|
||||
use App\Models\Industry;
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Models\InvoiceDesign;
|
||||
use App\Models\AccountGateway;
|
||||
use App\Models\Activity;
|
||||
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
use App\Ninja\Repositories\TaxRateRepository;
|
||||
use App\Events\InvoiceViewed;
|
||||
|
||||
class InvoiceController extends BaseController
|
||||
{
|
||||
protected $mailer;
|
||||
protected $invoiceRepo;
|
||||
@ -156,7 +183,7 @@ class InvoiceController extends \BaseController
|
||||
|
||||
if (!Session::has($invitationKey) && (!Auth::check() || Auth::user()->account_id != $invoice->account_id)) {
|
||||
Activity::viewInvoice($invitation);
|
||||
Event::fire('invoice.viewed', $invoice);
|
||||
Event::fire(new InvoiceViewed($invoice));
|
||||
}
|
||||
|
||||
Session::set($invitationKey, true);
|
||||
@ -185,7 +212,7 @@ class InvoiceController extends \BaseController
|
||||
'invoiceLabels' => $client->account->getInvoiceLabels(),
|
||||
'contact' => $contact,
|
||||
'hasToken' => $client->getGatewayToken(),
|
||||
'countGateways' => AccountGateway::scope()->count(),
|
||||
'countGateways' => AccountGateway::scope(false, $client->account->id)->count(),
|
||||
);
|
||||
|
||||
return View::make('invoices.view', $data);
|
||||
@ -297,15 +324,14 @@ class InvoiceController extends \BaseController
|
||||
return [
|
||||
'account' => Auth::user()->account,
|
||||
'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')),
|
||||
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'countries' => Cache::get('countries'),
|
||||
'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(),
|
||||
'taxRates' => TaxRate::scope()->orderBy('name')->get(),
|
||||
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
||||
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())
|
||||
->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
|
||||
'currencies' => Cache::get('currencies'),
|
||||
'sizes' => Cache::get('sizes'),
|
||||
'paymentTerms' => Cache::get('paymentTerms'),
|
||||
'industries' => Cache::get('industries'),
|
||||
'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
|
||||
'frequencies' => array(
|
||||
1 => 'Weekly',
|
||||
2 => 'Two weeks',
|
||||
@ -317,6 +343,7 @@ class InvoiceController extends \BaseController
|
||||
),
|
||||
'recurringHelp' => $recurringHelp
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -397,6 +424,12 @@ class InvoiceController extends \BaseController
|
||||
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
|
||||
}
|
||||
|
||||
/*
|
||||
This causes an error message. Commenting out. will return later.
|
||||
if (!empty(Input::get('pdfupload')) && strpos(Input::get('pdfupload'), 'data:application/pdf;base64,') === 0) {
|
||||
$this->storePDF(Input::get('pdfupload'), $invoice->id);
|
||||
}
|
||||
*/
|
||||
if ($action == 'clone') {
|
||||
return $this->cloneInvoice($publicId);
|
||||
} elseif ($action == 'convert') {
|
||||
@ -534,9 +567,23 @@ class InvoiceController extends \BaseController
|
||||
'invoice' => $invoice,
|
||||
'versionsJson' => json_encode($versionsJson),
|
||||
'versionsSelect' => $versionsSelect,
|
||||
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
|
||||
'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
|
||||
];
|
||||
|
||||
return View::make('invoices.history', $data);
|
||||
}
|
||||
|
||||
private function storePDF($encodedString, $invoiceId)
|
||||
{
|
||||
$uploadsDir = storage_path().'/pdfcache/';
|
||||
$encodedString = str_replace('data:application/pdf;base64,', '', $encodedString);
|
||||
$name = 'cache-'.$invoiceId.'.pdf';
|
||||
|
||||
if (file_put_contents($uploadsDir.$name, base64_decode($encodedString)) !== false) {
|
||||
$finfo = new finfo(FILEINFO_MIME);
|
||||
if ($finfo->file($uploadsDir.$name) !== 'application/pdf; charset=binary') {
|
||||
unlink($uploadsDir.$name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\PaymentRepository;
|
||||
use Utils;
|
||||
use Response;
|
||||
use App\Models\Payment;
|
||||
use App\Ninja\Repositories\PaymentRepository;
|
||||
|
||||
class PaymentApiController extends Controller
|
||||
{
|
57
app/controllers/PaymentController.php → app/Http/Controllers/PaymentController.php
Executable file → Normal file
57
app/controllers/PaymentController.php → app/Http/Controllers/PaymentController.php
Executable file → Normal file
@ -1,11 +1,30 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\PaymentRepository;
|
||||
use ninja\repositories\InvoiceRepository;
|
||||
use ninja\repositories\AccountRepository;
|
||||
use ninja\mailers\ContactMailer;
|
||||
use Datatable;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use Utils;
|
||||
use View;
|
||||
use Validator;
|
||||
use Omnipay;
|
||||
use CreditCard;
|
||||
use URL;
|
||||
use Cache;
|
||||
|
||||
class PaymentController extends \BaseController
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Client;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\Country;
|
||||
|
||||
use App\Ninja\Repositories\PaymentRepository;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
use App\Events\InvoicePaid;
|
||||
|
||||
class PaymentController extends BaseController
|
||||
{
|
||||
protected $creditRepo;
|
||||
|
||||
@ -133,8 +152,7 @@ class PaymentController extends \BaseController
|
||||
'method' => 'POST',
|
||||
'url' => "payments",
|
||||
'title' => trans('texts.new_payment'),
|
||||
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||
'paymentTypes' => Cache::get('paymentTypes'),
|
||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
||||
|
||||
return View::make('payments.edit', $data);
|
||||
@ -154,8 +172,7 @@ class PaymentController extends \BaseController
|
||||
'method' => 'PUT',
|
||||
'url' => 'payments/'.$publicId,
|
||||
'title' => trans('texts.edit_payment'),
|
||||
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||
'paymentTypes' => Cache::get('paymentTypes'),
|
||||
'clients' => Client::scope()->with('contacts')->orderBy('name')->get(), );
|
||||
|
||||
return View::make('payments.edit', $data);
|
||||
@ -223,8 +240,9 @@ class PaymentController extends \BaseController
|
||||
];
|
||||
}
|
||||
|
||||
private function getPaymentDetails($invoice, $input = null)
|
||||
private function getPaymentDetails($invitation, $input = null)
|
||||
{
|
||||
$invoice = $invitation->invoice;
|
||||
$key = $invoice->invoice_number.'_details';
|
||||
$gateway = $invoice->client->account->getGatewayByType(Session::get('payment_type'))->gateway;
|
||||
$paymentLibrary = $gateway->paymentlibrary;
|
||||
@ -288,7 +306,8 @@ class PaymentController extends \BaseController
|
||||
'card' => $card,
|
||||
'currency' => $currencyCode,
|
||||
'returnUrl' => URL::to('complete'),
|
||||
'cancelUrl' => URL::to('/')
|
||||
'cancelUrl' => $invitation->getLink(),
|
||||
'description' => trans('texts.' . $invoice->getEntityType()) . " {$invoice->invoice_number}",
|
||||
];
|
||||
} else {
|
||||
return $data;
|
||||
@ -326,6 +345,8 @@ class PaymentController extends \BaseController
|
||||
} else {
|
||||
return self::do_payment($invitationKey, false);
|
||||
}
|
||||
} else {
|
||||
Session::put('payment_type', PAYMENT_TYPE_ANY);
|
||||
}
|
||||
|
||||
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
|
||||
@ -346,7 +367,7 @@ class PaymentController extends \BaseController
|
||||
'paymentLibrary' => $paymentLibrary,
|
||||
'gateway' => $gateway,
|
||||
'acceptedCreditCardTypes' => $acceptedCreditCardTypes,
|
||||
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'countries' => Cache::get('countries'),
|
||||
'currencyId' => $client->currency_id,
|
||||
'account' => $client->account
|
||||
];
|
||||
@ -395,7 +416,7 @@ class PaymentController extends \BaseController
|
||||
'paymentLibrary' => $paymentLibrary,
|
||||
'gateway' => $gateway,
|
||||
'acceptedCreditCardTypes' => $acceptedCreditCardTypes,
|
||||
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'countries' => Cache::get('countries'),
|
||||
'currencyId' => 1,
|
||||
'paymentTitle' => $affiliate->payment_title,
|
||||
'paymentSubtitle' => $affiliate->payment_subtitle,
|
||||
@ -538,7 +559,7 @@ class PaymentController extends \BaseController
|
||||
}
|
||||
}
|
||||
|
||||
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
|
||||
$invitation = Invitation::with('invoice.invoice_items', 'invoice.client.currency', 'invoice.client.account.currency', 'invoice.client.account.account_gateways.gateway')->where('invitation_key', '=', $invitationKey)->firstOrFail();
|
||||
$invoice = $invitation->invoice;
|
||||
$client = $invoice->client;
|
||||
$account = $client->account;
|
||||
@ -557,7 +578,7 @@ class PaymentController extends \BaseController
|
||||
try {
|
||||
if ($paymentLibrary->id == PAYMENT_LIBRARY_OMNIPAY) {
|
||||
$gateway = self::createGateway($accountGateway);
|
||||
$details = self::getPaymentDetails($invoice, $useToken || !$onSite ? false : Input::all());
|
||||
$details = self::getPaymentDetails($invitation, $useToken || !$onSite ? false : Input::all());
|
||||
|
||||
if ($accountGateway->gateway_id == GATEWAY_STRIPE) {
|
||||
if ($useToken) {
|
||||
@ -654,7 +675,7 @@ class PaymentController extends \BaseController
|
||||
|
||||
$payment->save();
|
||||
|
||||
Event::fire('invoice.paid', $payment);
|
||||
Event::fire(new InvoicePaid($payment));
|
||||
|
||||
return $payment;
|
||||
}
|
||||
@ -671,7 +692,7 @@ class PaymentController extends \BaseController
|
||||
$gateway = self::createGateway($accountGateway);
|
||||
|
||||
try {
|
||||
$details = self::getPaymentDetails($invoice);
|
||||
$details = self::getPaymentDetails($invitation);
|
||||
$response = $gateway->completePurchase($details)->send();
|
||||
$ref = $response->getTransactionReference();
|
||||
|
@ -1,6 +1,19 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class ProductController extends \BaseController
|
||||
use Auth;
|
||||
use Str;
|
||||
use DB;
|
||||
use Datatable;
|
||||
use Utils;
|
||||
use URL;
|
||||
use View;
|
||||
use Input;
|
||||
use Session;
|
||||
use Redirect;
|
||||
|
||||
use App\Models\Product;
|
||||
|
||||
class ProductController extends BaseController
|
||||
{
|
||||
public function getDatatable()
|
||||
{
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\InvoiceRepository;
|
||||
use Utils;
|
||||
use Response;
|
||||
use App\Models\Invoice;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
|
||||
class QuoteApiController extends Controller
|
||||
{
|
@ -1,11 +1,32 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\mailers\ContactMailer as Mailer;
|
||||
use ninja\repositories\InvoiceRepository;
|
||||
use ninja\repositories\ClientRepository;
|
||||
use ninja\repositories\TaxRateRepository;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Utils;
|
||||
use View;
|
||||
use Cache;
|
||||
use Event;
|
||||
use Session;
|
||||
use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
use App\Models\Country;
|
||||
use App\Models\Currency;
|
||||
use App\Models\Industry;
|
||||
use App\Models\InvoiceDesign;
|
||||
use App\Models\PaymentTerm;
|
||||
use App\Models\Product;
|
||||
use App\Models\Size;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Activity;
|
||||
use App\Ninja\Mailers\ContactMailer as Mailer;
|
||||
use App\Ninja\Repositories\InvoiceRepository;
|
||||
use App\Ninja\Repositories\ClientRepository;
|
||||
use App\Ninja\Repositories\TaxRateRepository;
|
||||
use App\Events\QuoteApproved;
|
||||
|
||||
class QuoteController extends \BaseController
|
||||
class QuoteController extends BaseController
|
||||
{
|
||||
protected $mailer;
|
||||
protected $invoiceRepo;
|
||||
@ -127,15 +148,14 @@ class QuoteController extends \BaseController
|
||||
'entityType' => ENTITY_QUOTE,
|
||||
'account' => Auth::user()->account,
|
||||
'products' => Product::scope()->orderBy('id')->get(array('product_key', 'notes', 'cost', 'qty')),
|
||||
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'countries' => Cache::get('countries'),
|
||||
'clients' => Client::scope()->with('contacts', 'country')->orderBy('name')->get(),
|
||||
'taxRates' => TaxRate::scope()->orderBy('name')->get(),
|
||||
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'sizes' => Size::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
|
||||
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
|
||||
'industries' => Industry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
|
||||
'invoiceDesigns' => InvoiceDesign::remember(DEFAULT_QUERY_CACHE, 'invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId())
|
||||
->where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
|
||||
'currencies' => Cache::get('currencies'),
|
||||
'sizes' => Cache::get('sizes'),
|
||||
'paymentTerms' => Cache::get('paymentTerms'),
|
||||
'industries' => Cache::get('industries'),
|
||||
'invoiceDesigns' => InvoiceDesign::where('id', '<=', Auth::user()->maxInvoiceDesignId())->orderBy('id')->get(),
|
||||
'invoiceLabels' => Auth::user()->account->getInvoiceLabels()
|
||||
];
|
||||
}
|
||||
@ -171,7 +191,9 @@ class QuoteController extends \BaseController
|
||||
$invoice = $invitation->invoice;
|
||||
|
||||
if ($invoice->is_quote && !$invoice->quote_invoice_id) {
|
||||
Event::fire(new QuoteApproved($invoice));
|
||||
Activity::approveQuote($invitation);
|
||||
|
||||
$invoice = $this->invoiceRepo->cloneInvoice($invoice, $invoice->id);
|
||||
Session::flash('message', trans('texts.converted_to_invoice'));
|
||||
|
15
app/controllers/ReportController.php → app/Http/Controllers/ReportController.php
Executable file → Normal file
15
app/controllers/ReportController.php → app/Http/Controllers/ReportController.php
Executable file → Normal file
@ -1,6 +1,17 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class ReportController extends \BaseController
|
||||
use Auth;
|
||||
use Input;
|
||||
use Utils;
|
||||
use DB;
|
||||
use DateInterval;
|
||||
use DatePeriod;
|
||||
use Session;
|
||||
use View;
|
||||
|
||||
use App\Models\Account;
|
||||
|
||||
class ReportController extends BaseController
|
||||
{
|
||||
public function d3()
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class TimesheetController extends \BaseController {
|
||||
class TimesheetController extends BaseController {
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
21
app/controllers/TokenController.php → app/Http/Controllers/TokenController.php
Executable file → Normal file
21
app/controllers/TokenController.php → app/Http/Controllers/TokenController.php
Executable file → Normal file
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace App\Http\Controllers;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confide Controller Template
|
||||
@ -9,7 +9,19 @@
|
||||
|
|
||||
*/
|
||||
|
||||
use ninja\repositories\AccountRepository;
|
||||
use Auth;
|
||||
use Session;
|
||||
use DB;
|
||||
use Validator;
|
||||
use Input;
|
||||
use View;
|
||||
use Redirect;
|
||||
use Datatable;
|
||||
use URL;
|
||||
|
||||
use App\Models\AccountToken;
|
||||
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
|
||||
class TokenController extends BaseController
|
||||
{
|
||||
@ -81,11 +93,6 @@ class TokenController extends BaseController
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
if (!Auth::user()->confirmed) {
|
||||
Session::flash('error', trans('texts.register_to_add_user'));
|
||||
return Redirect::to('company/advanced_settings/user_management');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'showBreadcrumbs' => false,
|
||||
'token' => null,
|
225
app/controllers/UserController.php → app/Http/Controllers/UserController.php
Executable file → Normal file
225
app/controllers/UserController.php → app/Http/Controllers/UserController.php
Executable file → Normal file
@ -1,17 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Confide Controller Template
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This is the default Confide controller template for controlling user
|
||||
| authentication. Feel free to change to your needs.
|
||||
|
|
||||
*/
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use ninja\repositories\AccountRepository;
|
||||
use ninja\mailers\ContactMailer;
|
||||
use ninja\mailers\UserMailer;
|
||||
use Auth;
|
||||
use Config;
|
||||
use Datatable;
|
||||
use DB;
|
||||
use Event;
|
||||
use Input;
|
||||
use View;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use URL;
|
||||
use Utils;
|
||||
use Validator;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Http\Requests;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
|
||||
class UserController extends BaseController
|
||||
{
|
||||
@ -88,7 +94,7 @@ class UserController extends BaseController
|
||||
$user->force_pdfjs = true;
|
||||
$user->save();
|
||||
|
||||
Session::flash('message', trans('texts.confide.updated_settings'));
|
||||
Session::flash('message', trans('texts.security.updated_settings'));
|
||||
|
||||
return Redirect::to('/dashboard');
|
||||
}
|
||||
@ -221,7 +227,7 @@ class UserController extends BaseController
|
||||
$user->email = trim(Input::get('email'));
|
||||
$user->registered = true;
|
||||
$user->password = str_random(RANDOM_KEY_LENGTH);
|
||||
$user->password_confirmation = $user->password;
|
||||
$user->confirmation_code = str_random(RANDOM_KEY_LENGTH);
|
||||
$user->public_id = $lastUser->public_id + 1;
|
||||
}
|
||||
|
||||
@ -251,81 +257,6 @@ class UserController extends BaseController
|
||||
return Redirect::to('company/advanced_settings/user_management');
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the login form
|
||||
*
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if (Confide::user()) {
|
||||
Event::fire('user.login');
|
||||
Session::reflash();
|
||||
|
||||
return Redirect::to('/dashboard');
|
||||
|
||||
/*
|
||||
$invoice = Invoice::scope()->orderBy('id', 'desc')->first();
|
||||
|
||||
if ($invoice)
|
||||
{
|
||||
return Redirect::to('/invoices/' . $invoice->public_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Redirect::to('/dashboard');
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
return View::make(Config::get('confide::login_form'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to do login
|
||||
*
|
||||
*/
|
||||
public function do_login()
|
||||
{
|
||||
$input = array(
|
||||
'email' => Input::get('login_email'), // May be the username too
|
||||
'username' => Input::get('login_email'), // so we have to pass both
|
||||
'password' => Input::get('login_password'),
|
||||
'remember' => true,
|
||||
);
|
||||
|
||||
// If you wish to only allow login from confirmed users, call logAttempt
|
||||
// with the second parameter as true.
|
||||
// logAttempt will check if the 'email' perhaps is the username.
|
||||
// Get the value from the config file instead of changing the controller
|
||||
if (Input::get('login_email') && Confide::logAttempt($input, false)) {
|
||||
Event::fire('user.login');
|
||||
// Redirect the user to the URL they were trying to access before
|
||||
// caught by the authentication filter IE Redirect::guest('user/login').
|
||||
// Otherwise fallback to '/'
|
||||
// Fix pull #145
|
||||
return Redirect::intended('/dashboard'); // change it to '/admin', '/dashboard' or something
|
||||
} else {
|
||||
//$user = new User;
|
||||
|
||||
// Check if there was too many login attempts
|
||||
if (Confide::isThrottled($input)) {
|
||||
$err_msg = trans('texts.confide.too_many_attempts');
|
||||
}
|
||||
/*
|
||||
elseif( $user->checkUserExists( $input ) and ! $user->isConfirmed( $input ) )
|
||||
{
|
||||
$err_msg = Lang::get('confide::confide.alerts.not_confirmed');
|
||||
}
|
||||
*/
|
||||
else {
|
||||
$err_msg = trans('texts.confide.wrong_credentials');
|
||||
}
|
||||
|
||||
return Redirect::action('UserController@login')
|
||||
->withInput(Input::except('login_password'))
|
||||
->with('error', $err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to confirm account with code
|
||||
@ -334,10 +265,12 @@ class UserController extends BaseController
|
||||
*/
|
||||
public function confirm($code)
|
||||
{
|
||||
if (Confide::confirm($code)) {
|
||||
$notice_msg = trans('texts.confide.confirmation');
|
||||
|
||||
$user = User::where('confirmation_code', '=', $code)->get()->first();
|
||||
|
||||
if ($user) {
|
||||
$notice_msg = trans('texts.security.confirmation');
|
||||
|
||||
$user->confirmed = true;
|
||||
$user->confirmation_code = '';
|
||||
$user->save();
|
||||
|
||||
@ -352,109 +285,13 @@ class UserController extends BaseController
|
||||
|
||||
return Redirect::to($invitation->getLink());
|
||||
} else {
|
||||
return Redirect::action('UserController@login')->with('message', $notice_msg);
|
||||
return Redirect::to(Auth::check() ? '/dashboard' : '/login')->with('message', $notice_msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error_msg = trans('texts.confide.wrong_confirmation');
|
||||
$error_msg = trans('texts.security.wrong_confirmation');
|
||||
|
||||
return Redirect::action('UserController@login')->with('error', $error_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the forgot password form
|
||||
*
|
||||
*/
|
||||
public function forgot_password()
|
||||
{
|
||||
return View::make(Config::get('confide::forgot_password_form'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to send change password link to the given email
|
||||
*
|
||||
*/
|
||||
public function do_forgot_password()
|
||||
{
|
||||
Confide::forgotPassword(Input::get('email'));
|
||||
|
||||
$notice_msg = trans('texts.confide.password_forgot');
|
||||
|
||||
return Redirect::action('UserController@login')
|
||||
->with('notice', $notice_msg);
|
||||
|
||||
/*
|
||||
if( Confide::forgotPassword( Input::get( 'email' ) ) )
|
||||
{
|
||||
$notice_msg = Lang::get('confide::confide.alerts.password_forgot');
|
||||
return Redirect::action('UserController@login')
|
||||
->with( 'notice', $notice_msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_msg = Lang::get('confide::confide.alerts.wrong_password_forgot');
|
||||
return Redirect::action('UserController@forgot_password')
|
||||
->withInput()
|
||||
->with( 'error', $error_msg );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the change password form with the given token
|
||||
*
|
||||
*/
|
||||
public function reset_password($token = false)
|
||||
{
|
||||
return View::make(Config::get('confide::reset_password_form'))
|
||||
->with('token', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt change password of the user
|
||||
*
|
||||
*/
|
||||
public function do_reset_password()
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$rules = [
|
||||
'password' => 'required|between:4,11|confirmed',
|
||||
'password_confirmation' => 'between:4,11',
|
||||
];
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return Redirect::to('user/reset')->withInput()->withErrors($validator);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
$user->password = Input::get('password');
|
||||
$user->save();
|
||||
|
||||
Session::flash('message', trans('texts.confide.password_reset'));
|
||||
|
||||
return Redirect::to('/dashboard');
|
||||
} else {
|
||||
$input = array(
|
||||
'token' => Input::get('token'),
|
||||
'password' => Input::get('password'),
|
||||
'password_confirmation' => Input::get('password_confirmation'),
|
||||
);
|
||||
|
||||
// By passing an array with the token, password and confirmation
|
||||
if (Confide::resetPassword($input)) {
|
||||
$notice_msg = trans('texts.confide.password_reset');
|
||||
|
||||
return Redirect::action('UserController@login')
|
||||
->with('notice', $notice_msg);
|
||||
} else {
|
||||
$error_msg = trans('texts.confide.wrong_password_reset');
|
||||
|
||||
return Redirect::action('UserController@reset_password', array('token' => $input['token']))
|
||||
->withInput()
|
||||
->with('error', $error_msg);
|
||||
}
|
||||
return Redirect::to('/login')->with('error', $error_msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -474,7 +311,7 @@ class UserController extends BaseController
|
||||
Session::forget('news_feed_id');
|
||||
Session::forget('news_feed_message');
|
||||
|
||||
Confide::logout();
|
||||
Auth::logout();
|
||||
|
||||
return Redirect::to('/')->with('clearGuestKey', true);
|
||||
}
|
||||
@ -499,7 +336,7 @@ class UserController extends BaseController
|
||||
|
||||
// save the new password
|
||||
$user = Auth::user();
|
||||
$user->password = $password;
|
||||
$user->password = bcrypt($password);
|
||||
$user->save();
|
||||
|
||||
return RESULT_SUCCESS;
|
36
app/Http/Controllers/old/HomeController.php
Normal file
36
app/Http/Controllers/old/HomeController.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php namespace InvoiceNinja\Http\Controllers;
|
||||
|
||||
class HomeController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Home Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller renders your application's "dashboard" for users that
|
||||
| are authenticated. Of course, you are free to change or remove the
|
||||
| controller as you wish. It is just here to get your app started!
|
||||
|
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard to the user.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
|
||||
}
|
36
app/Http/Controllers/old/WelcomeController.php
Normal file
36
app/Http/Controllers/old/WelcomeController.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php namespace InvoiceNinja\Http\Controllers;
|
||||
|
||||
class WelcomeController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Welcome Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller renders the "marketing page" for the application and
|
||||
| is configured to only allow guests. Like most of the other sample
|
||||
| controllers, you are free to modify or remove it as you desire.
|
||||
|
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application welcome screen to the user.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('welcome');
|
||||
}
|
||||
|
||||
}
|
34
app/Http/Kernel.php
Normal file
34
app/Http/Kernel.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel {
|
||||
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
|
||||
'Illuminate\Cookie\Middleware\EncryptCookies',
|
||||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
||||
'Illuminate\Session\Middleware\StartSession',
|
||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||
'App\Http\Middleware\VerifyCsrfToken',
|
||||
'App\Http\Middleware\StartupCheck',
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => 'App\Http\Middleware\Authenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
||||
'api' => 'App\Http\Middleware\ApiCheck',
|
||||
];
|
||||
|
||||
}
|
77
app/Http/Middleware/ApiCheck.php
Normal file
77
app/Http/Middleware/ApiCheck.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Utils;
|
||||
use Request;
|
||||
use Session;
|
||||
use Response;
|
||||
use Auth;
|
||||
use Cache;
|
||||
|
||||
use App\Models\AccountToken;
|
||||
|
||||
class ApiCheck {
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$headers = Utils::getApiHeaders();
|
||||
|
||||
// check for a valid token
|
||||
$token = AccountToken::where('token', '=', Request::header('X-Ninja-Token'))->first(['id', 'user_id']);
|
||||
|
||||
if ($token) {
|
||||
Auth::loginUsingId($token->user_id);
|
||||
Session::set('token_id', $token->id);
|
||||
} else {
|
||||
sleep(3);
|
||||
return Response::make('Invalid token', 403, $headers);
|
||||
}
|
||||
|
||||
if (!Utils::isNinja()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Utils::isPro()) {
|
||||
return Response::make('API requires pro plan', 403, $headers);
|
||||
} else {
|
||||
$accountId = Auth::user()->account->id;
|
||||
|
||||
// http://stackoverflow.com/questions/1375501/how-do-i-throttle-my-sites-api-users
|
||||
$hour = 60 * 60;
|
||||
$hour_limit = 100; # users are limited to 100 requests/hour
|
||||
$hour_throttle = Cache::get("hour_throttle:{$accountId}", null);
|
||||
$last_api_request = Cache::get("last_api_request:{$accountId}", 0);
|
||||
$last_api_diff = time() - $last_api_request;
|
||||
|
||||
if (is_null($hour_throttle)) {
|
||||
$new_hour_throttle = 0;
|
||||
} else {
|
||||
$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 = $hour_hits_remaining >= 0 ? $hour_hits_remaining : 0;
|
||||
}
|
||||
|
||||
if ($new_hour_throttle > $hour) {
|
||||
$wait = ceil($new_hour_throttle - $hour);
|
||||
sleep(1);
|
||||
return Response::make("Please wait {$wait} second(s)", 403, $headers);
|
||||
}
|
||||
|
||||
Cache::put("hour_throttle:{$accountId}", $new_hour_throttle, 10);
|
||||
Cache::put("last_api_request:{$accountId}", time(), 10);
|
||||
}
|
||||
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
50
app/Http/Middleware/Authenticate.php
Normal file
50
app/Http/Middleware/Authenticate.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class Authenticate {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest())
|
||||
{
|
||||
if ($request->ajax())
|
||||
{
|
||||
return response('Unauthorized.', 401);
|
||||
}
|
||||
else
|
||||
{
|
||||
return redirect()->guest('/login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
44
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
44
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class RedirectIfAuthenticated {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check())
|
||||
{
|
||||
return new RedirectResponse(url('/dashboard'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
157
app/Http/Middleware/StartupCheck.php
Normal file
157
app/Http/Middleware/StartupCheck.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?php namespace app\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Utils;
|
||||
use App;
|
||||
use Auth;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Cache;
|
||||
use Session;
|
||||
use Event;
|
||||
use App\Events\UserSettingsChanged;
|
||||
|
||||
class StartupCheck
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
// Ensure all request are over HTTPS in production
|
||||
if (App::environment() == ENV_PRODUCTION) {
|
||||
if (!Request::secure()) {
|
||||
return Redirect::secure(Request::getRequestUri());
|
||||
}
|
||||
}
|
||||
|
||||
// If the database doens't yet exist we'll skip the rest
|
||||
if (!Utils::isNinja() && !Utils::isDatabaseSetup()) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
// Check data has been cached
|
||||
$cachedTables = [
|
||||
'currencies' => 'App\Models\Currency',
|
||||
'sizes' => 'App\Models\Size',
|
||||
'industries' => 'App\Models\Industry',
|
||||
'timezones' => 'App\Models\Timezone',
|
||||
'dateFormats' => 'App\Models\DateFormat',
|
||||
'datetimeFormats' => 'App\Models\DatetimeFormat',
|
||||
'languages' => 'App\Models\Language',
|
||||
'paymentTerms' => 'App\Models\PaymentTerm',
|
||||
'paymentTypes' => 'App\Models\PaymentType',
|
||||
];
|
||||
foreach ($cachedTables as $name => $class) {
|
||||
if (!Cache::has($name)) {
|
||||
$orderBy = 'id';
|
||||
|
||||
if ($name == 'paymentTerms') {
|
||||
$orderBy = 'num_days';
|
||||
} elseif (property_exists($class, 'name') && $name != 'paymentTypes') {
|
||||
$orderBy = 'name';
|
||||
}
|
||||
|
||||
Cache::forever($name, $class::orderBy($orderBy)->get());
|
||||
}
|
||||
}
|
||||
|
||||
// check the application is up to date and for any news feed messages
|
||||
if (Auth::check()) {
|
||||
$count = Session::get(SESSION_COUNTER, 0);
|
||||
Session::put(SESSION_COUNTER, ++$count);
|
||||
|
||||
if (!Utils::startsWith($_SERVER['REQUEST_URI'], '/news_feed') && !Session::has('news_feed_id')) {
|
||||
$data = false;
|
||||
if (Utils::isNinja()) {
|
||||
$data = Utils::getNewsFeedResponse();
|
||||
} else {
|
||||
$file = @file_get_contents(NINJA_APP_URL.'/news_feed/'.Utils::getUserType().'/'.NINJA_VERSION);
|
||||
$data = @json_decode($file);
|
||||
}
|
||||
if ($data) {
|
||||
if ($data->version != NINJA_VERSION) {
|
||||
$params = [
|
||||
'user_version' => NINJA_VERSION,
|
||||
'latest_version' => $data->version,
|
||||
'releases_link' => link_to(RELEASES_URL, 'Invoice Ninja', ['target' => '_blank']),
|
||||
];
|
||||
Session::put('news_feed_id', NEW_VERSION_AVAILABLE);
|
||||
Session::put('news_feed_message', trans('texts.new_version_available', $params));
|
||||
} else {
|
||||
Session::put('news_feed_id', $data->id);
|
||||
if ($data->message && $data->id > Auth::user()->news_feed_id) {
|
||||
Session::put('news_feed_message', $data->message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Session::put('news_feed_id', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we're requesting to change the account's language
|
||||
if (Input::has('lang')) {
|
||||
$locale = Input::get('lang');
|
||||
App::setLocale($locale);
|
||||
Session::set(SESSION_LOCALE, $locale);
|
||||
|
||||
if (Auth::check()) {
|
||||
if ($language = Language::whereLocale($locale)->first()) {
|
||||
$account = Auth::user()->account;
|
||||
$account->language_id = $language->id;
|
||||
$account->save();
|
||||
}
|
||||
}
|
||||
} elseif (Auth::check()) {
|
||||
$locale = Session::get(SESSION_LOCALE, DEFAULT_LOCALE);
|
||||
App::setLocale($locale);
|
||||
}
|
||||
|
||||
// Make sure the account/user localization settings are in the session
|
||||
if (Auth::check() && !Session::has(SESSION_TIMEZONE)) {
|
||||
Event::fire(new UserSettingsChanged());
|
||||
}
|
||||
|
||||
// Check if the user is claiming a license (ie, additional invoices, white label, etc.)
|
||||
$claimingLicense = Utils::startsWith($_SERVER['REQUEST_URI'], '/claim_license');
|
||||
if (!$claimingLicense && Input::has('license_key') && Input::has('product_id')) {
|
||||
$licenseKey = Input::get('license_key');
|
||||
$productId = Input::get('product_id');
|
||||
|
||||
$data = trim(file_get_contents((Utils::isNinjaDev() ? 'http://ninja.dev' : NINJA_APP_URL)."/claim_license?license_key={$licenseKey}&product_id={$productId}"));
|
||||
|
||||
if ($productId == PRODUCT_INVOICE_DESIGNS) {
|
||||
if ($data = json_decode($data)) {
|
||||
foreach ($data as $item) {
|
||||
$design = new InvoiceDesign();
|
||||
$design->id = $item->id;
|
||||
$design->name = $item->name;
|
||||
$design->javascript = $item->javascript;
|
||||
$design->save();
|
||||
}
|
||||
|
||||
if (!Utils::isNinjaProd()) {
|
||||
Cache::forget('invoice_designs_cache_'.Auth::user()->maxInvoiceDesignId());
|
||||
}
|
||||
|
||||
Session::flash('message', trans('texts.bought_designs'));
|
||||
}
|
||||
} elseif ($productId == PRODUCT_WHITE_LABEL) {
|
||||
if ($data == 'valid') {
|
||||
$account = Auth::user()->account;
|
||||
$account->pro_plan_paid = NINJA_DATE;
|
||||
$account->save();
|
||||
|
||||
Session::flash('message', trans('texts.bought_white_label'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
35
app/Http/Middleware/VerifyCsrfToken.php
Normal file
35
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||
|
||||
class VerifyCsrfToken extends BaseVerifier {
|
||||
|
||||
private $openRoutes = [
|
||||
'api/v1/clients',
|
||||
'api/v1/invoices',
|
||||
'api/v1/quotes',
|
||||
'api/v1/payments',
|
||||
'api/v1/email_invoice',
|
||||
];
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
foreach($this->openRoutes as $route) {
|
||||
|
||||
if ($request->is($route)) {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::handle($request, $next);
|
||||
}
|
||||
|
||||
}
|
9
app/Http/Requests/Request.php
Normal file
9
app/Http/Requests/Request.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
abstract class Request extends FormRequest {
|
||||
|
||||
//
|
||||
|
||||
}
|
33
app/routes.php → app/Http/routes.php
Executable file → Normal file
33
app/routes.php → app/Http/routes.php
Executable file → Normal file
@ -16,7 +16,6 @@
|
||||
//dd(DB::getQueryLog());
|
||||
//dd(Client::getPrivateId(1));
|
||||
//dd(new DateTime());
|
||||
//Event::fire('user.signup');
|
||||
//dd(App::environment());
|
||||
//dd(gethostname());
|
||||
//Log::error('test');
|
||||
@ -54,23 +53,44 @@ Route::get('claim_license', 'PaymentController@claim_license');
|
||||
Route::post('signup/validate', 'AccountController@checkEmail');
|
||||
Route::post('signup/submit', 'AccountController@submitSignup');
|
||||
|
||||
|
||||
// Laravel auth routes
|
||||
/*
|
||||
Route::controllers([
|
||||
'auth' => 'Auth\AuthController',
|
||||
'password' => 'Auth\PasswordController',
|
||||
]);
|
||||
*/
|
||||
|
||||
get('/signup', array('as' => 'signup', 'uses' => 'Auth\AuthController@getRegister'));
|
||||
post('/signup', array('as' => 'signup', 'uses' => 'Auth\AuthController@postRegister'));
|
||||
get('/login', array('as' => 'login', 'uses' => 'Auth\AuthController@getLogin'));
|
||||
post('/login', array('as' => 'login', 'uses' => 'Auth\AuthController@postLoginWrapper'));
|
||||
get('/logout', array('as' => 'logout', 'uses' => 'Auth\AuthController@getLogout'));
|
||||
get('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getEmail'));
|
||||
post('/forgot', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postEmail'));
|
||||
get('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@getReset'));
|
||||
post('/password/reset', array('as' => 'forgot', 'uses' => 'Auth\PasswordController@postReset'));
|
||||
get('/user/confirm/{code}', 'UserController@confirm');
|
||||
|
||||
/*
|
||||
// Confide routes
|
||||
Route::get('login', 'UserController@login');
|
||||
Route::post('login', 'UserController@do_login');
|
||||
Route::get('user/confirm/{code}', 'UserController@confirm');
|
||||
Route::get('forgot_password', 'UserController@forgot_password');
|
||||
Route::post('forgot_password', 'UserController@do_forgot_password');
|
||||
Route::get('user/reset/{token?}', 'UserController@reset_password');
|
||||
Route::post('user/reset', 'UserController@do_reset_password');
|
||||
Route::get('logout', 'UserController@logout');
|
||||
*/
|
||||
|
||||
if (Utils::isNinja()) {
|
||||
if (\App\Libraries\Utils::isNinja()) {
|
||||
Route::post('/signup/register', 'AccountController@doRegister');
|
||||
Route::get('/news_feed/{user_type}/{version}/', 'HomeController@newsFeed');
|
||||
Route::get('/demo', 'AccountController@demo');
|
||||
}
|
||||
|
||||
Route::group(array('before' => 'auth'), function() {
|
||||
Route::group(['middleware' => 'auth'], function() {
|
||||
Route::get('dashboard', 'DashboardController@index');
|
||||
Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible');
|
||||
Route::get('hide_message', 'HomeController@hideMessage');
|
||||
@ -147,11 +167,12 @@ Route::group(array('before' => 'auth'), function() {
|
||||
Route::get('api/credits/{client_id?}', array('as'=>'api.credits', 'uses'=>'CreditController@getDatatable'));
|
||||
Route::post('credits/bulk', 'CreditController@bulk');
|
||||
|
||||
get('/resend_confirmation', 'AccountController@resendConfirmation');
|
||||
//Route::resource('timesheets', 'TimesheetController');
|
||||
});
|
||||
|
||||
// Route group for API
|
||||
Route::group(array('prefix' => 'api/v1', 'before' => ['api.access']), function()
|
||||
Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
|
||||
{
|
||||
Route::resource('ping', 'ClientApiController@ping');
|
||||
Route::resource('clients', 'ClientApiController');
|
||||
@ -301,7 +322,7 @@ define('NINJA_GATEWAY_ID', GATEWAY_AUTHORIZE_NET);
|
||||
define('NINJA_GATEWAY_CONFIG', '{"apiLoginId":"626vWcD5","transactionKey":"4bn26TgL9r4Br4qJ","testMode":"","developerMode":""}');
|
||||
define('NINJA_WEB_URL', 'https://www.invoiceninja.com');
|
||||
define('NINJA_APP_URL', 'https://app.invoiceninja.com');
|
||||
define('NINJA_VERSION', '1.6.1');
|
||||
define('NINJA_VERSION', '1.7.2');
|
||||
define('NINJA_DATE', '2000-01-01');
|
||||
define('NINJA_FROM_EMAIL', 'maildelivery@invoiceninja.com');
|
||||
define('RELEASES_URL', 'https://github.com/hillelcoren/invoice-ninja/releases/');
|
0
app/includes/parsecsv.lib.php → app/Includes/parsecsv.lib.php
Executable file → Normal file
0
app/includes/parsecsv.lib.php → app/Includes/parsecsv.lib.php
Executable file → Normal file
42
app/libraries/Utils.php → app/Libraries/Utils.php
Executable file → Normal file
42
app/libraries/Utils.php → app/Libraries/Utils.php
Executable file → Normal file
@ -1,4 +1,20 @@
|
||||
<?php
|
||||
<?php namespace App\Libraries;
|
||||
|
||||
use Auth;
|
||||
use Cache;
|
||||
use DB;
|
||||
use Schema;
|
||||
use Session;
|
||||
use Request;
|
||||
use View;
|
||||
use DateTimeZone;
|
||||
use Input;
|
||||
use Log;
|
||||
use DateTime;
|
||||
use stdClass;
|
||||
use Carbon;
|
||||
|
||||
use App\Models\Currency;
|
||||
|
||||
class Utils
|
||||
{
|
||||
@ -18,7 +34,7 @@ class Utils
|
||||
if (Schema::hasTable('accounts')) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -149,6 +165,7 @@ class Utils
|
||||
'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '',
|
||||
'ip' => Request::getClientIp(),
|
||||
'count' => Session::get('error_count', 0),
|
||||
//'input' => Input::all()
|
||||
];
|
||||
|
||||
Log::error($error."\n", $data);
|
||||
@ -217,12 +234,14 @@ class Utils
|
||||
$currencyId = Session::get(SESSION_CURRENCY);
|
||||
}
|
||||
|
||||
$currency = Currency::remember(DEFAULT_QUERY_CACHE)->find($currencyId);
|
||||
$currency = Currency::find($currencyId);
|
||||
|
||||
if (!$currency) {
|
||||
$currency = Currency::remember(DEFAULT_QUERY_CACHE)->find(1);
|
||||
if(!$currency){
|
||||
$currency = Currency::find(1);
|
||||
}
|
||||
|
||||
Cache::add('currency', $currency, DEFAULT_QUERY_CACHE);
|
||||
|
||||
return $currency->symbol.number_format($value, $currency->precision, $currency->decimal_separator, $currency->thousand_separator);
|
||||
}
|
||||
|
||||
@ -291,8 +310,8 @@ class Utils
|
||||
return;
|
||||
}
|
||||
|
||||
$timezone = Session::get(SESSION_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT);
|
||||
$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT);
|
||||
|
||||
$dateTime = DateTime::createFromFormat($format, $date, new DateTimeZone($timezone));
|
||||
|
||||
@ -305,8 +324,8 @@ class Utils
|
||||
return '';
|
||||
}
|
||||
|
||||
$timezone = Session::get(SESSION_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT);
|
||||
$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT);
|
||||
|
||||
$dateTime = DateTime::createFromFormat('Y-m-d', $date, new DateTimeZone($timezone));
|
||||
|
||||
@ -315,8 +334,9 @@ class Utils
|
||||
|
||||
public static function today($formatResult = true)
|
||||
{
|
||||
$timezone = Session::get(SESSION_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT);
|
||||
$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT);
|
||||
|
||||
$date = date_create(null, new DateTimeZone($timezone));
|
||||
|
||||
if ($formatResult) {
|
0
app/libraries/entity.php → app/Libraries/entity.php
Executable file → Normal file
0
app/libraries/entity.php → app/Libraries/entity.php
Executable file → Normal file
46
app/Listeners/HandleInvoicePaid.php
Normal file
46
app/Listeners/HandleInvoicePaid.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php namespace App\Listeners;
|
||||
|
||||
use App\Events\InvoicePaid;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
use App\Ninja\Mailers\ContactMailer;
|
||||
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeQueued;
|
||||
|
||||
class HandleInvoicePaid {
|
||||
|
||||
protected $userMailer;
|
||||
protected $contactMailer;
|
||||
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserMailer $userMailer, ContactMailer $contactMailer)
|
||||
{
|
||||
$this->userMailer = $userMailer;
|
||||
$this->contactMailer = $contactMailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param InvoicePaid $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(InvoicePaid $event)
|
||||
{
|
||||
$this->contactMailer->sendPaymentConfirmation($payment);
|
||||
$invoice = $payment->invoice;
|
||||
|
||||
foreach ($invoice->account->users as $user)
|
||||
{
|
||||
if ($user->{'notify_paid'})
|
||||
{
|
||||
$this->userMailer->sendNotification($user, $invoice, 'paid', $payment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
42
app/Listeners/HandleInvoiceSent.php
Normal file
42
app/Listeners/HandleInvoiceSent.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Listeners;
|
||||
|
||||
use App\Events\InvoiceSent;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeQueued;
|
||||
|
||||
class HandleInvoiceSent {
|
||||
|
||||
protected $userMailer;
|
||||
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserMailer $userMailer)
|
||||
{
|
||||
$this->userMailer = $userMailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param InvoiceSent $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(InvoiceSent $event)
|
||||
{
|
||||
$invoice = $event->invoice;
|
||||
|
||||
foreach ($invoice->account->users as $user)
|
||||
{
|
||||
if ($user->{'notify_sent'})
|
||||
{
|
||||
$this->userMailer->sendNotification($user, $invoice, 'sent');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
42
app/Listeners/HandleInvoiceViewed.php
Normal file
42
app/Listeners/HandleInvoiceViewed.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Listeners;
|
||||
|
||||
use App\Events\InvoiceViewed;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeQueued;
|
||||
|
||||
class HandleInvoiceViewed {
|
||||
|
||||
protected $userMailer;
|
||||
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserMailer $userMailer)
|
||||
{
|
||||
$this->userMailer = $userMailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param InvoiceViewed $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(InvoiceViewed $event)
|
||||
{
|
||||
$invoice = $event->invoice;
|
||||
|
||||
foreach ($invoice->account->users as $user)
|
||||
{
|
||||
if ($user->{'notify_viewed'})
|
||||
{
|
||||
$this->userMailer->sendNotification($user, $invoice, 'viewed', $payment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
42
app/Listeners/HandleQuoteApproved.php
Normal file
42
app/Listeners/HandleQuoteApproved.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php namespace App\Listeners;
|
||||
|
||||
use App\Events\QuoteApproved;
|
||||
use App\Ninja\Mailers\UserMailer;
|
||||
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeQueued;
|
||||
|
||||
class HandleQuoteApproved {
|
||||
|
||||
protected $userMailer;
|
||||
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(UserMailer $userMailer)
|
||||
{
|
||||
$this->userMailer = $userMailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param QuoteApproved $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(QuoteApproved $event)
|
||||
{
|
||||
$invoice = $event->invoice;
|
||||
|
||||
foreach ($invoice->account->users as $user)
|
||||
{
|
||||
if ($user->{'notify_approved'})
|
||||
{
|
||||
$this->userMailer->sendNotification($user, $invoice, 'approved');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
37
app/Listeners/HandleUserLoggedIn.php
Normal file
37
app/Listeners/HandleUserLoggedIn.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php namespace App\Listeners;
|
||||
|
||||
use Auth;
|
||||
use Carbon;
|
||||
use App\Events\UserLoggedIn;
|
||||
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeQueued;
|
||||
|
||||
class HandleUserLoggedIn {
|
||||
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param UserLoggedIn $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(UserLoggedIn $event)
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
$account->last_login = Carbon::now()->toDateTimeString();
|
||||
$account->save();
|
||||
|
||||
$account->loadLocalizationSettings();
|
||||
}
|
||||
|
||||
}
|
34
app/Listeners/HandleUserSettingsChanged.php
Normal file
34
app/Listeners/HandleUserSettingsChanged.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php namespace App\Listeners;
|
||||
|
||||
use Auth;
|
||||
|
||||
use App\Events\UserSettingsChanged;
|
||||
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldBeQueued;
|
||||
|
||||
class HandleUserSettingsChanged {
|
||||
|
||||
/**
|
||||
* Create the event handler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param UserSettingsChanged $event
|
||||
* @return void
|
||||
*/
|
||||
public function handle(UserSettingsChanged $event)
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
$account->loadLocalizationSettings();
|
||||
}
|
||||
|
||||
}
|
48
app/models/Account.php → app/Models/Account.php
Executable file → Normal file
48
app/models/Account.php → app/Models/Account.php
Executable file → Normal file
@ -1,67 +1,79 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
use Utils;
|
||||
use Session;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Account extends Eloquent
|
||||
{
|
||||
protected $softDelete = true;
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany('User');
|
||||
return $this->hasMany('App\Models\User');
|
||||
}
|
||||
|
||||
public function clients()
|
||||
{
|
||||
return $this->hasMany('Client');
|
||||
return $this->hasMany('App\Models\Client');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('Invoice');
|
||||
return $this->hasMany('App\Models\Invoice');
|
||||
}
|
||||
|
||||
public function account_gateways()
|
||||
{
|
||||
return $this->hasMany('AccountGateway');
|
||||
return $this->hasMany('App\Models\AccountGateway');
|
||||
}
|
||||
|
||||
public function tax_rates()
|
||||
{
|
||||
return $this->hasMany('TaxRate');
|
||||
return $this->hasMany('App\Models\TaxRate');
|
||||
}
|
||||
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo('Country');
|
||||
return $this->belongsTo('App\Models\Country');
|
||||
}
|
||||
|
||||
public function timezone()
|
||||
{
|
||||
return $this->belongsTo('Timezone');
|
||||
return $this->belongsTo('App\Models\Timezone');
|
||||
}
|
||||
|
||||
public function language()
|
||||
{
|
||||
return $this->belongsTo('Language');
|
||||
return $this->belongsTo('App\Models\Language');
|
||||
}
|
||||
|
||||
public function date_format()
|
||||
{
|
||||
return $this->belongsTo('DateFormat');
|
||||
return $this->belongsTo('App\Models\DateFormat');
|
||||
}
|
||||
|
||||
public function datetime_format()
|
||||
{
|
||||
return $this->belongsTo('DatetimeFormat');
|
||||
return $this->belongsTo('App\Models\DatetimeFormat');
|
||||
}
|
||||
|
||||
public function size()
|
||||
{
|
||||
return $this->belongsTo('Size');
|
||||
return $this->belongsTo('App\Models\Size');
|
||||
}
|
||||
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Currency');
|
||||
}
|
||||
|
||||
public function industry()
|
||||
{
|
||||
return $this->belongsTo('Industry');
|
||||
return $this->belongsTo('App\Models\Industry');
|
||||
}
|
||||
|
||||
public function isGatewayConfigured($gatewayId = 0)
|
||||
@ -99,7 +111,7 @@ class Account extends Eloquent
|
||||
public function getGatewayByType($type = PAYMENT_TYPE_ANY)
|
||||
{
|
||||
foreach ($this->account_gateways as $gateway) {
|
||||
if ($type == PAYMENT_TYPE_ANY) {
|
||||
if (!$type || $type == PAYMENT_TYPE_ANY) {
|
||||
return $gateway;
|
||||
} elseif ($gateway->isPayPal() && $type == PAYMENT_TYPE_PAYPAL) {
|
||||
return $gateway;
|
||||
@ -181,7 +193,7 @@ class Account extends Eloquent
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
$language = Language::remember(DEFAULT_QUERY_CACHE)->where('id', '=', $this->account->language_id)->first();
|
||||
$language = Language::where('id', '=', $this->account->language_id)->first();
|
||||
|
||||
return $language->locale;
|
||||
}
|
||||
@ -352,6 +364,10 @@ class Account extends Eloquent
|
||||
|
||||
public function showTokenCheckbox()
|
||||
{
|
||||
if (!$this->isGatewayConfigured(GATEWAY_STRIPE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->token_billing_type_id == TOKEN_BILLING_OPT_IN
|
||||
|| $this->token_billing_type_id == TOKEN_BILLING_OPT_OUT;
|
||||
}
|
9
app/models/AccountGateway.php → app/Models/AccountGateway.php
Executable file → Normal file
9
app/models/AccountGateway.php → app/Models/AccountGateway.php
Executable file → Normal file
@ -1,10 +1,15 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class AccountGateway extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function gateway()
|
||||
{
|
||||
return $this->belongsTo('Gateway');
|
||||
return $this->belongsTo('App\Models\Gateway');
|
||||
}
|
||||
|
||||
public function getCreditcardTypes()
|
10
app/Models/AccountGatewayToken.php
Normal file
10
app/Models/AccountGatewayToken.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class AccountGatewayToken extends Eloquent
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
public $timestamps = true;
|
||||
}
|
14
app/Models/AccountToken.php
Normal file
14
app/Models/AccountToken.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class AccountToken extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
}
|
19
app/models/Activity.php → app/Models/Activity.php
Executable file → Normal file
19
app/models/Activity.php → app/Models/Activity.php
Executable file → Normal file
@ -1,9 +1,15 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Auth;
|
||||
use Eloquent;
|
||||
use Utils;
|
||||
use Session;
|
||||
use Request;
|
||||
use Carbon;
|
||||
|
||||
class Activity extends Eloquent
|
||||
{
|
||||
public $timestamps = true;
|
||||
protected $softDelete = false;
|
||||
|
||||
public function scopeScope($query)
|
||||
{
|
||||
@ -12,12 +18,12 @@ class Activity extends Eloquent
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('Account');
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
return $this->belongsTo('App\Models\User');
|
||||
}
|
||||
|
||||
private static function getBlank($entity = false)
|
||||
@ -35,6 +41,7 @@ class Activity extends Eloquent
|
||||
}
|
||||
|
||||
$activity->token_id = Session::get('token_id', null);
|
||||
$activity->ip = Request::getClientIp();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
@ -187,10 +194,10 @@ class Activity extends Eloquent
|
||||
}
|
||||
}
|
||||
|
||||
if ($diff > 0 || $fieldChanged) {
|
||||
if ($diff != 0 || $fieldChanged) {
|
||||
$backupInvoice = Invoice::with('invoice_items', 'client.account', 'client.contacts')->find($invoice->id);
|
||||
|
||||
if ($diff > 0 && !$invoice->is_quote && !$invoice->is_recurring) {
|
||||
if ($diff != 0 && !$invoice->is_quote && !$invoice->is_recurring) {
|
||||
$client->balance = $client->balance + $diff;
|
||||
$client->save();
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
class Affiliate extends Eloquent
|
||||
{
|
135
app/models/Client.php → app/Models/Client.php
Executable file → Normal file
135
app/models/Client.php → app/Models/Client.php
Executable file → Normal file
@ -1,7 +1,14 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use DB;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Client extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public static $fieldName = 'Client - Name';
|
||||
public static $fieldPhone = 'Client - Phone';
|
||||
public static $fieldAddress1 = 'Client - Street';
|
||||
@ -14,47 +21,47 @@ class Client extends EntityModel
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('Account');
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany('Invoice');
|
||||
return $this->hasMany('App\Models\Invoice');
|
||||
}
|
||||
|
||||
public function payments()
|
||||
{
|
||||
return $this->hasMany('Payment');
|
||||
return $this->hasMany('App\Models\Payment');
|
||||
}
|
||||
|
||||
public function contacts()
|
||||
{
|
||||
return $this->hasMany('Contact');
|
||||
return $this->hasMany('App\Models\Contact');
|
||||
}
|
||||
|
||||
public function projects()
|
||||
{
|
||||
return $this->hasMany('Project');
|
||||
return $this->hasMany('App\Models\Project');
|
||||
}
|
||||
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo('Country');
|
||||
return $this->belongsTo('App\Models\Country');
|
||||
}
|
||||
|
||||
public function currency()
|
||||
{
|
||||
return $this->belongsTo('Currency');
|
||||
return $this->belongsTo('App\Models\Currency');
|
||||
}
|
||||
|
||||
public function size()
|
||||
{
|
||||
return $this->belongsTo('Size');
|
||||
return $this->belongsTo('App\Models\Size');
|
||||
}
|
||||
|
||||
public function industry()
|
||||
{
|
||||
return $this->belongsTo('Industry');
|
||||
return $this->belongsTo('App\Models\Industry');
|
||||
}
|
||||
|
||||
public function getTotalCredit()
|
||||
@ -87,111 +94,6 @@ class Client extends EntityModel
|
||||
return ENTITY_CLIENT;
|
||||
}
|
||||
|
||||
public function getAddress()
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($this->address1) {
|
||||
$str .= $this->address1.'<br/>';
|
||||
}
|
||||
if ($this->address2) {
|
||||
$str .= $this->address2.'<br/>';
|
||||
}
|
||||
if ($this->city) {
|
||||
$str .= $this->city.', ';
|
||||
}
|
||||
if ($this->state) {
|
||||
$str .= $this->state.' ';
|
||||
}
|
||||
if ($this->postal_code) {
|
||||
$str .= $this->postal_code;
|
||||
}
|
||||
if ($this->country) {
|
||||
$str .= '<br/>'.$this->country->name;
|
||||
}
|
||||
|
||||
if ($str) {
|
||||
$str = '<p>'.$str.'</p>';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getPhone()
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($this->work_phone) {
|
||||
$str .= '<i class="fa fa-phone" style="width: 20px"></i>'.Utils::formatPhoneNumber($this->work_phone);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getIdNumber()
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($this->id_number) {
|
||||
$str .= '<i class="fa fa-id-number" style="width: 20px"></i>'.trans('texts.id_number').': '.$this->id_number;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getVatNumber()
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($this->vat_number) {
|
||||
$str .= '<i class="fa fa-vat-number" style="width: 20px"></i>'.trans('texts.vat_number').': '.$this->vat_number;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getNotes()
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($this->private_notes) {
|
||||
$str .= '<i>'.$this->private_notes.'</i>';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getIndustry()
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($this->client_industry) {
|
||||
$str .= $this->client_industry->name.' ';
|
||||
}
|
||||
|
||||
if ($this->client_size) {
|
||||
$str .= $this->client_size->name;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getCustomFields()
|
||||
{
|
||||
$str = '';
|
||||
$account = $this->account;
|
||||
|
||||
if ($account->custom_client_label1 && $this->custom_value1) {
|
||||
$str .= "{$account->custom_client_label1}: {$this->custom_value1}<br/>";
|
||||
}
|
||||
|
||||
if ($account->custom_client_label2 && $this->custom_value2) {
|
||||
$str .= "{$account->custom_client_label2}: {$this->custom_value2}<br/>";
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function getWebsite()
|
||||
{
|
||||
if (!$this->website) {
|
||||
@ -263,6 +165,7 @@ Client::deleting(function ($client) {
|
||||
Activity::archiveClient($client);
|
||||
});
|
||||
|
||||
Client::restoring(function ($client) {
|
||||
/*Client::restoring(function ($client) {
|
||||
Activity::restoreClient($client);
|
||||
});
|
||||
*/
|
34
app/models/Contact.php → app/Models/Contact.php
Executable file → Normal file
34
app/models/Contact.php → app/Models/Contact.php
Executable file → Normal file
@ -1,7 +1,14 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use HTML;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Contact extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public static $fieldFirstName = 'Contact - First Name';
|
||||
public static $fieldLastName = 'Contact - Last Name';
|
||||
public static $fieldEmail = 'Contact - Email';
|
||||
@ -9,7 +16,7 @@ class Contact extends EntityModel
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo('Client');
|
||||
return $this->belongsTo('App\Models\Client');
|
||||
}
|
||||
|
||||
public function getPersonType()
|
||||
@ -48,27 +55,4 @@ class Contact extends EntityModel
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public function getDetails()
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($this->first_name || $this->last_name) {
|
||||
$str .= '<b>'.$this->first_name.' '.$this->last_name.'</b><br/>';
|
||||
}
|
||||
|
||||
if ($this->email) {
|
||||
$str .= '<i class="fa fa-envelope" style="width: 20px"></i>'.HTML::mailto($this->email, $this->email).'<br/>';
|
||||
}
|
||||
|
||||
if ($this->phone) {
|
||||
$str .= '<i class="fa fa-phone" style="width: 20px"></i>'.Utils::formatPhoneNumber($this->phone);
|
||||
}
|
||||
|
||||
if ($str) {
|
||||
$str = '<p>'.$str.'</p>';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
10
app/Models/Country.php
Normal file
10
app/Models/Country.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class Country extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
protected $visible = ['id', 'name'];
|
||||
}
|
11
app/models/Credit.php → app/Models/Credit.php
Executable file → Normal file
11
app/models/Credit.php → app/Models/Credit.php
Executable file → Normal file
@ -1,15 +1,20 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Credit extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('Invoice')->withTrashed();
|
||||
return $this->belongsTo('App\Models\Invoice')->withTrashed();
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo('Client')->withTrashed();
|
||||
return $this->belongsTo('App\Models\Client')->withTrashed();
|
||||
}
|
||||
|
||||
public function getName()
|
5
app/models/Currency.php → app/Models/Currency.php
Executable file → Normal file
5
app/models/Currency.php → app/Models/Currency.php
Executable file → Normal file
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class Currency extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
5
app/models/DateFormat.php → app/Models/DateFormat.php
Executable file → Normal file
5
app/models/DateFormat.php → app/Models/DateFormat.php
Executable file → Normal file
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class DateFormat extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
5
app/models/DatetimeFormat.php → app/Models/DatetimeFormat.php
Executable file → Normal file
5
app/models/DatetimeFormat.php → app/Models/DatetimeFormat.php
Executable file → Normal file
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class DatetimeFormat extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
8
app/models/EntityModel.php → app/Models/EntityModel.php
Executable file → Normal file
8
app/models/EntityModel.php → app/Models/EntityModel.php
Executable file → Normal file
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Auth;
|
||||
use Eloquent;
|
||||
use Utils;
|
||||
|
||||
class EntityModel extends Eloquent
|
||||
{
|
||||
protected $softDelete = true;
|
||||
public $timestamps = true;
|
||||
|
||||
protected $hidden = ['id'];
|
||||
|
||||
public static function createNew($parent = false)
|
5
app/models/Frequency.php → app/Models/Frequency.php
Executable file → Normal file
5
app/models/Frequency.php → app/Models/Frequency.php
Executable file → Normal file
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class Frequency extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
8
app/models/Gateway.php → app/Models/Gateway.php
Executable file → Normal file
8
app/models/Gateway.php → app/Models/Gateway.php
Executable file → Normal file
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
use Omnipay;
|
||||
|
||||
class Gateway extends Eloquent
|
||||
{
|
||||
public $timestamps = true;
|
||||
protected $softDelete = false;
|
||||
|
||||
public function paymentlibrary()
|
||||
{
|
||||
return $this->belongsTo('PaymentLibrary', 'payment_library_id');
|
||||
return $this->belongsTo('\App\Models\PaymentLibrary', 'payment_library_id');
|
||||
}
|
||||
|
||||
public function getLogoUrl()
|
5
app/models/Industry.php → app/Models/Industry.php
Executable file → Normal file
5
app/models/Industry.php → app/Models/Industry.php
Executable file → Normal file
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class Industry extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
34
app/Models/Invitation.php
Normal file
34
app/Models/Invitation.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Invitation extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Invoice');
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Contact')->withTrashed();
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\User')->withTrashed();
|
||||
}
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
return SITE_URL.'/view/'.$this->invitation_key;
|
||||
}
|
||||
}
|
37
app/models/Invoice.php → app/Models/Invoice.php
Executable file → Normal file
37
app/models/Invoice.php → app/Models/Invoice.php
Executable file → Normal file
@ -1,40 +1,45 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Invoice extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('Account');
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('User');
|
||||
return $this->belongsTo('App\Models\User');
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo('Client')->withTrashed();
|
||||
return $this->belongsTo('App\Models\Client')->withTrashed();
|
||||
}
|
||||
|
||||
public function invoice_items()
|
||||
{
|
||||
return $this->hasMany('InvoiceItem');
|
||||
return $this->hasMany('App\Models\InvoiceItem')->orderBy('id');
|
||||
}
|
||||
|
||||
public function invoice_status()
|
||||
{
|
||||
return $this->belongsTo('InvoiceStatus');
|
||||
return $this->belongsTo('App\Models\InvoiceStatus');
|
||||
}
|
||||
|
||||
public function invoice_design()
|
||||
{
|
||||
return $this->belongsTo('InvoiceDesign');
|
||||
return $this->belongsTo('App\Models\InvoiceDesign');
|
||||
}
|
||||
|
||||
public function invitations()
|
||||
{
|
||||
return $this->hasMany('Invitation')->orderBy('invitations.contact_id');
|
||||
return $this->hasMany('App\Models\Invitation')->orderBy('invitations.contact_id');
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@ -93,7 +98,8 @@ class Invoice extends EntityModel
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
'custom_taxes1',
|
||||
'custom_taxes2', ]);
|
||||
'custom_taxes2',
|
||||
]);
|
||||
|
||||
$this->client->setVisible([
|
||||
'name',
|
||||
@ -110,7 +116,8 @@ class Invoice extends EntityModel
|
||||
'country',
|
||||
'currency_id',
|
||||
'custom_value1',
|
||||
'custom_value2', ]);
|
||||
'custom_value2',
|
||||
]);
|
||||
|
||||
$this->account->setVisible([
|
||||
'name',
|
||||
@ -136,7 +143,9 @@ class Invoice extends EntityModel
|
||||
'hide_quantity',
|
||||
'hide_paid_to_date',
|
||||
'custom_invoice_label1',
|
||||
'custom_invoice_label2', ]);
|
||||
'custom_invoice_label2',
|
||||
'pdf_email_attachment',
|
||||
]);
|
||||
|
||||
foreach ($this->invoice_items as $invoiceItem) {
|
||||
$invoiceItem->setVisible([
|
||||
@ -145,7 +154,8 @@ class Invoice extends EntityModel
|
||||
'cost',
|
||||
'qty',
|
||||
'tax_name',
|
||||
'tax_rate', ]);
|
||||
'tax_rate',
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($this->client->contacts as $contact) {
|
||||
@ -153,7 +163,8 @@ class Invoice extends EntityModel
|
||||
'first_name',
|
||||
'last_name',
|
||||
'email',
|
||||
'phone', ]);
|
||||
'phone',
|
||||
]);
|
||||
}
|
||||
|
||||
return $this;
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class InvoiceDesign extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
19
app/Models/InvoiceItem.php
Normal file
19
app/Models/InvoiceItem.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class InvoiceItem extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Invoice');
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Product');
|
||||
}
|
||||
}
|
5
app/models/InvoiceStatus.php → app/Models/InvoiceStatus.php
Executable file → Normal file
5
app/models/InvoiceStatus.php → app/Models/InvoiceStatus.php
Executable file → Normal file
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class InvoiceStatus extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
5
app/models/Language.php → app/Models/Language.php
Executable file → Normal file
5
app/models/Language.php → app/Models/Language.php
Executable file → Normal file
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class Language extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
10
app/Models/License.php
Normal file
10
app/Models/License.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class License extends Eloquent
|
||||
{
|
||||
public $timestamps = true;
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
}
|
17
app/models/Payment.php → app/Models/Payment.php
Executable file → Normal file
17
app/models/Payment.php → app/Models/Payment.php
Executable file → Normal file
@ -1,30 +1,35 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Payment extends EntityModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
public function invoice()
|
||||
{
|
||||
return $this->belongsTo('Invoice')->withTrashed();
|
||||
return $this->belongsTo('App\Models\Invoice')->withTrashed();
|
||||
}
|
||||
|
||||
public function invitation()
|
||||
{
|
||||
return $this->belongsTo('Invitation');
|
||||
return $this->belongsTo('App\Models\Invitation');
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo('Client')->withTrashed();
|
||||
return $this->belongsTo('App\Models\Client')->withTrashed();
|
||||
}
|
||||
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('Account');
|
||||
return $this->belongsTo('App\Models\Account');
|
||||
}
|
||||
|
||||
public function contact()
|
||||
{
|
||||
return $this->belongsTo('Contact');
|
||||
return $this->belongsTo('App\Models\Contact');
|
||||
}
|
||||
|
||||
public function getAmount()
|
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class PaymentLibrary extends Eloquent
|
||||
{
|
||||
@ -7,6 +9,6 @@ class PaymentLibrary extends Eloquent
|
||||
|
||||
public function gateways()
|
||||
{
|
||||
return $this->hasMany('Gateway', 'payment_library_id');
|
||||
return $this->hasMany('App\Models\Gateway', 'payment_library_id');
|
||||
}
|
||||
}
|
5
app/models/PaymentTerm.php → app/Models/PaymentTerm.php
Executable file → Normal file
5
app/models/PaymentTerm.php → app/Models/PaymentTerm.php
Executable file → Normal file
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
<?php namespace App\Models;
|
||||
|
||||
use Eloquent;
|
||||
|
||||
class PaymentTerm extends Eloquent
|
||||
{
|
||||
public $timestamps = false;
|
||||
protected $softDelete = false;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user