1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

bug fixes

This commit is contained in:
Hillel Coren 2014-01-12 18:55:33 +00:00
parent a57a4fcfc1
commit 4731536311
18 changed files with 98 additions and 63 deletions

View File

@ -1,7 +1,7 @@
# Invoice Ninja # Invoice Ninja
## Simple, Intuitive Invoicing ## Simple, Intuitive Invoicing
### Live demo: [http://www.invoiceninja.com](http://www.invoiceninja.com) ### [http://www.invoiceninja.com](http://www.invoiceninja.com)
### Introduction ### Introduction
Most online invoicing sites are expensive. They shouldn't be. The aim of this project is to provide a free, open-source alternative. Additionally, the hope is this codebase will serve as a sample site for Laravel as well as other JavaScript technologies. Most online invoicing sites are expensive. They shouldn't be. The aim of this project is to provide a free, open-source alternative. Additionally, the hope is this codebase will serve as a sample site for Laravel as well as other JavaScript technologies.

View File

@ -201,7 +201,7 @@ class AccountController extends \BaseController {
$count = 0; $count = 0;
$hasHeaders = Input::get('header_checkbox'); $hasHeaders = Input::get('header_checkbox');
$countries = Country::all(); $countries = Country::remember(DEFAULT_QUERY_CACHE)->all();
$countryMap = []; $countryMap = [];
foreach ($countries as $country) { foreach ($countries as $country) {
$countryMap[strtolower($country->name)] = $country->id; $countryMap[strtolower($country->name)] = $country->id;

View File

@ -131,8 +131,11 @@ class CreditController extends \BaseController {
$ids = Input::get('id') ? Input::get('id') : Input::get('ids'); $ids = Input::get('id') ? Input::get('id') : Input::get('ids');
$count = $this->creditRepo->bulk($ids, $action); $count = $this->creditRepo->bulk($ids, $action);
if ($count > 0)
{
$message = Utils::pluralize('Successfully '.$action.'d ? credit', $count); $message = Utils::pluralize('Successfully '.$action.'d ? credit', $count);
Session::flash('message', $message); Session::flash('message', $message);
}
return Redirect::to('credits'); return Redirect::to('credits');
} }

View File

@ -500,21 +500,13 @@ class InvoiceController extends \BaseController {
{ {
$action = Input::get('action'); $action = Input::get('action');
$ids = Input::get('id') ? Input::get('id') : Input::get('ids'); $ids = Input::get('id') ? Input::get('id') : Input::get('ids');
$invoices = Invoice::scope($ids)->get(); $count = $this->invoiceRepo->bulk($ids, $action);
foreach ($invoices as $invoice) if ($count > 0)
{ {
if ($action == 'delete') $message = Utils::pluralize('Successfully '.$action.'d ? invoice', $count);
{
$invoice->is_deleted = true;
$invoice->save();
}
$invoice->delete();
}
$message = Utils::pluralize('Successfully '.$action.'d ? invoice', count($invoices));
Session::flash('message', $message); Session::flash('message', $message);
}
return Redirect::to('invoices'); return Redirect::to('invoices');
} }

View File

@ -132,8 +132,11 @@ class PaymentController extends \BaseController
$ids = Input::get('id') ? Input::get('id') : Input::get('ids'); $ids = Input::get('id') ? Input::get('id') : Input::get('ids');
$count = $this->paymentRepo->bulk($ids, $action); $count = $this->paymentRepo->bulk($ids, $action);
if ($count > 0)
{
$message = Utils::pluralize('Successfully '.$action.'d ? payment', count($payments)); $message = Utils::pluralize('Successfully '.$action.'d ? payment', count($payments));
Session::flash('message', $message); Session::flash('message', $message);
}
return Redirect::to('payments'); return Redirect::to('payments');
} }

View File

@ -90,9 +90,9 @@ class UserController extends BaseController {
public function do_login() public function do_login()
{ {
$input = array( $input = array(
'email' => Input::get( 'email' ), // May be the username too 'email' => Input::get( 'login_email' ), // May be the username too
'username' => Input::get( 'email' ), // so we have to pass both 'username' => Input::get( 'login_email' ), // so we have to pass both
'password' => Input::get( 'password' ), 'password' => Input::get( 'login_password' ),
'remember' => true, 'remember' => true,
); );
@ -100,7 +100,7 @@ class UserController extends BaseController {
// with the second parameter as true. // with the second parameter as true.
// logAttempt will check if the 'email' perhaps is the username. // logAttempt will check if the 'email' perhaps is the username.
// Get the value from the config file instead of changing the controller // Get the value from the config file instead of changing the controller
if ( Confide::logAttempt( $input, Config::get('confide::signup_confirm') ) ) if ( Confide::logAttempt( $input, false ) )
{ {
Event::fire('user.login'); Event::fire('user.login');
// Redirect the user to the URL they were trying to access before // Redirect the user to the URL they were trying to access before
@ -130,7 +130,7 @@ class UserController extends BaseController {
} }
return Redirect::action('UserController@login') return Redirect::action('UserController@login')
->withInput(Input::except('password')) ->withInput(Input::except('login_password'))
->with( 'error', $err_msg ); ->with( 'error', $err_msg );
} }
} }

View File

@ -145,7 +145,6 @@ class Activity extends Eloquent
$client->save(); $client->save();
} }
$userName = Auth::check() ? Auth::user()->getFullName() : '<i>System</i>';
$activity = Activity::getBlank($invitation); $activity = Activity::getBlank($invitation);
$activity->client_id = $invitation->invoice->client_id; $activity->client_id = $invitation->invoice->client_id;
$activity->invoice_id = $invitation->invoice_id; $activity->invoice_id = $invitation->invoice_id;

