mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on pro plan
This commit is contained in:
parent
c557276a6e
commit
3a50fd6aa2
@ -370,9 +370,9 @@ class AccountController extends \BaseController {
|
||||
$csv->heading = false;
|
||||
$csv->auto($name);
|
||||
|
||||
if (count($csv->data) + Client::scope()->count() > MAX_NUM_CLIENTS)
|
||||
if (count($csv->data) + Client::scope()->count() > Auth::user()->getMaxNumClients())
|
||||
{
|
||||
$message = Utils::pluralize('limit_clients', MAX_NUM_CLIENTS);
|
||||
$message = Utils::pluralize('limit_clients', Auth::user()->getMaxNumClients());
|
||||
Session::flash('error', $message);
|
||||
return Redirect::to('company/import_export');
|
||||
}
|
||||
|
@ -67,9 +67,9 @@ class ClientController extends \BaseController {
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
if (Client::scope()->count() > MAX_NUM_CLIENTS)
|
||||
if (Client::scope()->count() > Auth::user()->getMaxNumClients())
|
||||
{
|
||||
return View::make('error', ['error' => "Sorry, you've exceeded the limit of " . MAX_NUM_CLIENTS . " clients"]);
|
||||
return View::make('error', ['error' => "Sorry, you've exceeded the limit of " . Auth::user()->getMaxNumClients() . " clients"]);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
|
@ -142,6 +142,7 @@ class InvoiceController extends \BaseController {
|
||||
|
||||
$invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
|
||||
$invoice->due_date = Utils::fromSqlDate($invoice->due_date);
|
||||
$invoice->is_pro = $client->account->isPro();
|
||||
|
||||
$data = array(
|
||||
'showBreadcrumbs' => false,
|
||||
@ -162,6 +163,7 @@ class InvoiceController extends \BaseController {
|
||||
$invoice->due_date = Utils::fromSqlDate($invoice->due_date);
|
||||
$invoice->start_date = Utils::fromSqlDate($invoice->start_date);
|
||||
$invoice->end_date = Utils::fromSqlDate($invoice->end_date);
|
||||
$invoice->is_pro = Auth::user()->isPro();
|
||||
|
||||
$contactIds = DB::table('invitations')
|
||||
->join('contacts', 'contacts.id', '=','invitations.contact_id')
|
||||
|
@ -116,12 +116,10 @@ class PaymentController extends \BaseController
|
||||
$gateway->$function($val);
|
||||
}
|
||||
|
||||
/*
|
||||
if (!Utils::isProd())
|
||||
{
|
||||
$gateway->setTestMode(true);
|
||||
}
|
||||
*/
|
||||
|
||||
return $gateway;
|
||||
}
|
||||
@ -427,6 +425,13 @@ class PaymentController extends \BaseController
|
||||
|
||||
$payment->save();
|
||||
|
||||
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');
|
||||
$account->save();
|
||||
}
|
||||
|
||||
return $payment;
|
||||
}
|
||||
|
||||
|
@ -306,4 +306,9 @@ return array(
|
||||
'invoice_subject' => 'Neue Rechnung von :account',
|
||||
'close' => 'Schließen',
|
||||
|
||||
'pro_plan_product' => 'Pro Plan',
|
||||
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
|
||||
'pro_plan_succes' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
|
||||
|
||||
|
||||
);
|
||||
|
@ -307,7 +307,7 @@ return array(
|
||||
'password' => 'Password',
|
||||
|
||||
'pro_plan_product' => 'Pro Plan',
|
||||
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan',
|
||||
'pro_plan_succes' => 'Thanks for joining! Once the invoice is paid your membership will begin.',
|
||||
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
|
||||
'pro_plan_succes' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
|
||||
|
||||
);
|
||||
|
@ -305,5 +305,9 @@ return array(
|
||||
'erase_data' => 'This will permanently erase your data.',
|
||||
'password' => 'Password',
|
||||
|
||||
'pro_plan_product' => 'Pro Plan',
|
||||
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
|
||||
'pro_plan_succes' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
|
||||
|
||||
|
||||
);
|
||||
|
@ -306,5 +306,9 @@ return array(
|
||||
'erase_data' => 'This will permanently erase your data.',
|
||||
'password' => 'Password',
|
||||
|
||||
'pro_plan_product' => 'Pro Plan',
|
||||
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
|
||||
'pro_plan_succes' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
|
||||
|
||||
|
||||
);
|
||||
|
@ -306,5 +306,9 @@ return array(
|
||||
'erase_data' => 'Questo eliminerà definitivamente i tuoi dati.',
|
||||
'password' => 'Password',
|
||||
|
||||
'pro_plan_product' => 'Pro Plan',
|
||||
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
|
||||
'pro_plan_succes' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
|
||||
|
||||
|
||||
);
|
||||
|
@ -306,4 +306,9 @@ return array(
|
||||
'invoice_subject' => 'Nieuwe factuur van :account',
|
||||
'close' => 'Sluiten',
|
||||
|
||||
'pro_plan_product' => 'Pro Plan',
|
||||
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
|
||||
'pro_plan_succes' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
|
||||
|
||||
|
||||
);
|
||||
|
@ -293,4 +293,10 @@ return array(
|
||||
'close' => 'Fechar',
|
||||
'invoice_subject' => 'Nova fatura de :account',
|
||||
'payment_subject' => 'Recebido Pagamento de',
|
||||
|
||||
'pro_plan_product' => 'Pro Plan',
|
||||
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
|
||||
'pro_plan_succes' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
|
||||
|
||||
|
||||
);
|
||||
|
@ -220,11 +220,6 @@ class Account extends Eloquent
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Auth::check())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$datePaid = $this->pro_plan_paid;
|
||||
|
||||
if (!$datePaid || $datePaid == '0000-00-00')
|
||||
|
@ -133,4 +133,9 @@ class User extends ConfideUser implements UserInterface, RemindableInterface
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getMaxNumClients()
|
||||
{
|
||||
return $this->isPro() ? MAX_NUM_CLIENTS_PRO : MAX_NUM_CLIENTS;
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ use Auth;
|
||||
use Invitation;
|
||||
use Invoice;
|
||||
use InvoiceItem;
|
||||
use AccountGateway;
|
||||
|
||||
class AccountRepository
|
||||
{
|
||||
@ -104,19 +105,18 @@ class AccountRepository
|
||||
}
|
||||
|
||||
$account = Auth::user()->account;
|
||||
$lastInvoice = Invoice::withTrashed()->whereAccountId($account->id)->orderBy('public_id', 'DESC')->first();
|
||||
$publicId = $lastInvoice ? ($lastInvoice->public_id + 1) : 1;
|
||||
|
||||
$ninjaAccount = $this->getNinjaAccount();
|
||||
$ninjaAccount = $this->getNinjaAccount($publicId);
|
||||
$ninjaClient = $this->getNinjaClient($ninjaAccount);
|
||||
$invoice = $this->createNinjaInvoice($ninjaAccount, $ninjaClient);
|
||||
$invoice = $this->createNinjaInvoice($publicId, $ninjaAccount, $ninjaClient);
|
||||
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
private function createNinjaInvoice($account, $client)
|
||||
private function createNinjaInvoice($publicId, $account, $client)
|
||||
{
|
||||
$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;
|
||||
@ -150,7 +150,7 @@ class AccountRepository
|
||||
return $invoice;
|
||||
}
|
||||
|
||||
private function getNinjaAccount()
|
||||
private function getNinjaAccount($publicId)
|
||||
{
|
||||
$account = Account::whereAccountKey(NINJA_ACCOUNT_KEY)->first();
|
||||
|
||||
@ -168,7 +168,6 @@ class AccountRepository
|
||||
$account->save();
|
||||
|
||||
$random = str_random(RANDOM_KEY_LENGTH);
|
||||
|
||||
$user = new User();
|
||||
$user->registered = true;
|
||||
$user->confirmed = true;
|
||||
@ -181,6 +180,13 @@ class AccountRepository
|
||||
$user->notify_sent = false;
|
||||
$user->notify_paid = false;
|
||||
$account->users()->save($user);
|
||||
|
||||
$accountGateway = new AccountGateway();
|
||||
$accountGateway->user_id = $user->id;
|
||||
$accountGateway->gateway_id = NINJA_GATEWAY_ID;
|
||||
$accountGateway->public_id = $publicId;
|
||||
$accountGateway->config = isset($_ENV['NINJA_GATEWAY_CONFIG']) ? $_ENV['NINJA_GATEWAY_CONFIG'] : null;
|
||||
$account->account_gateways()->save($accountGateway);
|
||||
}
|
||||
|
||||
return $account;
|
||||
|
@ -200,6 +200,7 @@ define('RECENTLY_VIEWED_LIMIT', 8);
|
||||
define('LOGGED_ERROR_LIMIT', 100);
|
||||
define('RANDOM_KEY_LENGTH', 32);
|
||||
define('MAX_NUM_CLIENTS', 1000);
|
||||
define('MAX_NUM_CLIENTS_PRO', 5000);
|
||||
|
||||
define('INVOICE_STATUS_DRAFT', 1);
|
||||
define('INVOICE_STATUS_SENT', 2);
|
||||
@ -236,21 +237,27 @@ define('DEFAULT_LOCALE', 'en');
|
||||
define('RESULT_SUCCESS', 'success');
|
||||
define('RESULT_FAILURE', 'failure');
|
||||
|
||||
define('GATEWAY_PAYPAL_EXPRESS', 17);
|
||||
define('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
|
||||
define('PRO_PLAN_PRICE', 40);
|
||||
define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN');
|
||||
|
||||
define('PAYMENT_LIBRARY_OMNIPAY', 1);
|
||||
define('PAYMENT_LIBRARY_PHP_PAYMENTS', 2);
|
||||
|
||||
define('GATEWAY_PAYPAL_EXPRESS', 17);
|
||||
define('GATEWAY_BEANSTREAM', 29);
|
||||
define('GATEWAY_PSIGATE', 30);
|
||||
|
||||
define('PRO_PLAN_PRICE', 40);
|
||||
define('REQUESTED_PRO_PLAN', 'REQUESTED_PRO_PLAN');
|
||||
define('NINJA_ACCOUNT_KEY', 'zg4ylmzDkdkPOT8yoKQw9LTWaoZJx79h');
|
||||
define('NINJA_GATEWAY_ID', GATEWAY_PAYPAL_EXPRESS);
|
||||
|
||||
|
||||
/*
|
||||
define('GATEWAY_AMAZON', 30);
|
||||
define('GATEWAY_BLUEPAY', 31);
|
||||
define('GATEWAY_BRAINTREE', 32);
|
||||
define('GATEWAY_GOOGLE', 33);
|
||||
define('GATEWAY_PSIGATE', 34);
|
||||
define('GATEWAY_QUICKBOOKS', 35);
|
||||
*/
|
||||
|
||||
if (Auth::check() && !Session::has(SESSION_TIMEZONE))
|
||||
{
|
||||
|
@ -5,9 +5,6 @@
|
||||
|
||||
{{ Former::open()->addClass('col-md-8 col-md-offset-2') }}
|
||||
{{ Former::populate($account) }}
|
||||
{{ Former::populateField('notify_sent', intval(Auth::user()->notify_sent)) }}
|
||||
{{ Former::populateField('notify_viewed', intval(Auth::user()->notify_viewed)) }}
|
||||
{{ Former::populateField('notify_paid', intval(Auth::user()->notify_paid)) }}
|
||||
|
||||
{{ Former::legend('Payment Gateway') }}
|
||||
|
||||
@ -24,10 +21,9 @@
|
||||
@endif
|
||||
|
||||
<div class="two-column">
|
||||
{{ Former::radios('recommendedGateway_id')
|
||||
->label('Recommended Gateways')
|
||||
->radios($recommendedGateways)
|
||||
->class('recommended-gateway')}}
|
||||
{{ Former::radios('recommendedGateway_id')->label('Recommended Gateways')
|
||||
->radios($recommendedGateways)->class('recommended-gateway')
|
||||
}}
|
||||
</div>
|
||||
|
||||
{{ Former::select('gateway_id')->label('PayPal & Other Gateways')->addOption('', '')
|
||||
|
@ -633,6 +633,7 @@
|
||||
|
||||
function createInvoiceModel() {
|
||||
var invoice = ko.toJS(model).invoice;
|
||||
invoice.is_pro = {{ Auth::user()->isPro() }};
|
||||
|
||||
@if (file_exists($account->getLogoPath()))
|
||||
invoice.image = "{{ HTML::image_data($account->getLogoPath()) }}";
|
||||
@ -640,10 +641,6 @@
|
||||
invoice.imageHeight = {{ $account->getLogoHeight() }};
|
||||
@endif
|
||||
|
||||
|
||||
//define logo images
|
||||
|
||||
|
||||
invoice.imageLogo1 = "{{ HTML::image_data('images/report_logo1.jpg') }}";
|
||||
invoice.imageLogoWidth1 =120;
|
||||
invoice.imageLogoHeight1 = 40
|
||||
@ -1019,7 +1016,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
if (clients.length > {{ MAX_NUM_CLIENTS}})
|
||||
if (clients.length > {{ Auth::user()->getMaxNumClients() }})
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
@ -97,9 +97,10 @@ function GetReportTemplate4(doc, invoice, layout, checkMath) {
|
||||
var totalX = layout.headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize());
|
||||
doc.text(totalX, y, total);
|
||||
|
||||
|
||||
if (!invoice.is_pro) {
|
||||
doc.setFontType("normal");
|
||||
doc.text(layout.marginLeft, 790, "Created by InvoiceNinja.com");
|
||||
}
|
||||
|
||||
return doc;
|
||||
}
|
||||
@ -688,7 +689,7 @@ function GetReportTemplate1(doc, invoice, layout, checkMath)
|
||||
doc.addImage(invoice.image, 'JPEG', layout.marginLeft, 30);
|
||||
}
|
||||
|
||||
if (invoice.imageLogo1)
|
||||
if (!invoice.is_pro && invoice.imageLogo1)
|
||||
{
|
||||
pageHeight=820;
|
||||
y=pageHeight-invoice.imageLogoHeight1;
|
||||
@ -1043,7 +1044,7 @@ function Report2AddFooter (invoice,doc)
|
||||
doc.rect(x1, y1, w2, h2, 'FD');
|
||||
|
||||
|
||||
if (invoice.imageLogo2)
|
||||
if (!invoice.is_pro && invoice.imageLogo2)
|
||||
{
|
||||
pageHeight=820;
|
||||
var left = 250;//headerRight ;
|
||||
@ -1084,7 +1085,7 @@ function Report3AddFooter (invoice, account, doc, layout)
|
||||
doc.rect(x1, y1, w2, h2, 'FD');
|
||||
|
||||
|
||||
if (invoice.imageLogo3)
|
||||
if (!invoice.is_pro && invoice.imageLogo3)
|
||||
{
|
||||
pageHeight=820;
|
||||
// var left = 25;//250;//headerRight ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user