1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00
Merged from parent.
This commit is contained in:
blkmutt 2014-04-13 21:55:40 -04:00
commit 55d1ec415c
19 changed files with 104 additions and 62 deletions

View File

@ -370,9 +370,9 @@ class AccountController extends \BaseController {
$csv->heading = false; $csv->heading = false;
$csv->auto($name); $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); Session::flash('error', $message);
return Redirect::to('company/import_export'); return Redirect::to('company/import_export');
} }

View File

@ -67,9 +67,9 @@ class ClientController extends \BaseController {
*/ */
public function create() 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( $data = array(

View File

@ -142,6 +142,7 @@ class InvoiceController extends \BaseController {
$invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date); $invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
$invoice->due_date = Utils::fromSqlDate($invoice->due_date); $invoice->due_date = Utils::fromSqlDate($invoice->due_date);
$invoice->is_pro = $client->account->isPro();
$data = array( $data = array(
'showBreadcrumbs' => false, 'showBreadcrumbs' => false,
@ -162,6 +163,7 @@ class InvoiceController extends \BaseController {
$invoice->due_date = Utils::fromSqlDate($invoice->due_date); $invoice->due_date = Utils::fromSqlDate($invoice->due_date);
$invoice->start_date = Utils::fromSqlDate($invoice->start_date); $invoice->start_date = Utils::fromSqlDate($invoice->start_date);
$invoice->end_date = Utils::fromSqlDate($invoice->end_date); $invoice->end_date = Utils::fromSqlDate($invoice->end_date);
$invoice->is_pro = Auth::user()->isPro();
$contactIds = DB::table('invitations') $contactIds = DB::table('invitations')
->join('contacts', 'contacts.id', '=','invitations.contact_id') ->join('contacts', 'contacts.id', '=','invitations.contact_id')

View File

@ -116,12 +116,10 @@ class PaymentController extends \BaseController
$gateway->$function($val); $gateway->$function($val);
} }
/*
if (!Utils::isProd()) if (!Utils::isProd())
{ {
$gateway->setTestMode(true); $gateway->setTestMode(true);
} }
*/
return $gateway; return $gateway;
} }
@ -427,6 +425,13 @@ class PaymentController extends \BaseController
$payment->save(); $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; return $payment;
} }

View File

@ -193,7 +193,7 @@ class UserController extends BaseController {
if ($invoice = $this->accountRepo->enableProPlan()) if ($invoice = $this->accountRepo->enableProPlan())
{ {
$this->contactMailer->sendInvoice($invoice); $this->contactMailer->sendInvoice($invoice);
$notice_msg = trans('texts.pro_plan_succes'); $notice_msg = trans('texts.pro_plan_success');
} }
} }

View File

@ -305,5 +305,10 @@ return array(
'password' => 'Passwort', 'password' => 'Passwort',
'invoice_subject' => 'Neue Rechnung von :account', 'invoice_subject' => 'Neue Rechnung von :account',
'close' => 'Schließen', 'close' => 'Schließen',
'pro_plan_product' => 'Pro Plan',
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
); );

View File

@ -307,7 +307,7 @@ return array(
'password' => 'Password', 'password' => 'Password',
'pro_plan_product' => 'Pro Plan', 'pro_plan_product' => 'Pro Plan',
'pro_plan_description' => 'One year enrollment in the Invoice Ninja 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_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
); );

View File

@ -305,5 +305,9 @@ return array(
'erase_data' => 'This will permanently erase your data.', 'erase_data' => 'This will permanently erase your data.',
'password' => 'Password', 'password' => 'Password',
'pro_plan_product' => 'Pro Plan',
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
); );

View File

