bug fixes

This commit is contained in:
Hillel Coren 2013-12-31 11:43:39 +02:00
parent b271a71586
commit 9dd1b54d4a
26 changed files with 79 additions and 54 deletions

View File

@ -42,8 +42,8 @@ class SendRecurringInvoices extends Command {
$invoice->invoice_number = $recurInvoice->account->getNextInvoiceNumber(); $invoice->invoice_number = $recurInvoice->account->getNextInvoiceNumber();
$invoice->amount = $recurInvoice->amount; $invoice->amount = $recurInvoice->amount;
$invoice->currency_id = $recurInvoice->currency_id; $invoice->currency_id = $recurInvoice->currency_id;
$invoice->invoice_date = new DateTime(); $invoice->invoice_date = date_create();
$invoice->due_date = new DateTime(); $invoice->due_date = date_create()->modify($invoice->client->payment_terms . ' day');
$invoice->save(); $invoice->save();
foreach ($recurInvoice->invoice_items as $recurItem) foreach ($recurInvoice->invoice_items as $recurItem)

View File

@ -88,6 +88,7 @@ class ClientController extends \BaseController {
'title' => '- New Client', 'title' => '- New Client',
'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get()); 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get());
@ -139,6 +140,7 @@ class ClientController extends \BaseController {
'url' => 'clients/' . $publicId, 'url' => 'clients/' . $publicId,
'title' => '- ' . $client->name, 'title' => '- ' . $client->name,
'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get()); 'countries' => Country::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get());
@ -187,6 +189,7 @@ class ClientController extends \BaseController {
$client->client_size_id = Input::get('client_size_id') ? Input::get('client_size_id') : null; $client->client_size_id = Input::get('client_size_id') ? Input::get('client_size_id') : null;
$client->client_industry_id = Input::get('client_industry_id') ? Input::get('client_industry_id') : null; $client->client_industry_id = Input::get('client_industry_id') ? Input::get('client_industry_id') : null;
$client->currency_id = Input::get('currency_id') ? Input::get('currency_id') : null; $client->currency_id = Input::get('currency_id') ? Input::get('currency_id') : null;
$client->payment_terms = Input::get('payment_terms');
$client->website = trim(Input::get('website')); $client->website = trim(Input::get('website'));
$client->save(); $client->save();

View File

@ -116,7 +116,7 @@ class InvoiceController extends \BaseController {
public function view($invitationKey) public function view($invitationKey)
{ {
$invitation = Invitation::with('user', 'invoice.account', 'invoice.client', 'invoice.invoice_items', 'invoice.client.account.account_gateways') $invitation = Invitation::with('user', 'invoice.invoice_items', 'invoice.client.account', 'invoice.client.contacts')
->where('invitation_key', '=', $invitationKey)->firstOrFail(); ->where('invitation_key', '=', $invitationKey)->firstOrFail();
$user = $invitation->user; $user = $invitation->user;
@ -350,6 +350,7 @@ class InvoiceController extends \BaseController {
'taxRates' => TaxRate::scope()->orderBy('name')->get(), 'taxRates' => TaxRate::scope()->orderBy('name')->get(),
'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'currencies' => Currency::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(), 'clientSizes' => ClientSize::remember(DEFAULT_QUERY_CACHE)->orderBy('id')->get(),
'paymentTerms' => PaymentTerm::remember(DEFAULT_QUERY_CACHE)->orderBy('num_days')->get(['name', 'num_days']),
'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(), 'clientIndustries' => ClientIndustry::remember(DEFAULT_QUERY_CACHE)->orderBy('name')->get(),
'frequencies' => array( 'frequencies' => array(
1 => 'Weekly', 1 => 'Weekly',

View File

@ -9,7 +9,8 @@ class ConfideSetupUsersTable extends Migration {
* @return void * @return void
*/ */
public function up() public function up()
{ {
Schema::dropIfExists('payment_terms');
Schema::dropIfExists('themes'); Schema::dropIfExists('themes');
Schema::dropIfExists('credits'); Schema::dropIfExists('credits');
Schema::dropIfExists('activities'); Schema::dropIfExists('activities');
@ -60,6 +61,13 @@ class ConfideSetupUsersTable extends Migration {
$t->string('name'); $t->string('name');
}); });
Schema::create('payment_terms', function($t)
{
$t->increments('id');
$t->integer('num_days');
$t->string('name');
});
Schema::create('timezones', function($t) Schema::create('timezones', function($t)
{ {
$t->increments('id'); $t->increments('id');
@ -220,6 +228,7 @@ class ConfideSetupUsersTable extends Migration {
$t->unsignedInteger('client_industry_id')->nullable(); $t->unsignedInteger('client_industry_id')->nullable();
$t->unsignedInteger('client_size_id')->nullable(); $t->unsignedInteger('client_size_id')->nullable();
$t->boolean('is_deleted'); $t->boolean('is_deleted');
$t->integer('payment_terms');
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$t->foreign('user_id')->references('id')->on('users'); $t->foreign('user_id')->references('id')->on('users');
@ -293,7 +302,6 @@ class ConfideSetupUsersTable extends Migration {
$t->date('end_date')->nullable(); $t->date('end_date')->nullable();
$t->timestamp('last_sent_date')->nullable(); $t->timestamp('last_sent_date')->nullable();
$t->unsignedInteger('recurring_invoice_id')->index()->nullable(); $t->unsignedInteger('recurring_invoice_id')->index()->nullable();
$t->decimal('amount', 13, 4); $t->decimal('amount', 13, 4);
$t->decimal('balance', 13, 4); $t->decimal('balance', 13, 4);
@ -486,6 +494,7 @@ class ConfideSetupUsersTable extends Migration {
*/ */
public function down() public function down()
{ {
Schema::dropIfExists('payment_terms');
Schema::dropIfExists('themes'); Schema::dropIfExists('themes');
Schema::dropIfExists('credits'); Schema::dropIfExists('credits');
Schema::dropIfExists('activities'); Schema::dropIfExists('activities');

View File

@ -69,10 +69,16 @@ class ConstantsSeeder extends Seeder
ClientSize::create(array('name' => '101 - 500')); ClientSize::create(array('name' => '101 - 500'));
ClientSize::create(array('name' => '500+')); ClientSize::create(array('name' => '500+'));
PaymentTerm::create(array('num_days' => 7, 'name' => 'Net 7'));
PaymentTerm::create(array('num_days' => 10, 'name' => 'Net 10'));
PaymentTerm::create(array('num_days' => 14, 'name' => 'Net 14'));
PaymentTerm::create(array('num_days' => 15, 'name' => 'Net 15'));
PaymentTerm::create(array('num_days' => 30, 'name' => 'Net 30'));
PaymentTerm::create(array('num_days' => 60, 'name' => 'Net 60'));
Currency::create(array('name' => 'US Dollar', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.')); Currency::create(array('name' => 'US Dollar', 'symbol' => '$', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'));
Currency::create(array('name' => 'Pound Sterling', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.')); Currency::create(array('name' => 'Pound Sterling', 'symbol' => '£', 'precision' => '2', 'thousand_separator' => ',', 'decimal_separator' => '.'));
DatetimeFormat::create(array('format' => 'F j, Y, g:i a', 'label' => 'March 10, 2013, 6:15 pm')); DatetimeFormat::create(array('format' => 'F j, Y, g:i a', 'label' => 'March 10, 2013, 6:15 pm'));
DatetimeFormat::create(array('format' => 'D M jS, Y g:ia', 'label' => 'Mon March 10th, 2013, 6:15 pm')); DatetimeFormat::create(array('format' => 'D M jS, Y g:ia', 'label' => 'Mon March 10th, 2013, 6:15 pm'));

View File

@ -3,7 +3,6 @@
class Account extends Eloquent class Account extends Eloquent
{ {
protected $softDelete = true; protected $softDelete = true;
protected $hidden = array('ip', 'timezone_id', 'created_at', 'updated_at', 'deleted_at', 'key', 'last_login');
public function users() public function users()
{ {

View File

@ -2,8 +2,6 @@
class AccountGateway extends Eloquent class AccountGateway extends Eloquent
{ {
protected $hidden = array('config');
public function gateway() public function gateway()
{ {
return $this->belongsTo('Gateway'); return $this->belongsTo('Gateway');

View File

@ -20,8 +20,6 @@ define("ACTIVITY_TYPE_DELETE_CREDIT", 15);
class Activity extends Eloquent class Activity extends Eloquent
{ {
protected $hidden = array('id');
public function scopeScope($query) public function scopeScope($query)
{ {
return $query->whereAccountId(Auth::user()->account_id); return $query->whereAccountId(Auth::user()->account_id);
@ -121,7 +119,7 @@ class Activity extends Eloquent
$activity->invoice_id = $invitation->invoice_id; $activity->invoice_id = $invitation->invoice_id;
$activity->contact_id = $invitation->contact_id; $activity->contact_id = $invitation->contact_id;
$activity->activity_type_id = ACTIVITY_TYPE_EMAIL_INVOICE; $activity->activity_type_id = ACTIVITY_TYPE_EMAIL_INVOICE;
$activity->message = $userName . ' emailed invoice ' . link_to('invoices/'.$invitation->invoice->public_id, $invitation->invoice->invoice_number) . ' to ' . $invitation->contact->getFullName(); $activity->message = $userName . ' emailed invoice ' . link_to('invoices/'.$invitation->invoice->public_id, $invitation->invoice->invoice_number) . ' to ' . $invitation->contact->getFullName() . ' - ' . $invitation->contact->email;
$activity->balance = $invitation->invoice->client->balance; $activity->balance = $invitation->invoice->client->balance;
$activity->adjustment = $adjustment; $activity->adjustment = $adjustment;
$activity->save(); $activity->save();

View File

@ -2,8 +2,6 @@
class Client extends EntityModel class Client extends EntityModel
{ {
protected $hidden = array('id', 'account_id', 'created_at', 'updated_at', 'deleted_at', 'private_notes', 'last_login');
public static $fieldName = 'Client - Name'; public static $fieldName = 'Client - Name';
public static $fieldPhone = 'Client - Phone'; public static $fieldPhone = 'Client - Phone';
public static $fieldAddress1 = 'Client - Street'; public static $fieldAddress1 = 'Client - Street';

View File

@ -2,8 +2,6 @@
class Contact extends EntityModel class Contact extends EntityModel
{ {
protected $hidden = array('id', 'cliend_id', 'created_at', 'updated_at', 'deleted_at', 'last_login');
public static $fieldFirstName = 'Contact - First Name'; public static $fieldFirstName = 'Contact - First Name';
public static $fieldLastName = 'Contact - Last Name'; public static $fieldLastName = 'Contact - Last Name';
public static $fieldEmail = 'Contact - Email'; public static $fieldEmail = 'Contact - Email';

View File

@ -1,7 +1,7 @@
<?php <?php
class Credit extends EntityModel class Credit extends EntityModel
{ {
public function invoice() public function invoice()
{ {
return $this->belongsTo('Invoice'); return $this->belongsTo('Invoice');

View File

@ -3,5 +3,5 @@
class Currency extends Eloquent class Currency extends Eloquent
{ {
public $timestamps = false; public $timestamps = false;
protected $softDelete = false; protected $softDelete = false;
} }

View File

@ -3,8 +3,6 @@
class EntityModel extends Eloquent class EntityModel extends Eloquent
{ {
protected $softDelete = true; protected $softDelete = true;
protected $hidden = array('id', 'created_at', 'updated_at', 'deleted_at');
public static function createNew($parent = false) public static function createNew($parent = false)
{ {
$className = get_called_class(); $className = get_called_class();

View File

@ -2,8 +2,6 @@
class Invitation extends EntityModel class Invitation extends EntityModel
{ {
protected $hidden = array('id', 'account_id', 'user_id', 'contact_id', 'created_at', 'updated_at', 'deleted_at', 'viewed_date');
public function invoice() public function invoice()
{ {
return $this->belongsTo('Invoice'); return $this->belongsTo('Invoice');

View File

@ -2,8 +2,6 @@
class Invoice extends EntityModel class Invoice extends EntityModel
{ {
protected $hidden = array('id', 'account_id', 'client_id', 'created_at', 'updated_at', 'deleted_at', 'viewed_date');
public function account() public function account()
{ {
return $this->belongsTo('Account'); return $this->belongsTo('Account');

7
app/models/PaymentTerm.php Executable file
View File

@ -0,0 +1,7 @@
<?php
class PaymentTerm extends Eloquent
{
public $timestamps = false;
protected $softDelete = false;
}

View File

@ -1,7 +1,7 @@
<?php <?php
class Product extends EntityModel class Product extends EntityModel
{ {
public static function findProductByKey($key) public static function findProductByKey($key)
{ {
return Product::scope()->where('product_key','=',$key)->first(); return Product::scope()->where('product_key','=',$key)->first();

View File

@ -2,6 +2,5 @@
class TaxRate extends EntityModel class TaxRate extends EntityModel
{ {
} }

View File

@ -6,9 +6,7 @@ use Zizaco\Confide\ConfideUser;
class User extends ConfideUser implements UserInterface, RemindableInterface class User extends ConfideUser implements UserInterface, RemindableInterface
{ {
protected $softDelete = true; protected $softDelete = true;
protected $hidden = array('created_at', 'updated_at', 'deleted_at', 'password', 'confirmation_code', 'registered', 'confirmed');
public static $rules = array( public static $rules = array(
/* /*

View File

@ -31,6 +31,7 @@ class ClientRepository
$client->client_size_id = $data['client_size_id'] ? $data['client_size_id'] : null; $client->client_size_id = $data['client_size_id'] ? $data['client_size_id'] : null;
$client->client_industry_id = $data['client_industry_id'] ? $data['client_industry_id'] : null; $client->client_industry_id = $data['client_industry_id'] ? $data['client_industry_id'] : null;
$client->currency_id = $data['currency_id'] ? $data['currency_id'] : null; $client->currency_id = $data['currency_id'] ? $data['currency_id'] : null;
$client->payment_terms = $data['payment_terms'];
$client->website = trim($data['website']); $client->website = trim($data['website']);
$client->save(); $client->save();
@ -41,7 +42,7 @@ class ClientRepository
{ {
$record = (array) $record; $record = (array) $record;
if (isset($record['public_id']) && $record['public_id']) if ($publicId != "-1" && isset($record['public_id']) && $record['public_id'])
{ {
$contact = Contact::scope($record['public_id'])->firstOrFail(); $contact = Contact::scope($record['public_id'])->firstOrFail();
} }

View File

@ -44,6 +44,8 @@
</div> </div>
{{ Former::legend('Additional Info') }} {{ Former::legend('Additional Info') }}
{{ Former::select('payment_terms')->addOption('','')
->fromQuery($paymentTerms, 'name', 'num_days') }}
{{ Former::select('currency_id')->addOption('','')->label('Currency') {{ Former::select('currency_id')->addOption('','')->label('Currency')
->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) }} ->fromQuery($currencies, 'name', 'id')->select(Session::get(SESSION_CURRENCY, DEFAULT_CURRENCY)) }}
{{ Former::select('client_size_id')->addOption('','')->label('Size') {{ Former::select('client_size_id')->addOption('','')->label('Size')

View File

@ -35,10 +35,10 @@
</div> </div>
<h2>{{ $client->name }}</h2> <h2>{{ $client->getDisplayName() }}</h2>
@if ($client->last_login > 0) @if ($client->last_login > 0)
<h3 style="margin-top:0px"><small> <h3 style="margin-top:0px"><small>
Last logged in {{ Utils::timestampToDateTimeString($client->last_login); }} Last logged in {{ Utils::timestampToDateTimeString(strtotime($client->last_login)); }}
</small></h3> </small></h3>
@endif @endif
@ -50,7 +50,8 @@
<p>{{ $client->getPhone() }}</p> <p>{{ $client->getPhone() }}</p>
<p>{{ $client->getNotes() }}</p> <p>{{ $client->getNotes() }}</p>
<p>{{ $client->getIndustry() }}</p> <p>{{ $client->getIndustry() }}</p>
<p>{{ $client->getWebsite() }} <p>{{ $client->getWebsite() }}</p>
<p>{{ $client->payment_terms ? "Payment terms: Net " . $client->payment_terms : '' }}</p>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">

View File

@ -66,13 +66,8 @@
@section('body') @section('body')
<div class="container"> <div class="container">
<p/> <p>&nbsp;</p>
<div> <p>&nbsp;</p>
<a href="{{ URL::to('/') }}" style="font-size:30px;color:black">Invoice Ninja</a>
</div>
<p style="clear: both"/>
<nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="navbar-header"> <div class="navbar-header">
@ -172,7 +167,7 @@
{{ Former::close() }} {{ Former::close() }}
</div> </div>
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') }}. Need 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> <p class="text-danger">This is a demo site, the data is erased.</p>
</div> </div>

View File

@ -123,16 +123,16 @@
->raw()->data_bind("value: product_key, valueUpdate: 'afterkeydown'")->addClass('datalist') }} ->raw()->data_bind("value: product_key, valueUpdate: 'afterkeydown'")->addClass('datalist') }}
</td> </td>
<td style="width:300px"> <td style="width:300px">
<textarea data-bind="value: wrapped_notes, valueUpdate: 'afterkeydown'" rows="1" cols="60" style="resize: none;" class="form-control word-wrap" onchange="refreshPDF()"></textarea> <textarea data-bind="value: wrapped_notes, valueUpdate: 'afterkeydown'" rows="1" cols="60" style="resize: none;" class="form-control word-wrap"></textarea>
</td> </td>
<td style="width:100px"> <td style="width:100px">
<input onkeyup="onItemChange()" data-bind="value: prettyCost, valueUpdate: 'afterkeydown'" style="text-align: right" class="form-control" onchange="refreshPDF()"//> <input onkeyup="onItemChange()" data-bind="value: prettyCost, valueUpdate: 'afterkeydown'" style="text-align: right" class="form-control"//>
</td> </td>
<td style="width:80px"> <td style="width:80px">
<input onkeyup="onItemChange()" data-bind="value: prettyQty, valueUpdate: 'afterkeydown'" style="text-align: right" class="form-control" onchange="refreshPDF()"//> <input onkeyup="onItemChange()" data-bind="value: prettyQty, valueUpdate: 'afterkeydown'" style="text-align: right" class="form-control"//>
</td> </td>
<td style="width:120px; vertical-align:middle" data-bind="visible: $parent.tax_rates().length > 1"> <td style="width:120px; vertical-align:middle" data-bind="visible: $parent.tax_rates().length > 1">
<select class="form-control" style="width:100%" data-bind="value: tax, options: $parent.tax_rates, optionsText: 'displayName'" onchange="refreshPDF()"></select> <select class="form-control" style="width:100%" data-bind="value: tax, options: $parent.tax_rates, optionsText: 'displayName'"></select>
</td> </td>
<td style="width:100px;text-align: right;padding-top:9px !important"> <td style="width:100px;text-align: right;padding-top:9px !important">
<span data-bind="text: total"></span> <span data-bind="text: total"></span>
@ -242,6 +242,8 @@
</div> </div>
{{ Former::legend('Additional Info') }} {{ Former::legend('Additional Info') }}
{{ Former::select('payment_terms')->addOption('','')->data_bind('value: payment_terms')
->fromQuery($paymentTerms, 'name', 'num_days') }}
{{ Former::select('currency_id')->addOption('','')->label('Currency')->data_bind('value: currency_id') {{ Former::select('currency_id')->addOption('','')->label('Currency')->data_bind('value: currency_id')
->fromQuery($currencies, 'name', 'id') }} ->fromQuery($currencies, 'name', 'id') }}
{{ Former::select('client_size_id')->addOption('','')->label('Size')->data_bind('value: client_size_id') {{ Former::select('client_size_id')->addOption('','')->label('Size')->data_bind('value: client_size_id')
@ -274,7 +276,7 @@
</div> </div>
<div class="modal-footer" style="margin-top: 0px"> <div class="modal-footer" style="margin-top: 0px">
<span class="error-block" id="emailError" style="display:none;float:left">Please provide a valid email address.</span><span>&nbsp;</span> <span class="error-block" id="emailError" style="display:none;float:left;font-weight:bold">Please provide a valid email address.</span><span>&nbsp;</span>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" data-bind="click: clientFormComplete">Done</button> <button type="button" class="btn btn-primary" data-bind="click: clientFormComplete">Done</button>
</div> </div>
@ -360,7 +362,8 @@
if (clientId > 0) { if (clientId > 0) {
model.loadClient(clientMap[clientId]); model.loadClient(clientMap[clientId]);
} else { } else {
model.client.public_id(0); // TODO_FIX //model.client.public_id(0); // TODO_FIX
model.loadClient(new ClientModel());
} }
refreshPDF(); refreshPDF();
}).trigger('change'); }).trigger('change');
@ -408,7 +411,12 @@
}); });
function applyComboboxListeners() { function applyComboboxListeners() {
var value; $('.invoice-table input, .invoice-table select, .invoice-table textarea').on('blur', function() {
//if (value != $(this).val()) refreshPDF();
refreshPDF();
});
var value;
$('.datalist').on('focus', function() { $('.datalist').on('focus', function() {
value = $(this).val(); value = $(this).val();
}).on('blur', function() { }).on('blur', function() {
@ -617,12 +625,18 @@
self.showClientForm = function() { self.showClientForm = function() {
self.clientBackup = ko.mapping.toJS(self.client); self.clientBackup = ko.mapping.toJS(self.client);
//console.log(self.clientBackup); //console.log(self.clientBackup);
/*
if (self.client.public_id() == 0) { if (self.client.public_id() == 0) {
$('#clientModal input').val(''); $('#clientModal input').val('');
$('#clientModal #payment_terms').val('');
$('#clientModal #country_id').val(''); $('#clientModal #country_id').val('');
$('#clientModal #currency_id').val('');
$('#clientModal #client_size_id').val('');
$('#clientModal #client_industry_id').val('');
} }
*/
$('#emailError').css( "display", "none" ); $('#emailError').css( "display", "none" );
$('#clientModal').modal('show'); $('#clientModal').modal('show');
} }
@ -735,6 +749,7 @@
self.client_industry_id = ko.observable(''); self.client_industry_id = ko.observable('');
self.currency_id = ko.observable(''); self.currency_id = ko.observable('');
self.website = ko.observable(''); self.website = ko.observable('');
self.payment_terms = ko.observable();
self.contacts = ko.observableArray(); self.contacts = ko.observableArray();
self.mapping = { self.mapping = {

View File

@ -31,12 +31,10 @@
@endif @endif
var doc = generatePDF(invoice); var doc = generatePDF(invoice);
var string = doc.output('datauristring'); var string = doc.output('datauristring');
alert(isFirefox);
alert(isChrome);
if (isFirefox || isChrome) { if (isFirefox || isChrome) {
$('#theFrame').attr('src', string).show(); $('#theFrame').attr('src', string).show();
} else { } else {
alert(1);
var pdfAsArray = convertDataURIToBinary(string); var pdfAsArray = convertDataURIToBinary(string);
PDFJS.getDocument(pdfAsArray).then(function getPdfHelloWorld(pdf) { PDFJS.getDocument(pdfAsArray).then(function getPdfHelloWorld(pdf) {

View File

@ -631,8 +631,13 @@ ko.bindingHandlers.dropdown = {
var value = ko.utils.unwrapObservable(valueAccessor()); var value = ko.utils.unwrapObservable(valueAccessor());
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false; var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
console.log("combo-update: %s", id); console.log("combo-update: %s", id);
if (id) $(element).val(id); if (id) {
$(element).combobox('refresh'); $(element).val(id);
$(element).combobox('refresh');
} else {
$(element).combobox('clearTarget');
$(element).combobox('clearElement');
}
} }
}; };