Client page color matches invoice design primary color

This commit is contained in:
Hillel Coren 2015-02-26 20:47:20 +02:00
parent fe2155e139
commit bf24e8c40f
10 changed files with 258 additions and 161 deletions

View File

@ -5,8 +5,8 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use ninja\mailers\ContactMailer as Mailer; use ninja\mailers\ContactMailer as Mailer;
class SendRecurringInvoices extends Command { class SendRecurringInvoices extends Command
{
protected $name = 'ninja:send-invoices'; protected $name = 'ninja:send-invoices';
protected $description = 'Send recurring invoices'; protected $description = 'Send recurring invoices';
protected $mailer; protected $mailer;
@ -20,36 +20,32 @@ class SendRecurringInvoices extends Command {
public function fire() public function fire()
{ {
$this->info(date('Y-m-d') . ' Running SendRecurringInvoices...'); $this->info(date('Y-m-d').' Running SendRecurringInvoices...');
$today = new DateTime(); $today = new DateTime();
$invoices = Invoice::with('account.timezone', 'invoice_items', 'client', 'user') $invoices = Invoice::with('account.timezone', 'invoice_items', 'client', 'user')
->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS TRUE AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))->get(); ->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS TRUE AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))->get();
$this->info(count($invoices) . ' recurring invoice(s) found'); $this->info(count($invoices).' recurring invoice(s) found');
foreach ($invoices as $recurInvoice) foreach ($invoices as $recurInvoice) {
{ if ($recurInvoice->client->deleted_at) {
if ($recurInvoice->client->deleted_at)
{
continue; continue;
} }
if (!$recurInvoice->user->confirmed) if (!$recurInvoice->user->confirmed) {
{
continue; continue;
} }
$this->info('Processing Invoice ' . $recurInvoice->id . ' - Should send ' . ($recurInvoice->shouldSendToday() ? 'YES' : 'NO')); $this->info('Processing Invoice '.$recurInvoice->id.' - Should send '.($recurInvoice->shouldSendToday() ? 'YES' : 'NO'));
if (!$recurInvoice->shouldSendToday()) if (!$recurInvoice->shouldSendToday()) {
{
continue; continue;
} }
$invoice = Invoice::createNew($recurInvoice); $invoice = Invoice::createNew($recurInvoice);
$invoice->client_id = $recurInvoice->client_id; $invoice->client_id = $recurInvoice->client_id;
$invoice->recurring_invoice_id = $recurInvoice->id; $invoice->recurring_invoice_id = $recurInvoice->id;
$invoice->invoice_number = 'R' . $recurInvoice->account->getNextInvoiceNumber(); $invoice->invoice_number = 'R'.$recurInvoice->account->getNextInvoiceNumber();
$invoice->amount = $recurInvoice->amount; $invoice->amount = $recurInvoice->amount;
$invoice->balance = $recurInvoice->amount; $invoice->balance = $recurInvoice->amount;
$invoice->invoice_date = date_create()->format('Y-m-d'); $invoice->invoice_date = date_create()->format('Y-m-d');
@ -66,15 +62,13 @@ class SendRecurringInvoices extends Command {
$invoice->custom_taxes2 = $recurInvoice->custom_taxes2; $invoice->custom_taxes2 = $recurInvoice->custom_taxes2;
$invoice->is_amount_discount = $recurInvoice->is_amount_discount; $invoice->is_amount_discount = $recurInvoice->is_amount_discount;
if ($invoice->client->payment_terms) if ($invoice->client->payment_terms) {
{ $invoice->due_date = date_create()->modify($invoice->client->payment_terms.' day')->format('Y-m-d');
$invoice->due_date = date_create()->modify($invoice->client->payment_terms . ' day')->format('Y-m-d');
} }
$invoice->save(); $invoice->save();
foreach ($recurInvoice->invoice_items as $recurItem) foreach ($recurInvoice->invoice_items as $recurItem) {
{
$item = InvoiceItem::createNew($recurItem); $item = InvoiceItem::createNew($recurItem);
$item->product_id = $recurItem->product_id; $item->product_id = $recurItem->product_id;
$item->qty = $recurItem->qty; $item->qty = $recurItem->qty;
@ -86,8 +80,7 @@ class SendRecurringInvoices extends Command {
$invoice->invoice_items()->save($item); $invoice->invoice_items()->save($item);
} }
foreach ($recurInvoice->invitations as $recurInvitation) foreach ($recurInvoice->invitations as $recurInvitation) {
{
$invitation = Invitation::createNew($recurInvitation); $invitation = Invitation::createNew($recurInvitation);
$invitation->contact_id = $recurInvitation->contact_id; $invitation->contact_id = $recurInvitation->contact_id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH); $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
@ -116,5 +109,4 @@ class SendRecurringInvoices extends Command {
//array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null), //array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
); );
} }
} }

View File

@ -46,7 +46,16 @@ class InvoiceController extends \BaseController
public function clientIndex() public function clientIndex()
{ {
$invitationKey = Session::get('invitation_key');
if (!$invitationKey) {
return Redirect::to('/setup');
}
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
$color = $invitation->account->primary_color ? $invitation->account->primary_color : '#0b4d78';
$data = [ $data = [
'color' => $color,
'hideLogo' => Session::get('white_label'), 'hideLogo' => Session::get('white_label'),
'title' => trans('texts.invoices'), 'title' => trans('texts.invoices'),
'entityType' => ENTITY_INVOICE, 'entityType' => ENTITY_INVOICE,

View File

@ -30,12 +30,23 @@ class PaymentController extends \BaseController
public function clientIndex() public function clientIndex()
{ {
return View::make('public_list', array( $invitationKey = Session::get('invitation_key');
if (!$invitationKey) {
return Redirect::to('/setup');
}
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
$color = $invitation->account->primary_color ? $invitation->account->primary_color : '#0b4d78';
$data = [
'color' => $color,
'hideLogo' => Session::get('white_label'), 'hideLogo' => Session::get('white_label'),
'entityType' => ENTITY_PAYMENT, 'entityType' => ENTITY_PAYMENT,
'title' => trans('texts.payments'), 'title' => trans('texts.payments'),
'columns' => Utils::trans(['invoice', 'transaction_reference', 'method', 'payment_amount', 'payment_date']), 'columns' => Utils::trans(['invoice', 'transaction_reference', 'method', 'payment_amount', 'payment_date'])
)); ];
return View::make('public_list', $data);
} }
public function getDatatable($clientPublicId = null) public function getDatatable($clientPublicId = null)

View File

@ -47,7 +47,16 @@ class QuoteController extends \BaseController
public function clientIndex() public function clientIndex()
{ {
$invitationKey = Session::get('invitation_key');
if (!$invitationKey) {
return Redirect::to('/setup');
}
$invitation = Invitation::with('account')->where('invitation_key', '=', $invitationKey)->first();
$color = $invitation->account->primary_color ? $invitation->account->primary_color : '#0b4d78';
$data = [ $data = [
'color' => $color,
'hideLogo' => Session::get('white_label'), 'hideLogo' => Session::get('white_label'),
'title' => trans('texts.quotes'), 'title' => trans('texts.quotes'),
'entityType' => ENTITY_QUOTE, 'entityType' => ENTITY_QUOTE,

View File

@ -12,7 +12,6 @@ class UserEventHandler
public function onSignup() public function onSignup()
{ {
} }
public function onLogin() public function onLogin()

View File

@ -17,6 +17,11 @@ class Invitation extends EntityModel
return $this->belongsTo('User')->withTrashed(); return $this->belongsTo('User')->withTrashed();
} }
public function account()
{
return $this->belongsTo('Account');
}
public function getLink() public function getLink()
{ {
return SITE_URL.'/view/'.$this->invitation_key; return SITE_URL.'/view/'.$this->invitation_key;

View File

@ -20,7 +20,7 @@
&nbsp;<label for="trashed" style="font-weight:normal; margin-left: 10px;"> &nbsp;<label for="trashed" style="font-weight:normal; margin-left: 10px;">
<input id="trashed" type="checkbox" onclick="setTrashVisible()" <input id="trashed" type="checkbox" onclick="setTrashVisible()"
{{ Session::get("show_trash:{$entityType}") ? 'checked' : ''}}/> {{ trans('texts.show_archived_deleted')}} {{ strtolower(trans('texts.'.$entityType.'s')) }} {{ Session::get("show_trash:{$entityType}") ? 'checked' : ''}}/>&nbsp; {{ trans('texts.show_archived_deleted')}} {{ strtolower(trans('texts.'.$entityType.'s')) }}
</label> </label>
<div id="top_right_buttons" class="pull-right"> <div id="top_right_buttons" class="pull-right">

View File

@ -15,6 +15,7 @@ body {
.container input[type=text], .container input[type=text],
.container input[type=email],
.container select { .container select {
font-weight: 300; font-weight: 300;
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
@ -145,13 +146,17 @@ header h3 em {
<div class="panel-body"> <div class="panel-body">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-7">
<header> <header>
@if ($client)
<h2>{{ $client->getDisplayName() }}</h2> <h2>{{ $client->getDisplayName() }}</h2>
<h3>{{ trans('texts.invoice') . ' ' . $invoiceNumber }}<span>|&nbsp; {{ trans('texts.amount_due') }}: <em>{{ Utils::formatMoney($amount, $currencyId) }}</em></span></h3> <h3>{{ trans('texts.invoice') . ' ' . $invoiceNumber }}<span>|&nbsp; {{ trans('texts.amount_due') }}: <em>{{ Utils::formatMoney($amount, $currencyId) }}</em></span></h3>
@elseif ($paymentTitle)
<h2>{{ $paymentTitle }}<br/><small>{{ $paymentSubtitle }}</small></h2>
@endif
</header> </header>
</div> </div>
<div class="col-md-6"> <div class="col-md-5">
@if (Request::secure() || Utils::isNinjaDev()) @if (Request::secure() || Utils::isNinjaDev())
<div class="secure"> <div class="secure">
<h3>{{ trans('texts.secure_payment') }}</h3> <h3>{{ trans('texts.secure_payment') }}</h3>
@ -254,7 +259,7 @@ header h3 em {
<div class="row" style="padding-top:18px"> <div class="row" style="padding-top:18px">
<div class="col-md-5"> <div class="col-md-5">
@if ($account->showTokenCheckbox()) @if ($client && $account->showTokenCheckbox())
<input id="token_billing" type="checkbox" name="token_billing" {{ $account->selectTokenCheckbox() ? 'CHECKED' : '' }} value="1" style="margin-left:0px; vertical-align:top"> <input id="token_billing" type="checkbox" name="token_billing" {{ $account->selectTokenCheckbox() ? 'CHECKED' : '' }} value="1" style="margin-left:0px; vertical-align:top">
<label for="token_billing" class="checkbox" style="display: inline;">{{ trans('texts.token_billing') }}</label> <label for="token_billing" class="checkbox" style="display: inline;">{{ trans('texts.token_billing') }}</label>
<span class="help-block" style="font-size:15px">{{ trans('texts.token_billing_secure', ['stripe_link' => link_to('https://stripe.com/', 'Stripe.com', ['target' => '_blank'])]) }}</span> <span class="help-block" style="font-size:15px">{{ trans('texts.token_billing_secure', ['stripe_link' => link_to('https://stripe.com/', 'Stripe.com', ['target' => '_blank'])]) }}</span>

View File

@ -2,32 +2,100 @@
@section('content') @section('content')
<section class="hero background hero-secure center" data-speed="2" data-type="background"> <style type="text/css">
<div class="container">
<div class="row">
<h1>License Key</h1>
<!--<p class="thin"><img src="{{ asset('images/icon-secure-pay.png') }}">256-BiT Encryption</p>-->
<!-- <img src="{{ asset('images/providers.png') }}"> -->
</div>
</div>
</section>
body {
background-color: #f8f8f8;
color: #1b1a1a;
}
.panel-body {
padding-bottom: 100px;
}
@media screen and (min-width: 700px) {
header {
margin: 20px 0 75px;
float: left;
}
.panel-body {
padding-left: 150px;
padding-right: 150px;
}
}
header {
margin: 0px !important
}
h2 {
font-weight: 300;
font-size: 30px;
color: #2e2b2b;
line-height: 1;
}
h3 {
font-weight: 900;
margin-top: 10px;
font-size: 15px;
}
h3 .help {
font-style: italic;
font-weight: normal;
color: #888888;
}
header h3 {
text-transform: uppercase;
}
header h3 span {
display: inline-block;
margin-left: 8px;
}
header h3 em {
font-style: normal;
color: #eb8039;
}
</style>
<div class="container">
<p>&nbsp;</p> <p>&nbsp;</p>
<section class="faq"> <div class="panel panel-default">
<div class="container"> <div class="panel-body">
<div class="row">
<div class="col-md-7">
<header>
<h2>License Key<br/><small>{{ $message }}</small></h2>
</header>
</div>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h3 style="text-align:center">{{ $message }}</h3>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2 style="text-align:center">{{ $license }}</h2> <h2 style="text-align:center">{{ $license }}</h2>
</div> </div>
</div> </div>
</div> </div>
</section> </div>
<p>&nbsp;</p> <div style="height:300px"></div>
</div>
@stop @stop

View File

@ -11,8 +11,7 @@
table.dataTable { border-radius: 3px; border-collapse: collapse; table.dataTable { border-radius: 3px; border-collapse: collapse;
/*border-spacing: 0;*/} /*border-spacing: 0;*/}
table.dataTable thead > tr > th, table.invoice-table thead > tr > th { table.dataTable thead > tr > th, table.invoice-table thead > tr > th {
background-color: #0b4d78 !important; background-color: {{ $color }} !important;
/*background-color: #e37329 !important;*/
color:#fff; color:#fff;
} }
th:first-child { th:first-child {
@ -68,8 +67,8 @@
max-width: 250px; max-width: 250px;
} }
.pagination>.active>a, .pagination>.active>span, .pagination>.active>a:hover, .pagination>.active>span:hover, .pagination>.active>a:focus, .pagination>.active>span:focus { .pagination>.active>a, .pagination>.active>span, .pagination>.active>a:hover, .pagination>.active>span:hover, .pagination>.active>a:focus, .pagination>.active>span:focus {
background-color: #0b4d78; background-color: {{ $color }};
border-color: #0b4d78; border-color: {{ $color }};
} }
.pagination>li:first-child>a, .pagination>li:first-child>span { .pagination>li:first-child>a, .pagination>li:first-child>span {
border-bottom-left-radius: 3px; border-bottom-left-radius: 3px;