mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01:00
bug fixes
This commit is contained in:
parent
75b1350808
commit
ba9b95f50f
@ -434,6 +434,8 @@ class AccountController extends \BaseController {
|
||||
{
|
||||
$config->$field = trim(Input::get($gateway->id.'_'.$field));
|
||||
}
|
||||
//dd(Input::all());
|
||||
//dd($config);
|
||||
|
||||
$accountGateway->config = json_encode($config);
|
||||
$account->account_gateways()->save($accountGateway);
|
||||
|
@ -16,21 +16,6 @@ class HomeController extends BaseController {
|
||||
|
||||
public function logError()
|
||||
{
|
||||
$count = Session::get('error_count', 0);
|
||||
Session::put('error_count', ++$count);
|
||||
if ($count > LOGGED_ERROR_LIMIT) return 'logged';
|
||||
|
||||
$data = [
|
||||
'context' => 'JavaScript',
|
||||
'user_id' => Auth::check() ? Auth::user()->id : 0,
|
||||
'url' => Input::get('url'),
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
|
||||
'ip' => Request::getClientIp(),
|
||||
'count' => $count
|
||||
];
|
||||
|
||||
Log::error(Input::get('error'), $data);
|
||||
|
||||
return 'logged';
|
||||
return Utils::logError(Input::get('error'), 'JavaScript');
|
||||
}
|
||||
}
|
@ -132,6 +132,7 @@ class InvoiceController extends \BaseController {
|
||||
}
|
||||
|
||||
Activity::viewInvoice($invitation);
|
||||
Event::fire('invoice.viewed', $invoice);
|
||||
|
||||
$client->account->loadLocalizationSettings();
|
||||
|
||||
@ -200,20 +201,21 @@ class InvoiceController extends \BaseController {
|
||||
|
||||
if (!$ref)
|
||||
{
|
||||
Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>');
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage());
|
||||
}
|
||||
|
||||
$payment = Payment::createNew();
|
||||
$payment->invitation_id = $invitation->id;
|
||||
$payment->account_gateway_id = $accountGateway->id;
|
||||
$payment->invoice_id = $invoice->id;
|
||||
$payment->amount = $invoice->amount;
|
||||
$payment->client_id = $invoice->client_id;
|
||||
$payment->currency_id = $invoice->currency_id ? $invoice->currency_id : 0;
|
||||
$payment->contact_id = $invitation->contact_id;
|
||||
$payment->transaction_reference = $ref;
|
||||
$payment->payment_date = date_create();
|
||||
$payment->save();
|
||||
|
||||
$invoice->balance = floatval($invoice->amount) - floatval($paymount->amount);
|
||||
|
||||
if ($response->isSuccessful())
|
||||
{
|
||||
|
||||
@ -229,7 +231,7 @@ class InvoiceController extends \BaseController {
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>'.$e);
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,19 +265,22 @@ class InvoiceController extends \BaseController {
|
||||
{
|
||||
$invoice->invoice_status_id = INVOICE_STATUS_PARTIAL;
|
||||
}
|
||||
|
||||
$invoice->save();
|
||||
|
||||
Event::fire('invoice.paid', $invoice);
|
||||
|
||||
Session::flash('message', 'Successfully applied payment');
|
||||
return Redirect::to('view/' . $payment->invitation->invitation_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>'.$response->getMessage());
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $response->getMessage());
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>'.$e);
|
||||
return Utils::fatalError('Sorry, there was an error processing your payment. Please try again later.<p>', $e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -432,6 +432,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->unsignedInteger('contact_id')->nullable();
|
||||
$t->unsignedInteger('invitation_id')->nullable();
|
||||
$t->unsignedInteger('user_id')->nullable();
|
||||
$t->unsignedInteger('account_gateway_id')->nullable();
|
||||
$t->unsignedInteger('currency_id')->default(1);
|
||||
$t->timestamps();
|
||||
$t->softDeletes();
|
||||
@ -446,6 +447,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
$t->foreign('contact_id')->references('id')->on('contacts');
|
||||
$t->foreign('account_gateway_id')->references('id')->on('account_gateways');
|
||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');;
|
||||
$t->foreign('currency_id')->references('id')->on('currencies');
|
||||
|
||||
|
@ -2,16 +2,41 @@
|
||||
|
||||
class Utils
|
||||
{
|
||||
public static function fatalError($error = false)
|
||||
public static function fatalError($message = false, $exception = false)
|
||||
{
|
||||
if (!$error)
|
||||
if (!$message)
|
||||
{
|
||||
$error = "An error occurred, please try again later";
|
||||
$message = "An error occurred, please try again later";
|
||||
}
|
||||
|
||||
Log::error($error);
|
||||
static::logError($message . ' ' . $exception);
|
||||
|
||||
return View::make('error')->with('error', $error);
|
||||
return View::make('error')->with('error', $message);
|
||||
}
|
||||
|
||||
public static function logError($error, $context = 'PHP')
|
||||
{
|
||||
$count = Session::get('error_count', 0);
|
||||
Session::put('error_count', ++$count);
|
||||
if ($count > LOGGED_ERROR_LIMIT) return 'logged';
|
||||
|
||||
$data = [
|
||||
'context' => $context,
|
||||
'user_id' => Auth::check() ? Auth::user()->id : 0,
|
||||
'url' => Input::get('url'),
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
|
||||
'ip' => Request::getClientIp(),
|
||||
'count' => Session::get('error_count', 0)
|
||||
];
|
||||
|
||||
Log::error($error, $data);
|
||||
|
||||
/*
|
||||
Mail::queue('emails.error', ['message'=>$error.' '.json_encode($data)], function($message)
|
||||
{
|
||||
$message->to($email)->subject($subject);
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
public static function formatPhoneNumber($phoneNumber)
|
||||
@ -285,9 +310,9 @@ class Utils
|
||||
|
||||
public static function encodeActivity($person = null, $action, $entity = null, $otherPerson = null)
|
||||
{
|
||||
$person = $person ? $person->getFullName() : '<i>System</i>';
|
||||
$person = $person ? $person->getDisplayName() : '<i>System</i>';
|
||||
$entity = $entity ? '[' . $entity->getKey() . ']' : '';
|
||||
$otherPerson = $otherPerson ? 'to ' . $otherPerson->getFullName() : '';
|
||||
$otherPerson = $otherPerson ? 'to ' . $otherPerson->getDisplayName() : '';
|
||||
|
||||
return trim("$person $action $entity $otherPerson");
|
||||
}
|
||||
|
@ -61,6 +61,8 @@ class Account extends Eloquent
|
||||
|
||||
public function isGatewayConfigured($gatewayId = 0)
|
||||
{
|
||||
$this->load('account_gateways');
|
||||
|
||||
if ($gatewayId)
|
||||
{
|
||||
return $this->getGatewayConfig($gatewayId) != false;
|
||||
@ -103,13 +105,19 @@ class Account extends Eloquent
|
||||
|
||||
public function getNextInvoiceNumber()
|
||||
{
|
||||
$order = Invoice::withTrashed()->scope(false, $this->id)->orderBy('created_at', 'DESC')->first();
|
||||
$orders = Invoice::withTrashed()->scope(false, $this->id)->get();
|
||||
|
||||
if ($order)
|
||||
$max = 0;
|
||||
|
||||
foreach ($orders as $order)
|
||||
{
|
||||
$number = preg_replace("/[^0-9]/", "", $order->invoice_number);
|
||||
$number = intval($number) + 1;
|
||||
return str_pad($number, 4, "0", STR_PAD_LEFT);
|
||||
$number = intval(preg_replace("/[^0-9]/", "", $order->invoice_number));
|
||||
$max = max($max, $number);
|
||||
}
|
||||
|
||||
if ($max > 0)
|
||||
{
|
||||
return str_pad($max+1, 4, "0", STR_PAD_LEFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -152,7 +152,7 @@ class Activity extends Eloquent
|
||||
$activity->invoice_id = $invitation->invoice_id;
|
||||
$activity->contact_id = $invitation->contact_id;
|
||||
$activity->activity_type_id = ACTIVITY_TYPE_EMAIL_INVOICE;
|
||||
$activity->message = Utils::encodeActivity(Auth::check() ? Auth::user() : null, 'emailed', $invoice, $invitation->contact);
|
||||
$activity->message = Utils::encodeActivity(Auth::check() ? Auth::user() : null, 'emailed', $invitation->invoice, $invitation->contact);
|
||||
$activity->balance = $client->balance;
|
||||
$activity->adjustment = $adjustment;
|
||||
$activity->save();
|
||||
@ -226,7 +226,7 @@ class Activity extends Eloquent
|
||||
{
|
||||
$activity = new Activity;
|
||||
$activity->contact_id = $payment->contact_id;
|
||||
//$activity->message = $contact->getFullName() . ' created payment ' . $payment->transaction_reference;
|
||||
$activity->message = Utils::encodeActivity($payment->invitation->contact, 'created payment');
|
||||
}
|
||||
|
||||
$activity->payment_id = $payment->id;
|
||||
|
@ -69,6 +69,19 @@ class User extends ConfideUser implements UserInterface, RemindableInterface
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getDisplayName()
|
||||
{
|
||||
if (!$this->first_name && !$this->last_name)
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->getFullName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getFullName()
|
||||
{
|
||||
$fullName = $this->first_name . ' ' . $this->last_name;
|
||||
|
@ -10,7 +10,6 @@ abstract class Mailer {
|
||||
'emails.'.$view.'_html',
|
||||
'emails.'.$view.'_text'
|
||||
];
|
||||
\Log::info('data: ' . json_encode($data));
|
||||
|
||||
Mail::queue($views, $data, function($message) use ($toEmail, $fromEmail, $subject)
|
||||
{
|
||||
|
@ -58,16 +58,9 @@ $monolog->pushHandler(new Monolog\Handler\SyslogHandler('intranet', 'user', Logg
|
||||
|
||||
App::error(function(Exception $exception, $code)
|
||||
{
|
||||
$data = [
|
||||
'context' => 'PHP',
|
||||
'user_id' => Auth::check() ? Auth::user()->id : 0,
|
||||
'code' => $code,
|
||||
'url' => Request::url(),
|
||||
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
|
||||
'ip' => Request::getClientIp()
|
||||
];
|
||||
//Log::error($exception);
|
||||
|
||||
Log::error($exception, $data);
|
||||
Utils::logError($exception . ' ' . $code);
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -14,7 +14,13 @@
|
||||
@if ($accountGateway)
|
||||
{{ Former::populateField('gateway_id', $accountGateway->gateway_id) }}
|
||||
@foreach ($accountGateway->fields as $field => $junk)
|
||||
{{ Former::populateField($accountGateway->gateway_id.'_'.$field, $config->$field) }}
|
||||
@if ($field == 'testMode' || $field == 'developerMode')
|
||||
@if ($config->$field)
|
||||
{{ Former::populateField($accountGateway->gateway_id.'_'.$field, true ) }}
|
||||
@endif
|
||||
@else
|
||||
{{ Former::populateField($accountGateway->gateway_id.'_'.$field, $config->$field) }}
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
|
@ -87,19 +87,37 @@
|
||||
$('#country_id').combobox();
|
||||
});
|
||||
|
||||
function ContactModel() {
|
||||
function ContactModel(data) {
|
||||
var self = this;
|
||||
self.public_id = ko.observable('');
|
||||
self.first_name = ko.observable('');
|
||||
self.last_name = ko.observable('');
|
||||
self.email = ko.observable('');
|
||||
self.phone = ko.observable('');
|
||||
|
||||
if (data) {
|
||||
ko.mapping.fromJS(data, {}, this);
|
||||
}
|
||||
}
|
||||
|
||||
function ContactsModel() {
|
||||
function ContactsModel(data) {
|
||||
var self = this;
|
||||
self.contacts = ko.observableArray();
|
||||
|
||||
self.mapping = {
|
||||
'contacts': {
|
||||
create: function(options) {
|
||||
return new ContactModel(options.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data) {
|
||||
ko.mapping.fromJS(data, self.mapping, this);
|
||||
} else {
|
||||
self.contacts.push(new ContactModel());
|
||||
}
|
||||
|
||||
self.placeholderName = ko.computed(function() {
|
||||
if (self.contacts().length == 0) return '';
|
||||
var contact = self.contacts()[0];
|
||||
@ -111,12 +129,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
@if ($client)
|
||||
window.model = ko.mapping.fromJS({{ $client }});
|
||||
@else
|
||||
window.model = new ContactsModel();
|
||||
addContact();
|
||||
@endif
|
||||
window.model = new ContactsModel({{ $client }});
|
||||
|
||||
model.showContact = function(elem) { if (elem.nodeType === 1) $(elem).hide().slideDown() }
|
||||
model.hideContact = function(elem) { if (elem.nodeType === 1) $(elem).slideUp(function() { $(elem).remove(); }) }
|
||||
|
0
app/views/emails/error.blade.php
Executable file
0
app/views/emails/error.blade.php
Executable file
@ -174,7 +174,6 @@
|
||||
@endif
|
||||
|
||||
Want something changed? We're {{ link_to('https://github.com/hillelcoren/invoice-ninja', 'open source', array('target'=>'_blank')) }}, email us at {{ link_to('mailto:contact@invoiceninja.com', 'contact@invoiceninja.com') }}.
|
||||
<p class="text-danger">This is a demo site, the data is erased.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -43,7 +43,7 @@
|
||||
@endif
|
||||
|
||||
<div data-bind="with: client">
|
||||
<div class="form-group" data-bind="visible: contacts().length > 1, foreach: contacts">
|
||||
<div class="form-group" data-bind="visible: contacts().length > 0 && contacts()[0].email(), foreach: contacts">
|
||||
<div class="col-lg-8 col-lg-offset-4">
|
||||
<label for="test" class="checkbox" data-bind="attr: {for: $index() + '_check'}">
|
||||
<input type="checkbox" value="1" data-bind="checked: send_invoice, attr: {id: $index() + '_check'}">
|
||||
@ -60,7 +60,7 @@
|
||||
{{ Former::text('invoice_date')->data_bind("datePicker: invoice_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
|
||||
{{ Former::text('due_date')->data_bind("datePicker: due_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
|
||||
</div>
|
||||
<div data-bind="visible: is_recurring">
|
||||
<div data-bind="visible: is_recurring" style="display: none">
|
||||
{{ Former::select('frequency_id')->label('How often')->options($frequencies)->data_bind("value: frequency_id") }}
|
||||
{{ Former::text('start_date')->data_bind("datePicker: start_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
|
||||
{{ Former::text('end_date')->data_bind("datePicker: end_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
|
||||
|
@ -9,14 +9,17 @@
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="pull-right">
|
||||
@if ($invoice->client->account->isGatewayConfigured())
|
||||
@if ($invoice->client->account->isGatewayConfigured())
|
||||
<div class="pull-right" style="width:270px">
|
||||
{{ Button::normal('Download PDF', array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}
|
||||
{{ Button::primary_link(URL::to('payment/' . $invitation->invitation_key), 'Pay Now', array('class' => 'btn-lg pull-right')) }}
|
||||
@else
|
||||
</div>
|
||||
@else
|
||||
<div class="pull-right">
|
||||
{{ Button::primary('Download PDF', array('onclick' => 'onDownloadClick()', 'class' => 'btn-lg')) }}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="clearfix"></div><p> </p>
|
||||
|
||||
<iframe id="theFrame" frameborder="1" width="100%" height="650" style="display:none;margin: 0 auto"></iframe>
|
||||
|
@ -237,7 +237,7 @@ function generatePDF(invoice, checkMath) {
|
||||
|
||||
/* table footer */
|
||||
doc.setDrawColor(200,200,200);
|
||||
var x = tableTop + (line * tableRowHeight);
|
||||
var x = tableTop + (line * tableRowHeight) - 6;
|
||||
|
||||
doc.setLineWidth(1);
|
||||
doc.line(tableLeft - tablePadding, x, lineTotalRight+tablePadding, x);
|
||||
|
Loading…
Reference in New Issue
Block a user