diff --git a/.env.example b/.env.example index bd40885edb..b354269ebf 100644 --- a/.env.example +++ b/.env.example @@ -2,18 +2,18 @@ APP_ENV=development APP_DEBUG=true APP_URL=http://ninja.dev APP_CIPHER=rijndael-128 -APP_KEY= +APP_KEY DB_TYPE=mysql DB_HOST=localhost DB_DATABASE=ninja -DB_USERNAME= -DB_PASSWORD= +DB_USERNAME +DB_PASSWORD MAIL_DRIVER=smtp MAIL_PORT=587 MAIL_ENCRYPTION=tls -MAIL_HOST= -MAIL_USERNAME= -MAIL_FROM_NAME= -MAIL_PASSWORD= \ No newline at end of file +MAIL_HOST +MAIL_USERNAME +MAIL_FROM_NAME +MAIL_PASSWORD \ No newline at end of file diff --git a/app/Console/Commands/SendRenewalInvoices.php b/app/Console/Commands/SendRenewalInvoices.php new file mode 100644 index 0000000000..ceae80e611 --- /dev/null +++ b/app/Console/Commands/SendRenewalInvoices.php @@ -0,0 +1,57 @@ +mailer = $mailer; + $this->accountRepo = $repo; + } + + public function fire() + { + $this->info(date('Y-m-d').' Running SendRenewalInvoices...'); + $today = new DateTime(); + + $accounts = Account::whereRaw('datediff(curdate(), pro_plan_paid) = 355')->get(); + $this->info(count($accounts).' accounts found'); + dd(0); + foreach ($accounts as $account) { + $client = $this->accountRepo->getNinjaClient($account); + $invitation = $this->accountRepo->createNinjaInvoice($client); + $this->mailer->sendInvoice($invitation->invoice); + } + + $this->info('Done'); + } + + protected function getArguments() + { + return array( + //array('example', InputArgument::REQUIRED, 'An example argument.'), + ); + } + + protected function getOptions() + { + return array( + //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null), + ); + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ddf38a4a30..64d68d6f46 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel { 'App\Console\Commands\ResetData', 'App\Console\Commands\ImportTimesheetData', 'App\Console\Commands\CheckData', + 'App\Console\Commands\SendRenewalInvoices', ]; /** diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index ef45bb4374..084f74fcc4 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -27,6 +27,7 @@ class Handler extends ExceptionHandler { { Utils::logError(Utils::getErrorString($e)); return false; + //return parent::report($e); } diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 371086bef4..01a85dd5b8 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -572,7 +572,7 @@ class AccountController extends BaseController } $subdomain = preg_replace('/[^a-zA-Z0-9_\-]/', '', substr(strtolower(Input::get('subdomain')), 0, MAX_SUBDOMAIN_LENGTH)); - if (in_array($subdomain, ['www', 'app', 'mail'])) { + if (!$subdomain || in_array($subdomain, ['www', 'app', 'mail', 'admin', 'blog'])) { $subdomain = null; } if ($subdomain) { diff --git a/app/Http/Controllers/AppController.php b/app/Http/Controllers/AppController.php index ddef45e053..964923ee61 100644 --- a/app/Http/Controllers/AppController.php +++ b/app/Http/Controllers/AppController.php @@ -9,6 +9,7 @@ use Exception; use Input; use Utils; use View; +use Session; use App\Models\User; use App\Ninja\Mailers\Mailer; use App\Ninja\Repositories\AccountRepository; diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index bf128d6afb..5c31f19e81 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -52,7 +52,7 @@ class DashboardController extends BaseController $activities = Activity::where('activities.account_id', '=', Auth::user()->account_id) ->where('activity_type_id', '>', 0) - ->orderBy('created_at', 'desc')->take(6)->get(); + ->orderBy('created_at', 'desc')->take(14)->get(); $pastDue = Invoice::scope() ->where('due_date', '<', date('Y-m-d')) @@ -73,7 +73,7 @@ class DashboardController extends BaseController $data = [ 'paidToDate' => $paidToDate, 'averageInvoice' => $averageInvoice, - 'billedClients' => $metrics ? $metrics->billed_clients : 0, + //'billedClients' => $metrics ? $metrics->billed_clients : 0, 'invoicesSent' => $metrics ? $metrics->invoices_sent : 0, 'activeClients' => $metrics ? $metrics->active_clients : 0, 'activities' => $activities, diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index cb6bf5e283..6eacdad00f 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -23,7 +23,7 @@ class HomeController extends BaseController public function showIndex() { Session::reflash(); - + if (!Utils::isDatabaseSetup()) { return Redirect::to('/setup'); } elseif (Account::count() == 0) { diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index dcc9d31d48..b75ad9d369 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -13,6 +13,8 @@ use CreditCard; use URL; use Cache; use Event; +use DateTime; +use App\Models\Account; use App\Models\Invoice; use App\Models\Invitation; use App\Models\Client; @@ -20,6 +22,7 @@ use App\Models\PaymentType; use App\Models\Country; use App\Models\License; use App\Models\Payment; +use App\Models\Affiliate; use App\Models\AccountGatewayToken; use App\Ninja\Repositories\PaymentRepository; use App\Ninja\Repositories\InvoiceRepository; @@ -610,7 +613,12 @@ class PaymentController extends BaseController if ($invoice->account->account_key == NINJA_ACCOUNT_KEY) { $account = Account::find($invoice->client->public_id); - $account->pro_plan_paid = date_create()->format('Y-m-d'); + if ($account->pro_plan_paid) { + $date = DateTime::createFromFormat('Y-m-d', $account->pro_plan_paid); + $account->pro_plan_paid = $date->modify('+1 year')->format('Y-m-d'); + } else { + $account->pro_plan_paid = date_create()->format('Y-m-d'); + } $account->save(); } diff --git a/app/Http/Middleware/StartupCheck.php b/app/Http/Middleware/StartupCheck.php index 696df9a588..bcf67ef0ce 100644 --- a/app/Http/Middleware/StartupCheck.php +++ b/app/Http/Middleware/StartupCheck.php @@ -10,6 +10,7 @@ use Cache; use Session; use Event; use App\Models\Language; +use App\Models\InvoiceDesign; use App\Events\UserSettingsChanged; class StartupCheck @@ -124,7 +125,7 @@ class StartupCheck $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}")); + $data = trim(file_get_contents((Utils::isNinjaDev() ? 'http://www.ninja.dev' : NINJA_APP_URL)."/claim_license?license_key={$licenseKey}&product_id={$productId}")); if ($productId == PRODUCT_INVOICE_DESIGNS) { if ($data = json_decode($data)) { diff --git a/app/Http/routes.php b/app/Http/routes.php index 9e1a441866..94f49865e6 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -84,7 +84,7 @@ Route::post('user/reset', 'UserController@do_reset_password'); Route::get('logout', 'UserController@logout'); */ -if (\App\Libraries\Utils::isNinja()) { +if (Utils::isNinja()) { Route::post('/signup/register', 'AccountController@doRegister'); Route::get('/news_feed/{user_type}/{version}/', 'HomeController@newsFeed'); Route::get('/demo', 'AccountController@demo'); @@ -350,7 +350,7 @@ define('EVENT_CREATE_PAYMENT', 4); define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN'); define('DEMO_ACCOUNT_ID', 'DEMO_ACCOUNT_ID'); define('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h'); -define('NINJA_GATEWAY_ID', GATEWAY_AUTHORIZE_NET); +define('NINJA_GATEWAY_ID', GATEWAY_STRIPE); define('NINJA_GATEWAY_CONFIG', ''); define('NINJA_WEB_URL', 'https://www.invoiceninja.com'); define('NINJA_APP_URL', 'https://app.invoiceninja.com'); @@ -507,7 +507,7 @@ Validator::extend('has_credit', function($attribute, $value, $parameters) { $publicClientId = $parameters[0]; $amount = $parameters[1]; - $client = Client::scope($publicClientId)->firstOrFail(); + $client = \App\Models\Client::scope($publicClientId)->firstOrFail(); $credit = $client->getTotalCredit(); return $credit >= $amount; diff --git a/app/Ninja/Repositories/AccountRepository.php b/app/Ninja/Repositories/AccountRepository.php index 695b79918e..b18ccfd983 100644 --- a/app/Ninja/Repositories/AccountRepository.php +++ b/app/Ninja/Repositories/AccountRepository.php @@ -108,19 +108,19 @@ class AccountRepository if (Auth::user()->isPro()) { return false; } - - $ninjaAccount = $this->getNinjaAccount(); - $lastInvoice = Invoice::withTrashed()->whereAccountId($ninjaAccount->id)->orderBy('public_id', 'DESC')->first(); - $publicId = $lastInvoice ? ($lastInvoice->public_id + 1) : 1; - - $ninjaClient = $this->getNinjaClient($ninjaAccount); - $invitation = $this->createNinjaInvoice($publicId, $ninjaAccount, $ninjaClient); + + $client = $this->getNinjaClient(Auth::user()->account); + $invitation = $this->createNinjaInvoice($client); return $invitation; } - private function createNinjaInvoice($publicId, $account, $client) + public function createNinjaInvoice($client) { + $account = $this->getNinjaAccount(); + $lastInvoice = Invoice::withTrashed()->whereAccountId($account->id)->orderBy('public_id', 'DESC')->first(); + $publicId = $lastInvoice ? ($lastInvoice->public_id + 1) : 1; + $invoice = new Invoice(); $invoice->account_id = $account->id; $invoice->user_id = $account->users()->first()->id; @@ -174,7 +174,6 @@ class AccountRepository $user->confirmed = true; $user->email = 'contact@invoiceninja.com'; $user->password = $random; - $user->password_confirmation = $random; $user->username = $random; $user->first_name = 'Invoice'; $user->last_name = 'Ninja'; @@ -193,27 +192,29 @@ class AccountRepository return $account; } - private function getNinjaClient($ninjaAccount) + public function getNinjaClient($account) { - $client = Client::whereAccountId($ninjaAccount->id)->wherePublicId(Auth::user()->account_id)->first(); + $account->load('users'); + $ninjaAccount = $this->getNinjaAccount(); + $client = Client::whereAccountId($ninjaAccount->id)->wherePublicId($account->id)->first(); if (!$client) { $client = new Client(); - $client->public_id = Auth::user()->account_id; + $client->public_id = $account->id; $client->user_id = $ninjaAccount->users()->first()->id; $client->currency_id = 1; foreach (['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'country_id', 'work_phone'] as $field) { - $client->$field = Auth::user()->account->$field; + $client->$field = $account->$field; } $ninjaAccount->clients()->save($client); $contact = new Contact(); $contact->user_id = $ninjaAccount->users()->first()->id; $contact->account_id = $ninjaAccount->id; - $contact->public_id = Auth::user()->account_id; + $contact->public_id = $account->id; $contact->is_primary = true; foreach (['first_name', 'last_name', 'email', 'phone'] as $field) { - $contact->$field = Auth::user()->$field; + $contact->$field = $account->users()->first()->$field; } $client->contacts()->save($contact); } @@ -223,13 +224,13 @@ class AccountRepository public function registerUser($user) { - $url = NINJA_APP_URL.'/signup/register'; + $url = (Utils::isNinjaDev() ? '' : NINJA_APP_URL) . '/signup/register'; $data = ''; $fields = [ - 'first_name' => urlencode($user->first_name), - 'last_name' => urlencode($user->last_name), - 'email' => urlencode($user->email), - ]; + 'first_name' => urlencode($user->first_name), + 'last_name' => urlencode($user->last_name), + 'email' => urlencode($user->email), + ]; foreach ($fields as $key => $value) { $data .= $key.'='.$value.'&'; diff --git a/config/app.php b/config/app.php index a8dd21bff2..d4ca7d6d40 100644 --- a/config/app.php +++ b/config/app.php @@ -95,7 +95,7 @@ return [ | */ - 'log' => 'daily', + 'log' => 'single', /* |-------------------------------------------------------------------------- diff --git a/config/session.php b/config/session.php index 417b506ccb..2ffb7d5cc9 100644 --- a/config/session.php +++ b/config/session.php @@ -29,7 +29,7 @@ return [ | */ - 'lifetime' => 120, + 'lifetime' => 360, 'expire_on_close' => false, diff --git a/public/css/built.css b/public/css/built.css index 01bb59406a..608464b39b 100644 --- a/public/css/built.css +++ b/public/css/built.css @@ -2388,7 +2388,7 @@ body { background: #f8f8f8 !important; } .bold { font-weight: 700; } a {color:#0b4d78;} -a:hover { text-decoration: none; color: #0a3857;} +/*a:hover { text-decoration: none; color: #0a3857;}*/ .breadcrumb { padding: 8px 0!important; } diff --git a/public/css/style.css b/public/css/style.css index 8c138b7b2d..c59b4647d1 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -4,7 +4,7 @@ body { background: #f8f8f8 !important; } .bold { font-weight: 700; } a {color:#0b4d78;} -a:hover { text-decoration: none; color: #0a3857;} +/*a:hover { text-decoration: none; color: #0a3857;}*/ .breadcrumb { padding: 8px 0!important; } diff --git a/public/js/built.js b/public/js/built.js index b8859bfc75..ea550343f3 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -31941,7 +31941,7 @@ function isValidEmailAddress(emailAddress) { $(function() { $.ajaxSetup({ headers: { - 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); }); diff --git a/public/js/script.js b/public/js/script.js index aa630d6b49..a591702af8 100644 --- a/public/js/script.js +++ b/public/js/script.js @@ -391,7 +391,7 @@ function isValidEmailAddress(emailAddress) { $(function() { $.ajaxSetup({ headers: { - 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); }); diff --git a/resources/lang/da/texts.php b/resources/lang/da/texts.php index ee77c9c14a..f6faea7b2f 100644 --- a/resources/lang/da/texts.php +++ b/resources/lang/da/texts.php @@ -263,7 +263,7 @@ return array( 'payment_message' => 'Tak for din betaling pålydende :amount.', 'email_salutation' => 'Kære :name,', 'email_signature' => 'Med venlig hilsen,', - 'email_from' => 'The InvoiceNinja Team', + 'email_from' => 'The Invoice Ninja Team', 'user_email_footer' => 'For at justere varslingsindstillingene venligst besøg '.SITE_URL.'/company/notifications', 'invoice_link_message' => 'Hvis du vil se din klientfaktura klik på linket under:', 'notification_invoice_paid_subject' => 'Faktura :invoice betalt af :client', diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index c2a0cdb9e8..e45efcefff 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -261,7 +261,7 @@ return array( 'payment_message' => 'Thank you for your payment of :amount.', 'email_salutation' => 'Dear :name,', 'email_signature' => 'Regards,', - 'email_from' => 'The InvoiceNinja Team', + 'email_from' => 'The Invoice Ninja Team', 'user_email_footer' => 'To adjust your email notification settings please visit '.SITE_URL.'/company/notifications', 'invoice_link_message' => 'To view your client invoice click the link below:', 'notification_invoice_paid_subject' => 'Invoice :invoice was paid by :client', diff --git a/resources/lang/lt/texts.php b/resources/lang/lt/texts.php index 3b1cc2d9b0..acd2dc7825 100644 --- a/resources/lang/lt/texts.php +++ b/resources/lang/lt/texts.php @@ -261,7 +261,7 @@ return array( 'payment_message' => 'Thank you for your payment of :amount.', 'email_salutation' => 'Dear :name,', 'email_signature' => 'Regards,', - 'email_from' => 'The InvoiceNinja Team', + 'email_from' => 'The Invoice Ninja Team', 'user_email_footer' => 'To adjust your email notification settings please visit '.SITE_URL.'/company/notifications', 'invoice_link_message' => 'To view your client invoice click the link below:', 'notification_invoice_paid_subject' => 'Invoice :invoice was paid by :client', diff --git a/resources/lang/nb_NO/texts.php b/resources/lang/nb_NO/texts.php index 04cb327a83..85be70b3cb 100644 --- a/resources/lang/nb_NO/texts.php +++ b/resources/lang/nb_NO/texts.php @@ -261,7 +261,7 @@ return array( 'payment_message' => 'Fakk for din betaling pålydende :amount.', 'email_salutation' => 'Kjære :name,', 'email_signature' => 'Med vennlig hilsen,', - 'email_from' => 'The InvoiceNinja Team', + 'email_from' => 'The Invoice Ninja Team', 'user_email_footer' => 'For å justere varslingsinnstillingene vennligst besøk '.SITE_URL.'/company/notifications', 'invoice_link_message' => 'Hvis du vil se din klientfaktura klikk på linken under:', 'notification_invoice_paid_subject' => 'Faktura :invoice betalt av :client', diff --git a/resources/views/accounts/nav_advanced.blade.php b/resources/views/accounts/nav_advanced.blade.php index 928462ca12..53979af666 100644 --- a/resources/views/accounts/nav_advanced.blade.php +++ b/resources/views/accounts/nav_advanced.blade.php @@ -9,7 +9,7 @@ @if (!Auth::user()->account->isPro())
{!! Former::text('email')->placeholder(trans('texts.email_address'))->raw() !!} diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index db77a4c96a..76c0bfa8c3 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -26,11 +26,13 @@