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-15 14:01:24 +00:00
parent d1d3d75915
commit 1c782b6f2c
24 changed files with 167 additions and 109 deletions

View File

@ -44,10 +44,11 @@ class AccountController extends \BaseController {
$random = str_random(RANDOM_KEY_LENGTH);
$user = new User;
$user->username = $random;
$user->password = $random;
$user->password_confirmation = $random;
$account->users()->save($user);
$user->password_confirmation = $random;
$account->users()->save($user);
Session::forget(RECENTLY_VIEWED);
}
@ -479,17 +480,13 @@ class AccountController extends \BaseController {
$account->industry_id = Input::get('industry_id') ? Input::get('industry_id') : null;
$account->save();
$user = $account->users()->first();
$user = Auth::user();
$user->first_name = trim(Input::get('first_name'));
$user->last_name = trim(Input::get('last_name'));
$user->username = $user->email = trim(Input::get('email'));
$user->phone = trim(Input::get('phone'));
$user->save();
if (Input::get('timezone_id')) {
$timezone = Timezone::findOrFail(Input::get('timezone_id'));
Session::put('tz', $timezone->name);
}
$user->username = trim(Input::get('email'));
$user->email = trim(Input::get('email'));
$user->phone = trim(Input::get('phone'));
$user->amend(); // need to 'amend' to avoid password validation rules
/* Logo image file */
if ($file = Input::file('logo'))

View File

@ -23,7 +23,7 @@ class CreditController extends \BaseController {
return View::make('list', array(
'entityType'=>ENTITY_CREDIT,
'title' => '- Credits',
'columns'=>['checkbox', 'Client', 'Credit Amount', 'Credit Date', 'Action']
'columns'=>['checkbox', 'Client', 'Credit Amount', 'Credit Date', 'Private Notes', 'Action']
));
}
@ -41,6 +41,7 @@ class CreditController extends \BaseController {
return $table->addColumn('amount', function($model){ return Utils::formatMoney($model->amount, $model->currency_id); })
->addColumn('credit_date', function($model) { return Utils::fromSqlDate($model->credit_date); })
->addColumn('private_notes', function($model) { return $model->private_notes; })
->addColumn('dropdown', function($model)
{
return '<div class="btn-group tr-action" style="visibility:hidden;">
@ -66,8 +67,8 @@ class CreditController extends \BaseController {
'method' => 'POST',
'url' => 'credits',
'title' => '- New Credit',
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'invoices' => Invoice::scope()->with('client', 'invoice_status')->where('balance','>',0)->orderBy('invoice_number')->get(),
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'invoices' => Invoice::scope()->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
return View::make('credits.edit', $data);
@ -84,7 +85,7 @@ class CreditController extends \BaseController {
'method' => 'PUT',
'url' => 'credits/' . $publicId,
'title' => '- Edit Credit',
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
return View::make('credit.edit', $data);
}

View File

@ -68,6 +68,9 @@ class InvoiceController extends \BaseController {
<ul class="dropdown-menu" role="menu">
<li><a href="' . URL::to('invoices/'.$model->public_id.'/edit') . '">Edit Invoice</a></li>
<li class="divider"></li>
<li><a href="' . URL::to('payments/create/' . $model->client_public_id . '/' . $model->public_id ) . '">Enter Payment</a></li>
<li><a href="' . URL::to('credits/create/' . $model->client_public_id . '/' . $model->public_id ) . '">Enter Credit</a></li>
<li class="divider"></li>
<li><a href="javascript:archiveEntity(' . $model->public_id . ')">Archive Invoice</a></li>
<li><a href="javascript:deleteEntity(' . $model->public_id . ')">Delete Invoice</a></li>
</ul>

View File

@ -18,7 +18,7 @@ class PaymentController extends \BaseController
return View::make('list', array(
'entityType'=>ENTITY_PAYMENT,
'title' => '- Payments',
'columns'=>['checkbox', 'Transaction Reference', 'Client', 'Invoice', 'Payment Amount', 'Payment Date', 'Action']
'columns'=>['checkbox', 'Transaction Reference', 'Method', 'Client', 'Invoice', 'Payment Amount', 'Payment Date', 'Action']
));
}
@ -31,7 +31,9 @@ class PaymentController extends \BaseController
$table->addColumn('checkbox', function($model) { return '<input type="checkbox" name="ids[]" value="' . $model->public_id . '">'; });
}
$table->addColumn('transaction_reference', function($model) { return $model->transaction_reference ? $model->transaction_reference : '<i>Manual entry</i>'; });
$table->addColumn('transaction_reference', function($model) { return $model->transaction_reference ? $model->transaction_reference : '<i>Manual entry</i>'; })
->addColumn('method', function($model) { return $model->payment_type ? $model->payment_type : ($model->transaction_reference ? '<i>Online payment</i>' : ''); });
if (!$clientPublicId) {
$table->addColumn('client_name', function($model) { return link_to('clients/' . $model->client_public_id, Utils::getClientDisplayName($model)); });
@ -62,12 +64,12 @@ class PaymentController extends \BaseController
'clientPublicId' => Input::old('client') ? Input::old('client') : $clientPublicId,
'invoicePublicId' => Input::old('invoice') ? Input::old('invoice') : $invoicePublicId,
'invoice' => null,
'invoices' => Invoice::scope()->with('client', 'invoice_status')->where('balance','>',0)->orderBy('invoice_number')->get(),
'invoices' => Invoice::scope()->with('client', 'invoice_status')->orderBy('invoice_number')->get(),
'payment' => null,
'method' => 'POST',
'url' => "payments",
'title' => '- New Payment',
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
@ -87,7 +89,7 @@ class PaymentController extends \BaseController
'method' => 'PUT',
'url' => 'payments/' . $publicId,
'title' => '- Edit Payment',
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
//'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'paymentTypes' => PaymentType::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'clients' => Client::scope()->with('contacts')->orderBy('name')->get());
return View::make('payments.edit', $data);

View File

@ -178,7 +178,7 @@ class ConfideSetupUsersTable extends Migration {
$t->string('first_name');
$t->string('last_name');
$t->string('phone');
$t->string('username');
$t->string('username')->unique();
$t->string('email');
$t->string('password');
$t->string('confirmation_code');
@ -305,7 +305,6 @@ class ConfideSetupUsersTable extends Migration {
$t->unsignedInteger('user_id');
$t->unsignedInteger('account_id')->index();
$t->unsignedInteger('invoice_status_id')->default(1);
$t->unsignedInteger('currency_id')->default(1);
$t->timestamps();
$t->softDeletes();
@ -334,7 +333,6 @@ class ConfideSetupUsersTable extends Migration {
$t->foreign('account_id')->references('id')->on('accounts');
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');;
$t->foreign('invoice_status_id')->references('id')->on('invoice_statuses');
$t->foreign('currency_id')->references('id')->on('currencies');
$t->foreign('recurring_invoice_id')->references('id')->on('invoices');
$t->unsignedInteger('public_id')->index();
@ -441,7 +439,6 @@ class ConfideSetupUsersTable extends Migration {
$t->unsignedInteger('user_id')->nullable();
$t->unsignedInteger('account_gateway_id')->nullable();
$t->unsignedInteger('payment_type_id')->nullable();
$t->unsignedInteger('currency_id')->default(1);
$t->timestamps();
$t->softDeletes();
@ -457,7 +454,6 @@ class ConfideSetupUsersTable extends Migration {
$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');
$t->foreign('payment_type_id')->references('id')->on('payment_types');
$t->unsignedInteger('public_id')->index();
@ -472,7 +468,6 @@ class ConfideSetupUsersTable extends Migration {
$t->unsignedInteger('client_id')->index()->nullable();
$t->unsignedInteger('invoice_id')->nullable();
$t->unsignedInteger('contact_id')->nullable();
$t->unsignedInteger('currency_id')->default(1);
$t->timestamps();
$t->softDeletes();
@ -480,14 +475,14 @@ class ConfideSetupUsersTable extends Migration {
$t->decimal('amount', 13, 4);
$t->date('credit_date')->nullable();
$t->string('credit_number');
$t->text('private_notes');
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
$t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
$t->foreign('contact_id')->references('id')->on('contacts');
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');;
$t->foreign('currency_id')->references('id')->on('currencies');
$t->unsignedInteger('public_id')->index();
$t->unique( array('account_id','public_id') );
});
@ -505,7 +500,7 @@ class ConfideSetupUsersTable extends Migration {
$t->unsignedInteger('invoice_id');
$t->unsignedInteger('credit_id');
$t->unsignedInteger('invitation_id');
$t->unsignedInteger('currency_id')->default(1);
$t->unsignedInteger('currency_id')->nullable();
$t->text('message');
$t->text('json_backup');

View File

@ -31,10 +31,21 @@ class ConstantsSeeder extends Seeder
$client->invoices()->save($invoice);
*/
PaymentType::create(array('name' => 'Visa'));
PaymentType::create(array('name' => 'Apply Credit'));
PaymentType::create(array('name' => 'Bank Transfer'));
PaymentType::create(array('name' => 'Cash'));
PaymentType::create(array('name' => 'Debit'));
PaymentType::create(array('name' => 'ACH'));
PaymentType::create(array('name' => 'Visa Card'));
PaymentType::create(array('name' => 'MasterCard'));
PaymentType::create(array('name' => 'American Express'));
PaymentType::create(array('name' => 'Cash'));
PaymentType::create(array('name' => 'Discover Card'));
PaymentType::create(array('name' => 'Diners Card'));
PaymentType::create(array('name' => 'EuroCard'));
PaymentType::create(array('name' => 'Nova'));
PaymentType::create(array('name' => 'Credit Card Other'));
PaymentType::create(array('name' => 'PayPal'));
PaymentType::create(array('name' => 'Google Wallet'));
Theme::create(array('name' => 'amelia'));
Theme::create(array('name' => 'cerulean'));

View File

@ -108,7 +108,7 @@ class Activity extends Eloquent
$activity = Activity::getBlank($invoice);
$activity->invoice_id = $invoice->id;
$activity->client_id = $invoice->client_id;
$activity->currency_id = $invoice->currency_id;
$activity->currency_id = $invoice->client->currency_id;
$activity->activity_type_id = ACTIVITY_TYPE_CREATE_INVOICE;
$activity->message = $message;
$activity->balance = $invoice->client->balance;
@ -289,7 +289,7 @@ class Activity extends Eloquent
}
$activity->client_id = $payment->client_id;
$activity->currency_id = $payment->currency_id;
$activity->currency_id = $client->currency_id;
$activity->activity_type_id = ACTIVITY_TYPE_CREATE_PAYMENT;
$activity->balance = $client->balance;
$activity->adjustment = $payment->amount * -1;
@ -388,11 +388,11 @@ class Activity extends Eloquent
$activity->invoice_id = $credit->invoice_id;
$invoice = $credit->invoice;
$invoice->balance = $invoice->amount - $credit->amount;
$invoice->balance = $invoice->balance - $credit->amount;
$invoice->save();
}
$activity->currency_id = $credit->currency_id;
$activity->currency_id = $client->currency_id;
$activity->activity_type_id = ACTIVITY_TYPE_CREATE_CREDIT;
$activity->balance = $client->balance;
$activity->adjustment = $credit->amount * -1;

View File

@ -49,10 +49,10 @@ class Invoice extends EntityModel
public function hidePrivateFields()
{
$this->setVisible(['invoice_number', 'discount', 'po_number', 'invoice_date', 'due_date', 'terms', 'currency_id', 'public_notes', 'amount', 'balance', 'invoice_items', 'client', 'tax_name', 'tax_rate', 'account']);
$this->setVisible(['invoice_number', 'discount', 'po_number', 'invoice_date', 'due_date', 'terms', 'public_notes', 'amount', 'balance', 'invoice_items', 'client', 'tax_name', 'tax_rate', 'account']);
$this->client->setVisible(['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'work_phone', 'payment_terms', 'contacts', 'country']);
$this->account->setVisible(['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'country']);
$this->client->setVisible(['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'work_phone', 'payment_terms', 'contacts', 'country', 'currency_id' ]);
$this->account->setVisible(['name', 'address1', 'address2', 'city', 'state', 'postal_code', 'country', 'currency_id']);
foreach ($this->invoice_items as $invoiceItem)
{

View File

@ -9,14 +9,16 @@ class User extends ConfideUser implements UserInterface, RemindableInterface
protected $softDelete = true;
public static $rules = array(
/*
'username' => 'required|email|unique:users',
'email' => 'required|email|unique:users',
*/
'username' => 'required|unique:users',
'password' => 'required|between:6,32|confirmed',
'password_confirmation' => 'between:6,32',
);
protected $updateRules = array(
'email' => 'required|unique:users',
'username' => 'required|unique:users',
);
/**
* The database table used by the model.
*

View File

@ -16,7 +16,7 @@ class CreditRepository
->where('clients.deleted_at', '=', null)
->where('credits.deleted_at', '=', null)
->where('contacts.is_primary', '=', true)
->select('credits.public_id', 'clients.name as client_name', 'clients.public_id as client_public_id', 'credits.amount', 'credits.credit_date', 'credits.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email');
->select('credits.public_id', 'clients.name as client_name', 'clients.public_id as client_public_id', 'credits.amount', 'credits.credit_date', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'credits.private_notes');
if ($clientPublicId)
{
@ -49,7 +49,8 @@ class CreditRepository
$credit->credit_date = Utils::toSqlDate($input['credit_date']);
$credit->invoice_id = isset($input['invoice']) && $input['invoice'] != "-1" ? Invoice::getPrivateId($input['invoice']) : null;
$credit->amount = Utils::parseFloat($input['amount']);
$credit->currency_id = $input['currency_id'] ? $input['currency_id'] : null;
//$credit->currency_id = $input['currency_id'] ? $input['currency_id'] : null;
$credit->private_notes = trim($input['private_notes']);
$credit->save();
return $credit;

View File

@ -19,7 +19,7 @@ class InvoiceRepository
->where('clients.deleted_at', '=', null)
->where('invoices.is_recurring', '=', false)
->where('contacts.is_primary', '=', true)
->select('clients.public_id as client_public_id', 'invoice_number', 'clients.name as client_name', 'invoices.public_id', 'amount', 'invoices.balance', 'invoice_date', 'due_date', 'invoice_statuses.name as invoice_status_name', 'invoices.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email');
->select('clients.public_id as client_public_id', 'invoice_number', 'clients.name as client_name', 'invoices.public_id', 'amount', 'invoices.balance', 'invoice_date', 'due_date', 'invoice_statuses.name as invoice_status_name', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email');
if ($clientPublicId)
{
@ -49,7 +49,7 @@ class InvoiceRepository
->where('invoices.deleted_at', '=', null)
->where('invoices.is_recurring', '=', true)
->where('contacts.is_primary', '=', true)
->select('clients.public_id as client_public_id', 'clients.name as client_name', 'invoices.public_id', 'amount', 'frequencies.name as frequency', 'start_date', 'end_date', 'invoices.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email');
->select('clients.public_id as client_public_id', 'clients.name as client_name', 'invoices.public_id', 'amount', 'frequencies.name as frequency', 'start_date', 'end_date', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email');
if ($clientPublicId)
{
@ -122,7 +122,7 @@ class InvoiceRepository
$invoice->terms = trim($data['terms']);
$invoice->public_notes = trim($data['public_notes']);
$invoice->po_number = trim($data['po_number']);
$invoice->currency_id = $data['currency_id'];
//$invoice->currency_id = $data['currency_id'];
if (isset($data['tax_rate']) && Utils::parseFloat($data['tax_rate']) > 0)
{

View File

@ -13,11 +13,12 @@ class PaymentRepository
->join('clients', 'clients.id', '=','payments.client_id')
->join('invoices', 'invoices.id', '=','payments.invoice_id')
->join('contacts', 'contacts.client_id', '=', 'clients.id')
->leftJoin('payment_types', 'payment_types.id', '=', 'payments.payment_type_id')
->where('payments.account_id', '=', \Auth::user()->account_id)
->where('payments.deleted_at', '=', null)
->where('clients.deleted_at', '=', null)
->where('contacts.is_primary', '=', true)
->select('payments.public_id', 'payments.transaction_reference', 'clients.name as client_name', 'clients.public_id as client_public_id', 'payments.amount', 'payments.payment_date', 'invoices.public_id as invoice_public_id', 'invoices.invoice_number', 'payments.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email');
->select('payments.public_id', 'payments.transaction_reference', 'clients.name as client_name', 'clients.public_id as client_public_id', 'payments.amount', 'payments.payment_date', 'invoices.public_id as invoice_public_id', 'invoices.invoice_number', 'clients.currency_id', 'contacts.first_name', 'contacts.last_name', 'contacts.email', 'payment_types.name as payment_type');
if ($clientPublicId)
{
@ -48,7 +49,7 @@ class PaymentRepository
$payment->client_id = Client::getPrivateId($input['client']);
$payment->invoice_id = isset($input['invoice']) && $input['invoice'] != "-1" ? Invoice::getPrivateId($input['invoice']) : null;
$payment->currency_id = $input['currency_id'] ? $input['currency_id'] : null;
//$payment->currency_id = $input['currency_id'] ? $input['currency_id'] : null;
$payment->payment_type_id = $input['payment_type_id'] ? $input['payment_type_id'] : null;
$payment->payment_date = Utils::toSqlDate($input['payment_date']);
$payment->amount = Utils::parseFloat($input['amount']);

View File

@ -16,7 +16,7 @@
'email' => 'email|required'
)); }}
{{ Former::populate($account); }}
{{ Former::populate($account) }}
{{ Former::populateField('first_name', $account->users()->first()->first_name) }}
{{ Former::populateField('last_name', $account->users()->first()->last_name) }}
{{ Former::populateField('email', $account->users()->first()->email) }}
@ -27,7 +27,7 @@
{{ Former::legend('Account') }}
{{ Former::text('name') }}
{{ Former::file('logo')->max(2, 'MB')->accept('image')->wrap('test') }}
{{ Former::file('logo')->max(2, 'MB')->accept('image')->wrap('test')->inlineHelp('Recommnded size: 120px width, 80px height') }}
@if (file_exists($account->getLogoPath()))
<center>

View File

@ -4,7 +4,7 @@
@parent
{{ Former::open()->addClass('col-md-9 col-md-offset-1') }}
{{ Former::legend('Export Data') }}
{{ Former::legend('Export Client Data') }}
{{ Button::lg_primary_submit('Download') }}
{{ Former::close() }}

View File

@ -4,7 +4,7 @@
@parent
{{ Former::open_for_files('account/import_map')->addClass('col-md-9 col-md-offset-1') }}
{{ Former::legend('Import Clients') }}
{{ Former::legend('Import Client Data') }}
{{ Former::file('file')->label('Select CSV file') }}
{{ Former::actions( Button::lg_primary_submit('Upload') ) }}
{{ Former::close() }}

View File

@ -56,13 +56,13 @@
{{ Former::select('datetime_format_id')->addOption('','')->label('Date/Time Format')
->fromQuery($datetimeFormats, 'label', 'id') }}
{{ Former::legend('Notifications') }}
{{ Former::legend('Email Notifications') }}
{{ Former::checkbox('notify_sent')->label('&nbsp;')->text('Email me when an invoice is <b>sent</b>') }}
{{ Former::checkbox('notify_viewed')->label('&nbsp;')->text('Email me when an invoice is <b>viewed</b>') }}
{{ Former::checkbox('notify_paid')->label('&nbsp;')->text('Email me when an invoice is <b>paid</b>') }}
{{ Former::legend('Invoices') }}
{{ Former::textarea('invoice_terms') }}
{{ Former::legend('Invoice Terms') }}
{{ Former::textarea('invoice_terms')->label('Terms') }}
{{ Former::actions( Button::lg_primary_submit('Save') ) }}
{{ Former::close() }}

View File

@ -67,7 +67,7 @@
{{ Former::select('payment_terms')->addOption('','')
->fromQuery($paymentTerms, 'name', 'num_days') }}
{{ Former::select('currency_id')->addOption('','')->label('Currency')
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) }}
->fromQuery($currencies, 'name', 'id') }}
{{ Former::select('size_id')->addOption('','')->label('Size')
->fromQuery($sizes, 'name', 'id') }}
{{ Former::select('industry_id')->addOption('','')->label('Industry')

View File

@ -25,8 +25,8 @@
Navigation::links(
[
['Create Invoice', URL::to('invoices/create/' . $client->public_id )],
['Create Payment', URL::to('payments/create/' . $client->public_id )],
['Create Credit', URL::to('credits/create/' . $client->public_id )],
['Enter Payment', URL::to('payments/create/' . $client->public_id )],
['Enter Credit', URL::to('credits/create/' . $client->public_id )],
]
)
, ['id'=>'primaryDropDown'])->split(); }}
@ -112,7 +112,7 @@
<div class="tab-pane" id="payments">
{{ Datatable::table()
->addColumn('Transaction Reference', 'Invoice', 'Payment Amount', 'Payment Date')
->addColumn('Transaction Reference', 'Method', 'Invoice', 'Payment Amount', 'Payment Date')
->setUrl(url('api/payments/' . $client->public_id))
->setOptions('sPaginationType', 'bootstrap')
->setOptions('bFilter', false)
@ -122,7 +122,7 @@
<div class="tab-pane" id="credits">
{{ Datatable::table()
->addColumn('Credit Amount', 'Credit Date')
->addColumn('Credit Amount', 'Credit Date', 'Private Notes')
->setUrl(url('api/credits/' . $client->public_id))
->setOptions('sPaginationType', 'bootstrap')
->setOptions('bFilter', false)

View File

@ -26,8 +26,9 @@
{{ Former::select('invoice')->addOption('', '')->addGroupClass('invoice-select') }}
{{ Former::text('amount') }}
{{ Former::text('credit_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
{{ Former::select('currency_id')->addOption('','')->label('Currency')
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) }}
{{-- Former::select('currency_id')->addOption('','')->label('Currency')
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) --}}
{{ Former::textarea('private_notes') }}
</div>
<div class="col-md-6">

View File

@ -62,11 +62,11 @@
@section('body')
<div class="container">
<p>&nbsp;</p>
<p>&nbsp;</p>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
@ -137,10 +137,13 @@
</div><!-- /.navbar-collapse -->
</div>
</nav>
<p>&nbsp;</p>
<div class="container">
@if (Session::has('message'))
<div class="alert alert-info">{{ Session::get('message') }}</div>
@endif

View File

@ -56,7 +56,6 @@
</div>
<div class="col-md-4" id="col_2">
<div data-bind="visible: !is_recurring()">
{{ Former::text('invoice_number')->label('Invoice #')->data_bind("value: invoice_number, valueUpdate: 'afterkeydown'") }}
{{ 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>
@ -71,7 +70,7 @@
</div>
@else
<div data-bind="visible: invoice_status_id() < CONSTS.INVOICE_STATUS_SENT">
{{ Former::checkbox('recurring')->text('Enable | <a href="#" rel="tooltip" data-toggle="tooltip" title="Recurring invoices are automatically sent. Use :MONTH, :QUARTER or :YEAR for dynamic dates. Basic math works as well. ie, :MONTH-1.">Learn more</a>')->data_bind("checked: is_recurring")
{{ Former::checkbox('recurring')->text('Enable | <a href="#" onclick="showLearnMore()">Learn more</a>')->data_bind("checked: is_recurring")
->inlineHelp($invoice && $invoice->last_sent_date ? 'Last invoice sent ' . Utils::dateToString($invoice->last_sent_date) : '') }}
</div>
@endif
@ -79,9 +78,10 @@
</div>
<div class="col-md-3" id="col_2">
{{ Former::text('invoice_number')->label('Invoice #')->data_bind("value: invoice_number, valueUpdate: 'afterkeydown'") }}
{{ Former::text('po_number')->label('PO #')->data_bind("value: po_number, valueUpdate: 'afterkeydown'") }}
{{ Former::text('discount')->data_bind("value: discount, valueUpdate: 'afterkeydown'") }}
{{ Former::select('currency_id')->label('Currency')->addOption('', '')->fromQuery($currencies, 'name', 'id')->data_bind("value: currency_id") }}
{{-- Former::select('currency_id')->label('Currency')->addOption('', '')->fromQuery($currencies, 'name', 'id')->data_bind("value: currency_id") --}}
<div class="form-group" style="margin-bottom: 8px">
<label for="recurring" class="control-label col-lg-4 col-sm-4">Taxes</label>
@ -197,24 +197,14 @@
</div>
{{ Button::normal('Download PDF', array('onclick' => 'onDownloadClick()')) }}
@if ($invoice)
<div id="relatedActions" style="text-align:left" class="btn-group">
<button class=" btn-default btn" type="button">Download PDF</button>
<button class=" btn-default btn dropdown-toggle" type="button" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="javascript:onDownloadClick()">Download PDF</a></li>
<li class="divider"></li>
<li><a href="javascript:onPaymentClick()">Create Payment</a></li>
<li><a href="javascript:onCreditClick()">Create Credit</a></li>
</ul>
</div>
<div id="primaryActions" style="text-align:left" data-bind="css: $root.enable.save" class="btn-group">
<button class=" btn-primary btn" type="button" data-bind="css: $root.enable.save">Save Invoice</button>
<button class=" btn-primary btn dropdown-toggle" type="button" data-toggle="dropdown" data-bind="css: $root.enable.save">
<button class="btn-primary btn" type="button" data-bind="css: $root.enable.save">Save Invoice</button>
<button class="btn-primary btn dropdown-toggle" type="button" data-toggle="dropdown" data-bind="css: $root.enable.save">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
@ -250,17 +240,33 @@
)
, array('id'=>'primaryActions', 'style'=>'text-align:left', 'data-bind'=>'css: $root.enable.save'))->split(); --}}
@else
{{ Button::normal('Download PDF', array('onclick' => 'onDownloadClick()')) }}
{{ Button::primary_submit('Save Invoice', array('data-bind'=>'css: $root.enable.save')) }}
@endif
{{ Button::primary('Email Invoice', array('id' => 'email_button', 'onclick' => 'onEmailClick()', 'data-bind' => 'css: $root.enable.email')) }}
@if ($invoice)
<div id="relatedActions" style="text-align:left" class="btn-group">
<button class="btn-success btn" type="button">Enter Payment</button>
<button class="btn-success btn dropdown-toggle" type="button" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="javascript:onPaymentClick()">Enter Payment</a></li>
<li><a href="javascript:onCreditClick()">Enter Credit</a></li>
</ul>
</div>
@endif
</div>
<p>&nbsp;</p>
<!-- <textarea rows="20" cols="120" id="pdfText" onkeyup="runCode()"></textarea> -->
<!-- <iframe frameborder="1" width="100%" height="600" style="display:block;margin: 0 auto"></iframe> -->
<iframe id="theFrame" style="display:none" frameborder="1" width="100%" height="500"></iframe>
<iframe id="theFrame" style="display:none" frameborder="1" width="100%" height="1150"></iframe>
<canvas id="theCanvas" style="display:none;width:100%;border:solid 1px #CCCCCC;"></canvas>
@ -427,6 +433,32 @@
</div>
<div class="modal fade" id="recurringModal" tabindex="-1" role="dialog" aria-labelledby="recurringModalLabel" aria-hidden="true">
<div class="modal-dialog" style="min-width:150px">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="recurringModalLabel">Recurring Invoices</h4>
</div>
<div style="background-color: #EEEEEE; padding-left: 16px; padding-right: 16px">
&nbsp;
<p>Recurring invoices are automatically sent.</p>
<p>Use :MONTH, :QUARTER or :YEAR for dynamic dates. </p>
<p>Basic math works as well. ie, :MONTH-1. </p>
&nbsp;
</div>
<div class="modal-footer" style="margin-top: 0px">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
{{ Former::close() }}
</div>
@ -437,6 +469,10 @@
$('#signUpModal').modal('show');
}
function showLearnMore() {
$('#recurringModal').modal('show');
}
$(function() {
$('#country_id').combobox();
@ -492,7 +528,7 @@
})
$('#relatedActions > button:first').click(function() {
onDownloadClick();
onPaymentClick();
});
$('#primaryActions > button:first').click(function() {
@ -906,9 +942,8 @@
this.id = ko.observable('');
self.discount = ko.observable('');
self.frequency_id = ko.observable('');
//self.currency_id = ko.observable({{ Session::get(SESSION_CURRENCY) }});
self.currency_id = ko.observable({{ $client && $client->currency_id ? $client->currency_id : Session::get(SESSION_CURRENCY) }});
self.terms = ko.observable(wordWrapText('{{ $account->invoice_terms }}', 340));
//self.currency_id = ko.observable({{ $client && $client->currency_id ? $client->currency_id : Session::get(SESSION_CURRENCY) }});
self.terms = ko.observable(wordWrapText('{{ str_replace("\n", '\n', $account->invoice_terms) }}', 340));
self.set_default_terms = ko.observable(false);
self.public_notes = ko.observable('');
self.po_number = ko.observable('');
@ -1020,7 +1055,7 @@
this.totals.subtotal = ko.computed(function() {
var total = self.totals.rawSubtotal();
return total > 0 ? formatMoney(total, self.currency_id()) : '';
return total > 0 ? formatMoney(total, self.client().currency_id()) : '';
});
this.totals.rawDiscounted = ko.computed(function() {
@ -1028,7 +1063,7 @@
});
this.totals.discounted = ko.computed(function() {
return formatMoney(self.totals.rawDiscounted(), self.currency_id());
return formatMoney(self.totals.rawDiscounted(), self.client().currency_id());
});
self.totals.taxAmount = ko.computed(function() {
@ -1042,7 +1077,7 @@
var taxRate = parseFloat(self.tax_rate());
if (taxRate > 0) {
var tax = total * (taxRate/100);
return formatMoney(tax, self.currency_id());
return formatMoney(tax, self.client().currency_id());
} else {
return formatMoney(0);
}
@ -1054,7 +1089,7 @@
this.totals.paidToDate = ko.computed(function() {
var total = self.totals.rawPaidToDate();
return total > 0 ? formatMoney(total, self.currency_id()) : '';
return total > 0 ? formatMoney(total, self.client().currency_id()) : '';
});
this.totals.total = ko.computed(function() {
@ -1075,7 +1110,7 @@
total -= paid;
}
return total != 0 ? formatMoney(total, self.currency_id()) : '';
return total != 0 ? formatMoney(total, self.client().currency_id()) : '';
});
self.onDragged = function(item) {
@ -1311,8 +1346,8 @@
this.totals.total = ko.computed(function() {
var total = self.totals.rawTotal();
if (window.hasOwnProperty('model') && model.invoice && model.invoice()) {
return total ? formatMoney(total, model.invoice().currency_id()) : '';
if (window.hasOwnProperty('model') && model.invoice && model.invoice() && model.invoice().client()) {
return total ? formatMoney(total, model.invoice().client().currency_id()) : '';
} else {
return total ? formatMoney(total, 1) : '';
}
@ -1410,7 +1445,7 @@
for (var i=0; i<model.invoice().invoice_items().length; i++) {
var item = model.invoice().invoice_items()[i];
item.tax(model.getTaxRate(item.tax_name(), item.tax_rate()));
item.cost(parseFloat(item.cost()) > 0 ? formatMoney(item.cost(), model.invoice().currency_id(), true) : '');
item.cost(parseFloat(item.cost()) > 0 ? formatMoney(item.cost(), model.invoice().client().currency_id(), true) : '');
}
onTaxRateChange();

View File

@ -29,8 +29,8 @@
{{ Former::select('payment_type_id')->addOption('','')->label('Payment type')
->fromQuery($paymentTypes, 'name', 'id') }}
{{ Former::text('payment_date')->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
{{ Former::select('currency_id')->addOption('','')->label('Currency')
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) }}
{{-- Former::select('currency_id')->addOption('','')->label('Currency')
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) --}}
</div>
<div class="col-md-6">

View File

@ -63,16 +63,21 @@ $app = new Illuminate\Foundation\Application;
$env = $app->detectEnvironment(function ()
{
return require __DIR__.'/environment.php';
if (file_exists(__DIR__.'/environment.php'))
{
return require __DIR__.'/environment.php';
}
else if (isset($_SERVER['LARAVEL_ENV']))
{
return $_SERVER['LARAVEL_ENV'];
}
else
{
return 'development';
}
});
/*
$env = $app->detectEnvironment(function () {
return isset($_SERVER['LARAVEL_ENV']) ? $_SERVER['LARAVEL_ENV'] : 'development';
});
*/
/*
$env = $app->detectEnvironment(array(
'development' => ['precise64', 'ubuntu-server-12042-x64-vbox4210'],

View File

@ -8,7 +8,7 @@ var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
function generatePDF(invoice, checkMath) {
var client = invoice.client;
var account = invoice.account;
var currencyId = invoice.currency_id;
var currencyId = client.currency_id;
var invoiceNumber = invoice.invoice_number;
var invoiceDate = invoice.invoice_date ? invoice.invoice_date : '';
var dueDate = invoice.due_date ? invoice.due_date : '';
@ -150,7 +150,7 @@ function generatePDF(invoice, checkMath) {
doc.setFontType("bold");
doc.text(headerLeft, headerY, 'Amount Due');
var balance = formatMoney(invoice.balance, currencyId, true);
var balance = formatMoney(invoice.balance, currencyId);
balanceX = headerRight - (doc.getStringUnitWidth(balance) * doc.internal.getFontSize());
doc.text(balanceX, headerY, balance);
@ -341,6 +341,7 @@ function generatePDF(invoice, checkMath) {
if (invoice.client) {
var clientX = headerRight - (doc.getStringUnitWidth(invoice.client.name) * doc.internal.getFontSize());
}
var numberX = headerRight - (doc.getStringUnitWidth(invoice.invoice_number) * doc.internal.getFontSize());