@ -102,25 +102,25 @@ return array(
'no_items' => 'Aucun élément', 'no_items' => 'Aucun élément',
// recurring invoices // recurring invoices
'recurring_invoices' => 'Recurring Invoices', 'recurring_invoices' => 'Factures récurrentes',
'recurring_help' => '<p>Automatically send clients the same invoices weekly, bi-monthly, monthly, quarterly or annually. </p> 'recurring_help' => '<p>Envoyer automatiquement la même facture à vos clients de façon hebdomadaire, bimensuelle, mensuelle, trimestrielle ou annuelle.</p>
<p>Use :MONTH, :QUARTER or :YEAR for dynamic dates. Basic math works as well, for example :MONTH-1.</p> <p>Utiliser :MONTH, :QUARTER ou :YEAR pour des dates dynamiques. Les opérations simples fonctionnent également, par exemple :MONTH-1.</p>
<p>Examples of dynamic invoice variables:</p> <p>Exemples de variables dynamiques pour les factures:</p>
<ul> <ul>
<li>"Gym membership for the month of :MONTH" => "Gym membership for the month of July"</li> <li>"Adhésion au club de gym pour le mois de :MONTH" => "Adhésion au club de gym pour le mois de Juillet"</li>
<li>":YEAR+1 yearly subscription" => "2015 Yearly Subscription"</li> <li>":YEAR+1 - abonnement annuel" => "2015 - abonnement annuel"</li>
<li>"Retainer payment for :QUARTER+1" => "Retainer payment for Q2"</li> <li>"Acompte pour le :QUARTER+1" => "Acompte pour le Q2"</li>
</ul>', </ul>',
// dashboard // dashboard
'in_total_revenue' => 'in total revenue', 'in_total_revenue' => 'de bénéfice total',
'billed_client' => 'billed client', 'billed_client' => 'client facturé',
'billed_clients' => 'billed clients', 'billed_clients' => 'clients facturés',
'active_client' => 'active client', 'active_client' => 'client actif',
'active_clients' => 'active clients', 'active_clients' => 'clients actifs',
'invoices_past_due' => 'Invoices Past Due', 'invoices_past_due' => 'Date limite de paiement dépassée',
'upcoming_invoices' => 'Upcoming invoices', 'upcoming_invoices' => 'Factures à venir',
'average_invoice' => 'Average invoice', 'average_invoice' => 'Moyenne de facturation',
// list pages // list pages
'archive' => 'Archive', 'archive' => 'Archive',
@ -305,6 +305,10 @@ return array(
'success_message' => 'You have succesfully registered. Please visit the link in the account confirmation email to verify your email address.', 'success_message' => 'You have succesfully registered. Please visit the link in the account confirmation email to verify your email address.',
'erase_data' => 'This will permanently erase your data.', 'erase_data' => 'This will permanently erase your data.',
'password' => 'Password', 'password' => 'Password',
'pro_plan_product' => 'Pro Plan',
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
); );

View File

@ -306,5 +306,9 @@ return array(
'erase_data' => 'Questo eliminerà definitivamente i tuoi dati.', 'erase_data' => 'Questo eliminerà definitivamente i tuoi dati.',
'password' => 'Password', 'password' => 'Password',
'pro_plan_product' => 'Pro Plan',
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
); );

View File

@ -305,5 +305,10 @@ return array(
'password' => 'Wachtwoord', 'password' => 'Wachtwoord',
'invoice_subject' => 'Nieuwe factuur van :account', 'invoice_subject' => 'Nieuwe factuur van :account',
'close' => 'Sluiten', 'close' => 'Sluiten',
'pro_plan_product' => 'Pro Plan',
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
); );

View File

@ -293,4 +293,10 @@ return array(
'close' => 'Fechar', 'close' => 'Fechar',
'invoice_subject' => 'Nova fatura de :account', 'invoice_subject' => 'Nova fatura de :account',
'payment_subject' => 'Recebido Pagamento de', 'payment_subject' => 'Recebido Pagamento de',
'pro_plan_product' => 'Pro Plan',
'pro_plan_description' => 'One year enrollment in the Invoice Ninja Pro Plan.',
'pro_plan_success' => 'Thanks for joining! Once the invoice is paid your Pro Plan membership will begin.',
); );

View File

@ -220,11 +220,6 @@ class Account extends Eloquent
return true; return true;
} }
if (!Auth::check())
{
return false;
}
$datePaid = $this->pro_plan_paid; $datePaid = $this->pro_plan_paid;
if (!$datePaid || $datePaid == '0000-00-00') if (!$datePaid || $datePaid == '0000-00-00')

View File