View File

@ -33,28 +33,26 @@ class Contact extends EntityModel
public function getDisplayName() public function getDisplayName()
{ {
if (!$this->first_name && !$this->last_name) if ($this->getFullName())
{ {
return $this->email; return $this->getFullName();
} }
else else
{ {
return $this->getFullName(); return $this->email;
} }
} }
public function getFullName() public function getFullName()
{ {
$fullName = $this->first_name . ' ' . $this->last_name; if ($this->first_name || $this->last_name)
if ($fullName == ' ')
{ {
return ''; return $this->first_name . ' ' . $this->last_name;
} }
else else
{ {
return $fullName; return '';
} }
} }

View File

@ -71,28 +71,30 @@ class User extends ConfideUser implements UserInterface, RemindableInterface
public function getDisplayName() public function getDisplayName()
{ {
if (!$this->first_name && !$this->last_name) if ($this->getFullName())
{
return $this->getFullName();
}
else if ($this->email)
{ {
return $this->email; return $this->email;
} }
else else
{ {
return $this->getFullName(); return 'Guest';
}
} }
}
public function getFullName() public function getFullName()
{ {
$fullName = $this->first_name . ' ' . $this->last_name; if ($this->first_name || $this->last_name)
if ($fullName == ' ')
{ {
return "Guest"; return $this->first_name . ' ' . $this->last_name;
} }
else else
{ {
return $fullName; return '';
} }
} }

View File

@ -57,6 +57,11 @@ class CreditRepository
public function bulk($ids, $action) public function bulk($ids, $action)
{ {
if (!$ids)
{
return 0;
}
$credits = Credit::scope($ids)->get(); $credits = Credit::scope($ids)->get();
foreach ($credits as $credit) foreach ($credits as $credit)

View File

@ -200,4 +200,27 @@ class InvoiceRepository
return $invoice; return $invoice;
} }
public function bulk($ids, $action)
{
if (!$ids)
{
return 0;
}
$invoices = Invoice::scope($ids)->get();
foreach ($invoices as $invoice)
{
if ($action == 'delete')
{
$invoice->is_deleted = true;
$invoice->save();
}
$invoice->delete();
}
return count($invoices);
}
} }

