diff --git a/LICENSE b/LICENSE index 83e6795919db..2f9d7d69a9b5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Attribution Assurance License -Copyright (c) 2015 by Hillel Coren +Copyright (c) 2016 by Hillel Coren http://www.hillelcoren.com All Rights Reserved diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index 27ecaa59f4cf..3ad84ddfadc6 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -272,4 +272,29 @@ class AppController extends BaseController return RESULT_SUCCESS; } + + public function stats() + { + if (Input::get('password') != env('RESELLER_PASSWORD')) { + sleep(3); + return ''; + } + + if (Utils::getResllerType() == RESELLER_LIMITED_USERS) { + return User::count(); + } else { + $payments = DB::table('accounts') + ->leftJoin('payments', 'payments.account_id', '=', 'accounts.id') + ->leftJoin('clients', 'clients.id', '=', 'payments.client_id') + ->where('accounts.account_key', '=', NINJA_ACCOUNT_KEY) + ->where('payments.is_deleted', '=', false) + ->get([ + 'clients.public_id as client_id', + 'payments.public_id as payment_id', + 'payments.payment_date', + 'payments.amount' + ]); + return json_encode($payments); + } + } } diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index bfda7bcb4916..264c485e617f 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -35,7 +35,7 @@ class StartupCheck // Ensure all request are over HTTPS in production if (Utils::requireHTTPS() && !Request::secure()) { - return Redirect::secure(Request::path()); + //return Redirect::secure(Request::path()); } // If the database doens't yet exist we'll skip the rest diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 8c159e39ea74..b0f44b79a076 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -19,6 +19,7 @@ class VerifyCsrfToken extends BaseVerifier { 'api/v1/hooks', 'hook/email_opened', 'hook/email_bounced', + 'reseller_stats', ]; /** diff --git a/app/Http/routes.php b/app/Http/routes.php index e4fbfc7a933f..5d3748153a57 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -83,6 +83,10 @@ if (Utils::isNinja()) { Route::get('/demo', 'AccountController@demo'); } +if (Utils::isReseller()) { + Route::post('/reseller_stats', 'AppController@stats'); +} + Route::group(['middleware' => 'auth'], function() { Route::get('dashboard', 'DashboardController@index'); Route::get('view_archive/{entity_type}/{visible}', 'AccountController@setTrashVisible'); @@ -583,6 +587,9 @@ if (!defined('CONTACT_EMAIL')) { define('BANK_LIBRARY_OFX', 1); + define('RESELLER_REVENUE_SHARE', 'A'); + define('RESELLER_LIMITED_USERS', 'B'); + $creditCards = [ 1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'], 2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'], diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 113a78671071..1c66946ee043 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -58,6 +58,10 @@ class Utils public static function isNinjaProd() { + if (Utils::isReseller()) { + return true; + } + return isset($_ENV['NINJA_PROD']) && $_ENV['NINJA_PROD'] == 'true'; } @@ -71,6 +75,16 @@ class Utils return Utils::isNinjaProd() || (isset($_ENV['REQUIRE_HTTPS']) && $_ENV['REQUIRE_HTTPS'] == 'true'); } + public static function isReseller() + { + return Utils::getResllerType() ? true : false; + } + + public static function getResllerType() + { + return isset($_ENV['RESELLER_TYPE']) ? $_ENV['RESELLER_TYPE'] : false; + } + public static function isOAuthEnabled() { $providers = [ diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index 1fd6c7117dcc..795d0334d2c4 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -24,6 +24,10 @@ class AccountRepository { public function create($firstName = '', $lastName = '', $email = '', $password = '') { + if (Utils::getResllerType() == RESELLER_LIMITED_USERS && User::count() >= 1000) { + return false; + } + $account = new Account(); $account->ip = Request::getClientIp(); $account->account_key = str_random(RANDOM_KEY_LENGTH); diff --git a/readme.md b/readme.md index ab29279e83e8..4b14f71c1441 100644 --- a/readme.md +++ b/readme.md @@ -13,7 +13,7 @@ ### Reseller Program There are two options: * 10% of revenue -* $1,000 for a site limited to 1,000 accounts +* $1,000 for a site limited to 1,000 users ### Installation Options * [Self-Host Zip](https://www.invoiceninja.com/knowledgebase/self-host/) - Free diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 0236388c8786..95b36e25c9d8 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -264,12 +264,12 @@ }, 3000); $('#search').blur(function(){ - $('#search').css('width', '{{ Utils::isEnglish() ? 150 : 110 }}px'); + $('#search').css('width', '110px'); $('ul.navbar-right').show(); }); $('#search').focus(function(){ - $('#search').css('width', '{{ Utils::isEnglish() ? 264 : 216 }}px'); + $('#search').css('width', '224px'); $('ul.navbar-right').hide(); if (!window.hasOwnProperty('searchData')) { trackEvent('/activity', '/search'); @@ -480,7 +480,7 @@
diff --git a/resources/views/invoices/knockout.blade.php b/resources/views/invoices/knockout.blade.php index d9aec7fea5be..34b86eec2063 100644 --- a/resources/views/invoices/knockout.blade.php +++ b/resources/views/invoices/knockout.blade.php @@ -484,10 +484,8 @@ function InvoiceModel(data) { } var taxRate = parseFloat(self.tax_rate()); - //if (taxRate > 0) { - // total = NINJA.parseFloat(total) + roundToTwo((total * (taxRate/100))); - //} - total = NINJA.parseFloat(total) + roundToTwo((total * (taxRate/100))); + total = NINJA.parseFloat(total) + roundToTwo(total * (taxRate/100)); + total = roundToTwo(total); var taxes = self.totals.itemTaxes(); for (var key in taxes) { diff --git a/resources/views/payments/payment.blade.php b/resources/views/payments/payment.blade.php index 9d6f37cba4fb..8957af0c683f 100644 --- a/resources/views/payments/payment.blade.php +++ b/resources/views/payments/payment.blade.php @@ -239,7 +239,6 @@ ->autocomplete('cc-exp-year') ->data_stripe('exp-year') ->placeholder(trans('texts.expiration_year')) - ->addOption('2015', '2015') ->addOption('2016', '2016') ->addOption('2017', '2017') ->addOption('2018', '2018') @@ -249,7 +248,8 @@ ->addOption('2022', '2022') ->addOption('2023', '2023') ->addOption('2024', '2024') - ->addOption('2025', '2025')->label('') + ->addOption('2025', '2025') + ->addOption('2026', '2026')->label('') !!}