@ -133,4 +133,9 @@ class User extends ConfideUser implements UserInterface, RemindableInterface
return true; return true;
} }
} }
public function getMaxNumClients()
{
return $this->isPro() ? MAX_NUM_CLIENTS_PRO : MAX_NUM_CLIENTS;
}
} }

View File

@ -11,6 +11,7 @@ use Auth;
use Invitation; use Invitation;
use Invoice; use Invoice;
use InvoiceItem; use InvoiceItem;
use AccountGateway;
class AccountRepository class AccountRepository
{ {
@ -104,19 +105,18 @@ class AccountRepository
} }
$account = Auth::user()->account; $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); $ninjaClient = $this->getNinjaClient($ninjaAccount);
$invoice = $this->createNinjaInvoice($ninjaAccount, $ninjaClient); $invoice = $this->createNinjaInvoice($publicId, $ninjaAccount, $ninjaClient);
return $invoice; 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 = new Invoice();
$invoice->account_id = $account->id; $invoice->account_id = $account->id;
$invoice->user_id = $account->users()->first()->id; $invoice->user_id = $account->users()->first()->id;
@ -150,7 +150,7 @@ class AccountRepository
return $invoice; return $invoice;
} }
private function getNinjaAccount() private function getNinjaAccount($publicId)
{ {
$account = Account::whereAccountKey(NINJA_ACCOUNT_KEY)->first(); $account = Account::whereAccountKey(NINJA_ACCOUNT_KEY)->first();
@ -168,7 +168,6 @@ class AccountRepository
$account->save(); $account->save();
$random = str_random(RANDOM_KEY_LENGTH); $random = str_random(RANDOM_KEY_LENGTH);
$user = new User(); $user = new User();
$user->registered = true; $user->registered = true;
$user->confirmed = true; $user->confirmed = true;
@ -181,6 +180,13 @@ class AccountRepository
$user->notify_sent = false; $user->notify_sent = false;
$user->notify_paid = false; $user->notify_paid = false;
$account->users()->save($user); $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; return $account;

View File

@ -200,6 +200,7 @@ define('RECENTLY_VIEWED_LIMIT', 8);
define('LOGGED_ERROR_LIMIT', 100); define('LOGGED_ERROR_LIMIT', 100);
define('RANDOM_KEY_LENGTH', 32); define('RANDOM_KEY_LENGTH', 32);
define('MAX_NUM_CLIENTS', 1000); define('MAX_NUM_CLIENTS', 1000);
define('MAX_NUM_CLIENTS_PRO', 5000);
define('INVOICE_STATUS_DRAFT', 1); define('INVOICE_STATUS_DRAFT', 1);
define('INVOICE_STATUS_SENT', 2); define('INVOICE_STATUS_SENT', 2);
@ -236,21 +237,27 @@ define('DEFAULT_LOCALE', 'en');
define('RESULT_SUCCESS', 'success'); define('RESULT_SUCCESS', 'success');
define('RESULT_FAILURE', 'failure'); 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_OMNIPAY', 1);
define('PAYMENT_LIBRARY_PHP_PAYMENTS', 2); define('PAYMENT_LIBRARY_PHP_PAYMENTS', 2);
define('GATEWAY_PAYPAL_EXPRESS', 17);
define('GATEWAY_BEANSTREAM', 29); 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_AMAZON', 30);
define('GATEWAY_BLUEPAY', 31); define('GATEWAY_BLUEPAY', 31);
define('GATEWAY_BRAINTREE', 32); define('GATEWAY_BRAINTREE', 32);
define('GATEWAY_GOOGLE', 33); define('GATEWAY_GOOGLE', 33);
define('GATEWAY_PSIGATE', 34);
define('GATEWAY_QUICKBOOKS', 35); define('GATEWAY_QUICKBOOKS', 35);
*/
if (Auth::check() && !Session::has(SESSION_TIMEZONE)) if (Auth::check() && !Session::has(SESSION_TIMEZONE))
{ {

View File

@ -5,9 +5,6 @@
{{ Former::open()->addClass('col-md-8 col-md-offset-2') }} {{ Former::open()->addClass('col-md-8 col-md-offset-2') }}
{{ Former::populate($account) }} {{ 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') }} {{ Former::legend('Payment Gateway') }}
@ -24,10 +21,9 @@
@endif @endif
<div class="two-column"> <div class="two-column">
{{ Former::radios('recommendedGateway_id') {{ Former::radios('recommendedGateway_id')->label('Recommended Gateways')
->label('Recommended Gateways') ->radios($recommendedGateways)->class('recommended-gateway')
->radios($recommendedGateways) }}
->class('recommended-gateway')}}
</div> </div>
{{ Former::select('gateway_id')->label('PayPal & Other Gateways')->addOption('', '') {{ Former::select('gateway_id')->label('PayPal & Other Gateways')->addOption('', '')

View File

@ -633,17 +633,14 @@
function createInvoiceModel() { function createInvoiceModel() {
var invoice = ko.toJS(model).invoice; var invoice = ko.toJS(model).invoice;
invoice.is_pro = {{ Auth::user()->isPro() }};
@if (file_exists($account->getLogoPath())) @if (file_exists($account->getLogoPath()))
invoice.image = "{{ HTML::image_data($account->getLogoPath()) }}"; invoice.image = "{{ HTML::image_data($account->getLogoPath()) }}";
invoice.imageWidth = {{ $account->getLogoWidth() }}; invoice.imageWidth = {{ $account->getLogoWidth() }};
invoice.imageHeight = {{ $account->getLogoHeight() }}; invoice.imageHeight = {{ $account->getLogoHeight() }};
@endif @endif
//define logo images
invoice.imageLogo1 = "{{ HTML::image_data('images/report_logo1.jpg') }}"; invoice.imageLogo1 = "{{ HTML::image_data('images/report_logo1.jpg') }}";
invoice.imageLogoWidth1 =120; invoice.imageLogoWidth1 =120;
invoice.imageLogoHeight1 = 40 invoice.imageLogoHeight1 = 40
@ -1019,7 +1016,7 @@
} }
else else
{ {
if (clients.length > {{ MAX_NUM_CLIENTS}}) if (clients.length > {{ Auth::user()->getMaxNumClients() }})
{ {
return ''; return '';
} }

View File

@ -97,9 +97,10 @@ function GetReportTemplate4(doc, invoice, layout, checkMath) {
var totalX = layout.headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize()); var totalX = layout.headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize());
doc.text(totalX, y, total); doc.text(totalX, y, total);
if (!invoice.is_pro) {
doc.setFontType("normal"); doc.setFontType("normal");
doc.text(layout.marginLeft, 790, "Created by InvoiceNinja.com"); doc.text(layout.marginLeft, 790, "Created by InvoiceNinja.com");
}
return doc; return doc;
} }
@ -688,7 +689,7 @@ function GetReportTemplate1(doc, invoice, layout, checkMath)
doc.addImage(invoice.image, 'JPEG', layout.marginLeft, 30); doc.addImage(invoice.image, 'JPEG', layout.marginLeft, 30);
} }
if (invoice.imageLogo1) if (!invoice.is_pro && invoice.imageLogo1)
{ {
pageHeight=820; pageHeight=820;
y=pageHeight-invoice.imageLogoHeight1; y=pageHeight-invoice.imageLogoHeight1;
@ -1043,7 +1044,7 @@ function Report2AddFooter (invoice,doc)
doc.rect(x1, y1, w2, h2, 'FD'); doc.rect(x1, y1, w2, h2, 'FD');
if (invoice.imageLogo2) if (!invoice.is_pro && invoice.imageLogo2)
{ {
pageHeight=820; pageHeight=820;
var left = 250;//headerRight ; var left = 250;//headerRight ;
@ -1084,7 +1085,7 @@ function Report3AddFooter (invoice, account, doc, layout)
doc.rect(x1, y1, w2, h2, 'FD'); doc.rect(x1, y1, w2, h2, 'FD');
if (invoice.imageLogo3) if (!invoice.is_pro && invoice.imageLogo3)
{ {
pageHeight=820; pageHeight=820;
// var left = 25;//250;//headerRight ; // var left = 25;//250;//headerRight ;