View File

@ -58,6 +58,11 @@ class PaymentRepository
public function bulk($ids, $action) public function bulk($ids, $action)
{ {
if (!$ids)
{
return 0;
}
$payments = Payment::scope($ids)->get(); $payments = Payment::scope($ids)->get();
foreach ($payments as $payment) foreach ($payments as $payment)

View File

@ -22,9 +22,6 @@
//Log::error('test'); //Log::error('test');
/*
Event::listen('illuminate.query', function($query, $bindings, $time, $name) Event::listen('illuminate.query', function($query, $bindings, $time, $name)
{ {
$data = compact('bindings', 'time', 'name'); $data = compact('bindings', 'time', 'name');
@ -48,7 +45,7 @@ Event::listen('illuminate.query', function($query, $bindings, $time, $name)
Log::info($query, $data); Log::info($query, $data);
}); });
*/
/* /*
Route::get('/test', function() { Route::get('/test', function() {

View File

@ -300,7 +300,7 @@
$('.signUpForm').submit(); $('.signUpForm').submit();
} else { } else {
$('#errorTaken').show(); $('#errorTaken').show();
$('form.signUpForm #email').closest('div.form-group').removeClass('has-success').addClass('has-error'); $('form.signUpForm #new_email').closest('div.form-group').removeClass('has-success').addClass('has-error');
$('#signUpDiv, #signUpFooter').show(); $('#signUpDiv, #signUpFooter').show();
$('#working').hide(); $('#working').hide();
} }

View File

@ -191,8 +191,8 @@
<div style="display:none"> <div style="display:none">
{{ Former::text('action') }} {{ Former::text('action') }}
@if ($invoice) @if ($invoice)
{{ Former::populateField('id', $invoice->public_id) }}
{{ Former::text('id') }} {{ Former::text('id') }}
{{ Former::populateField('id', $invoice->id) }}
@endif @endif
</div> </div>

View File

@ -14,10 +14,10 @@
<div class="navbar-collapse collapse"> <div class="navbar-collapse collapse">
{{ Form::open(array('url' => 'login', 'class' => 'navbar-form navbar-right')) }} {{ Form::open(array('url' => 'login', 'class' => 'navbar-form navbar-right')) }}
<div class="form-group"> <div class="form-group">
{{ Form::text('email', Input::old('email'), array('placeholder' => 'Email')) }} {{ Form::text('login_email', Input::old('login_email'), array('placeholder' => 'Email')) }}
</div> </div>
<div class="form-group"> <div class="form-group">
{{ Form::password('password', array('placeholder' => 'Password')) }} {{ Form::password('login_password', array('placeholder' => 'Password')) }}
</div> </div>
<button type="submit" class="btn btn-success">Sign in</button> <button type="submit" class="btn btn-success">Sign in</button>
{{ Form::close() }} {{ Form::close() }}

View File

@ -54,13 +54,13 @@
<h2 class="form-signin-heading">Please sign in</h2> <h2 class="form-signin-heading">Please sign in</h2>
<p> <p>
{{ $errors->first('email') }} {{ $errors->first('login_email') }}
{{ $errors->first('password') }} {{ $errors->first('login_password') }}
</p> </p>
<p> <p>
{{ Form::text('email', Input::old('email'), array('placeholder' => 'Email address')) }} {{ Form::text('login_email', Input::old('login_email'), array('placeholder' => 'Email address')) }}
{{ Form::password('password', array('placeholder' => 'Password')) }} {{ Form::password('login_password', array('placeholder' => 'Password')) }}
</p> </p>
<p>{{ Button::primary_submit('Sign In', array('class' => 'btn-lg'))->block() }}</p> <p>{{ Button::primary_submit('Sign In', array('class' => 'btn-lg'))->block() }}</p>

View File

@ -13,7 +13,7 @@ function generatePDF(invoice, checkMath) {
var invoiceDate = invoice.invoice_date ? invoice.invoice_date : ''; var invoiceDate = invoice.invoice_date ? invoice.invoice_date : '';
var dueDate = invoice.due_date ? invoice.due_date : ''; var dueDate = invoice.due_date ? invoice.due_date : '';
var marginLeft = 90; var marginLeft = 60;
var accountTop = 30; var accountTop = 30;
var headerTop = 140; var headerTop = 140;
var headerLeft = 360; var headerLeft = 360;
@ -55,7 +55,8 @@ function generatePDF(invoice, checkMath) {
if (invoice.image) if (invoice.image)
{ {
doc.addImage(invoice.image, 'JPEG', 30, 30, invoice.imageWidth, invoice.imageHeight); var left = headerRight - invoice.imageWidth;
doc.addImage(invoice.image, 'JPEG', left, 30, invoice.imageWidth, invoice.imageHeight);
} }
/* table header */ /* table header */
@ -81,7 +82,7 @@ function generatePDF(invoice, checkMath) {
doc.setFontType("normal"); doc.setFontType("normal");
var y = accountTop; var y = accountTop;
var left = headerLeft; var left = marginLeft;
if (account.name) { if (account.name) {
y += rowHeight; y += rowHeight;
@ -149,6 +150,11 @@ function generatePDF(invoice, checkMath) {
doc.setFontType("bold"); doc.setFontType("bold");
doc.text(headerLeft, headerY, 'Amount Due'); doc.text(headerLeft, headerY, 'Amount Due');
var balance = formatMoney(invoice.balance, currencyId, true);
balanceX = headerRight - (doc.getStringUnitWidth(balance) * doc.internal.getFontSize());
doc.text(balanceX, headerY, balance);
doc.setDrawColor(200,200,200); doc.setDrawColor(200,200,200);
doc.setFillColor(230,230,230); doc.setFillColor(230,230,230);
doc.rect(tableLeft - tablePadding, tableTop - 12, headerRight - tableLeft + 12, rowHeight + 2, 'FD'); doc.rect(tableLeft - tablePadding, tableTop - 12, headerRight - tableLeft + 12, rowHeight + 2, 'FD');
@ -174,7 +180,6 @@ function generatePDF(invoice, checkMath) {
var line = 1; var line = 1;
var total = 0; var total = 0;
var shownItem = false; var shownItem = false;
doc.setDrawColor(220,220,220);
for (var i=0; i<invoice.invoice_items.length; i++) { for (var i=0; i<invoice.invoice_items.length; i++) {
var item = invoice.invoice_items[i]; var item = invoice.invoice_items[i];
@ -225,14 +230,20 @@ function generatePDF(invoice, checkMath) {
doc.text(taxX, x, tax+'%'); doc.text(taxX, x, tax+'%');
} }
line += doc.splitTextToSize(item.notes, 200).length; line += (doc.splitTextToSize(item.notes, 200).length * .6) + .4;
if (i < invoice.invoice_items.length - 2) { if (i < invoice.invoice_items.length - 2) {
doc.setLineWidth(0.5); doc.setLineWidth(0.5);
doc.setDrawColor(220,220,220);
doc.line(tableLeft - tablePadding, tableTop + (line * tableRowHeight) - 8, doc.line(tableLeft - tablePadding, tableTop + (line * tableRowHeight) - 8,
lineTotalRight+tablePadding, tableTop + (line * tableRowHeight) - 8); lineTotalRight+tablePadding, tableTop + (line * tableRowHeight) - 8);
} }
if (line > 20) {
line = 0;
tableTop = 60;
doc.addPage();
}
} }
/* table footer */ /* table footer */
@ -304,9 +315,6 @@ function generatePDF(invoice, checkMath) {
var totalX = headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize()); var totalX = headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize());
doc.text(totalX, x, total); doc.text(totalX, x, total);
totalX = headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize());
doc.text(totalX, headerY, total);
/* payment stub */ /* payment stub */