1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +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
## Simple, Intuitive Invoicing
### Live demo: [http://www.invoiceninja.com](http://www.invoiceninja.com)
### [http://www.invoiceninja.com](http://www.invoiceninja.com)
### 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.

View File

@ -201,7 +201,7 @@ class AccountController extends \BaseController {
$count = 0;
$hasHeaders = Input::get('header_checkbox');
$countries = Country::all();
$countries = Country::remember(DEFAULT_QUERY_CACHE)->all();
$countryMap = [];
foreach ($countries as $country) {
$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');
$count = $this->creditRepo->bulk($ids, $action);
$message = Utils::pluralize('Successfully '.$action.'d ? credit', $count);
Session::flash('message', $message);
if ($count > 0)
{
$message = Utils::pluralize('Successfully '.$action.'d ? credit', $count);
Session::flash('message', $message);
}
return Redirect::to('credits');
}

View File

@ -500,22 +500,14 @@ class InvoiceController extends \BaseController {
{
$action = Input::get('action');
$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 ($action == 'delete')
{
$invoice->is_deleted = true;
$invoice->save();
}
$invoice->delete();
if ($count > 0)
{
$message = Utils::pluralize('Successfully '.$action.'d ? invoice', $count);
Session::flash('message', $message);
}
$message = Utils::pluralize('Successfully '.$action.'d ? invoice', count($invoices));
Session::flash('message', $message);
return Redirect::to('invoices');
}

View File

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

View File

@ -90,9 +90,9 @@ class UserController extends BaseController {
public function do_login()
{
$input = array(
'email' => Input::get( 'email' ), // May be the username too
'username' => Input::get( 'email' ), // so we have to pass both
'password' => Input::get( 'password' ),
'email' => Input::get( 'login_email' ), // May be the username too
'username' => Input::get( 'login_email' ), // so we have to pass both
'password' => Input::get( 'login_password' ),
'remember' => true,
);
@ -100,7 +100,7 @@ class UserController extends BaseController {
// with the second parameter as true.
// logAttempt will check if the 'email' perhaps is the username.
// 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');
// 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')
->withInput(Input::except('password'))
->withInput(Input::except('login_password'))
->with( 'error', $err_msg );
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -200,4 +200,27 @@ class InvoiceRepository
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)
{
if (!$ids)
{
return 0;
}
$payments = Payment::scope($ids)->get();
foreach ($payments as $payment)

View File

@ -22,9 +22,6 @@
//Log::error('test');
/*
Event::listen('illuminate.query', function($query, $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);
});
*/
/*
Route::get('/test', function() {

View File

@ -300,7 +300,7 @@
$('.signUpForm').submit();
} else {
$('#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();
$('#working').hide();
}

View File

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

View File

@ -14,10 +14,10 @@
<div class="navbar-collapse collapse">
{{ Form::open(array('url' => 'login', 'class' => 'navbar-form navbar-right')) }}
<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 class="form-group">
{{ Form::password('password', array('placeholder' => 'Password')) }}
{{ Form::password('login_password', array('placeholder' => 'Password')) }}
</div>
<button type="submit" class="btn btn-success">Sign in</button>
{{ Form::close() }}

View File

@ -54,13 +54,13 @@
<h2 class="form-signin-heading">Please sign in</h2>
<p>
{{ $errors->first('email') }}
{{ $errors->first('password') }}
{{ $errors->first('login_email') }}
{{ $errors->first('login_password') }}
</p>
<p>
{{ Form::text('email', Input::old('email'), array('placeholder' => 'Email address')) }}
{{ Form::password('password', array('placeholder' => 'Password')) }}
{{ Form::text('login_email', Input::old('login_email'), array('placeholder' => 'Email address')) }}
{{ Form::password('login_password', array('placeholder' => 'Password')) }}
</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 dueDate = invoice.due_date ? invoice.due_date : '';
var marginLeft = 90;
var marginLeft = 60;
var accountTop = 30;
var headerTop = 140;
var headerLeft = 360;
@ -55,7 +55,8 @@ function generatePDF(invoice, checkMath) {
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 */
@ -81,7 +82,7 @@ function generatePDF(invoice, checkMath) {
doc.setFontType("normal");
var y = accountTop;
var left = headerLeft;
var left = marginLeft;
if (account.name) {
y += rowHeight;
@ -149,6 +150,11 @@ function generatePDF(invoice, checkMath) {
doc.setFontType("bold");
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.setFillColor(230,230,230);
doc.rect(tableLeft - tablePadding, tableTop - 12, headerRight - tableLeft + 12, rowHeight + 2, 'FD');
@ -174,7 +180,6 @@ function generatePDF(invoice, checkMath) {
var line = 1;
var total = 0;
var shownItem = false;
doc.setDrawColor(220,220,220);
for (var i=0; i<invoice.invoice_items.length; i++) {
var item = invoice.invoice_items[i];
@ -225,14 +230,20 @@ function generatePDF(invoice, checkMath) {
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) {
doc.setLineWidth(0.5);
doc.setDrawColor(220,220,220);
doc.line(tableLeft - tablePadding, tableTop + (line * tableRowHeight) - 8,
lineTotalRight+tablePadding, tableTop + (line * tableRowHeight) - 8);
}
if (line > 20) {
line = 0;
tableTop = 60;
doc.addPage();
}
}
/* table footer */
@ -304,9 +315,6 @@ function generatePDF(invoice, checkMath) {
var totalX = headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize());
doc.text(totalX, x, total);
totalX = headerRight - (doc.getStringUnitWidth(total) * doc.internal.getFontSize());
doc.text(totalX, headerY, total);
/* payment stub */