mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-21 07:20:56 -04:00
bug fixes
This commit is contained in:
parent
309442cab3
commit
fff1aa69d3
@ -506,10 +506,10 @@ class AccountController extends \BaseController {
|
||||
public function submitSignup()
|
||||
{
|
||||
$rules = array(
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'password' => 'required|min:6',
|
||||
'email' => 'email|required'
|
||||
'new_first_name' => 'required',
|
||||
'new_last_name' => 'required',
|
||||
'new_password' => 'required|min:6',
|
||||
'new_email' => 'email|required'
|
||||
);
|
||||
|
||||
$validator = Validator::make(Input::all(), $rules);
|
||||
@ -528,7 +528,8 @@ class AccountController extends \BaseController {
|
||||
$user->save();
|
||||
|
||||
$activities = Activity::scope()->get();
|
||||
foreach ($activities as $activity) {
|
||||
foreach ($activities as $activity)
|
||||
{
|
||||
$activity->message = str_replace('Guest', $user->getFullName(), $activity->message);
|
||||
$activity->save();
|
||||
}
|
||||
|
@ -114,11 +114,11 @@ class ClientController extends \BaseController {
|
||||
public function show($publicId)
|
||||
{
|
||||
$client = Client::scope($publicId)->with('contacts', 'client_size', 'client_industry')->firstOrFail();
|
||||
Utils::trackViewed($client->name, ENTITY_CLIENT);
|
||||
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT);
|
||||
|
||||
$data = array(
|
||||
'client' => $client,
|
||||
'title' => '- ' . $client->name,
|
||||
'title' => '- ' . $client->getDisplayName(),
|
||||
'hasRecurringInvoices' => Invoice::scope()->where('is_recurring', '=', true)->whereClientId($client->id)->count() > 0
|
||||
);
|
||||
|
||||
|
@ -85,6 +85,8 @@ class CreditController extends \BaseController {
|
||||
public function edit($publicId)
|
||||
{
|
||||
$credit = Credit::scope($publicId)->firstOrFail();
|
||||
$credit->credit_date = Utils::fromSqlDate($credit->credit_date);
|
||||
|
||||
$data = array(
|
||||
'client' => null,
|
||||
'credit' => $credit,
|
||||
@ -126,7 +128,7 @@ class CreditController extends \BaseController {
|
||||
$credit = Credit::createNew();
|
||||
}
|
||||
|
||||
$credit->client_id = Input::get('client');
|
||||
$credit->client_id = Client::getPrivateId(Input::get('client'));
|
||||
$credit->credit_date = Utils::toSqlDate(Input::get('credit_date'));
|
||||
$credit->amount = floatval(Input::get('amount'));
|
||||
$credit->currency_id = Input::get('currency_id') ? Input::get('currency_id') : null;
|
||||
@ -134,7 +136,7 @@ class CreditController extends \BaseController {
|
||||
|
||||
$message = $publicId ? 'Successfully updated credit' : 'Successfully created credit';
|
||||
Session::flash('message', $message);
|
||||
return Redirect::to('clients/' . $credit->client_id);
|
||||
return Redirect::to('clients/' . Input::get('client'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,8 +300,13 @@ class InvoiceController extends \BaseController {
|
||||
public function edit($publicId)
|
||||
{
|
||||
$invoice = Invoice::scope($publicId)->with('account.country', 'client', 'invoice_items')->firstOrFail();
|
||||
Utils::trackViewed($invoice->invoice_number . ' - ' . $invoice->client->name, ENTITY_INVOICE);
|
||||
Utils::trackViewed($invoice->invoice_number . ' - ' . $invoice->client->getDisplayName(), ENTITY_INVOICE);
|
||||
|
||||
$invoice->invoice_date = Utils::fromSqlDate($invoice->invoice_date);
|
||||
$invoice->due_date = Utils::fromSqlDate($invoice->due_date);
|
||||
$invoice->start_date = Utils::fromSqlDate($invoice->start_date);
|
||||
$invoice->end_date = Utils::fromSqlDate($invoice->end_date);
|
||||
|
||||
$contactIds = DB::table('invitations')
|
||||
->join('contacts', 'contacts.id', '=','invitations.contact_id')
|
||||
->where('invitations.invoice_id', '=', $invoice->id)
|
||||
@ -453,7 +458,7 @@ class InvoiceController extends \BaseController {
|
||||
{
|
||||
$message = ' and created client';
|
||||
$url = URL::to('clients/' . $client->public_id);
|
||||
Utils::trackViewed($client->name, ENTITY_CLIENT, $url);
|
||||
Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT, $url);
|
||||
}
|
||||
|
||||
if ($action == 'clone')
|
||||
|
@ -89,6 +89,8 @@ class PaymentController extends \BaseController
|
||||
public function edit($publicId)
|
||||
{
|
||||
$payment = Payment::scope($publicId)->firstOrFail();
|
||||
$payment->payment_date = Utils::fromSqlDate($payment->payment_date);
|
||||
|
||||
$data = array(
|
||||
'client' => null,
|
||||
'invoice' => null,
|
||||
@ -132,9 +134,9 @@ class PaymentController extends \BaseController
|
||||
$payment = Payment::createNew();
|
||||
}
|
||||
|
||||
$invoiceId = Input::get('invoice') && Input::get('invoice') != "-1" ? Input::get('invoice') : null;
|
||||
$invoiceId = Input::get('invoice') && Input::get('invoice') != "-1" ? Invoice::getPrivateId(Input::get('invoice')) : null;
|
||||
|
||||
$payment->client_id = Input::get('client');
|
||||
$payment->client_id = Client::getPrivateId(Input::get('client'));
|
||||
$payment->invoice_id = $invoiceId;
|
||||
$payment->currency_id = Input::get('currency_id') ? Input::get('currency_id') : null;
|
||||
$payment->payment_date = Utils::toSqlDate(Input::get('payment_date'));
|
||||
@ -143,7 +145,7 @@ class PaymentController extends \BaseController
|
||||
|
||||
$message = $publicId ? 'Successfully updated payment' : 'Successfully created payment';
|
||||
Session::flash('message', $message);
|
||||
return Redirect::to('clients/' . $payment->client_id);
|
||||
return Redirect::to('clients/' . Input::get('client'));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,15 +8,15 @@ class ReportController extends \BaseController {
|
||||
{
|
||||
$groupBy = Input::get('group_by');
|
||||
$chartType = Input::get('chart_type');
|
||||
$startDate = date_create(Input::get('start_date'));
|
||||
$endDate = date_create(Input::get('end_date'));
|
||||
$startDate = Utils::toSqlDate(Input::get('start_date'), false);
|
||||
$endDate = Utils::toSqlDate(Input::get('end_date'), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$groupBy = 'MONTH';
|
||||
$chartType = 'Bar';
|
||||
$startDate = date_create()->modify('-3 month');
|
||||
$endDate = date_create();
|
||||
$startDate = Utils::today(false)->modify('-3 month');
|
||||
$endDate = Utils::today(false);
|
||||
}
|
||||
|
||||
$padding = $groupBy == 'DAYOFYEAR' ? 'day' : ($groupBy == 'WEEK' ? 'week' : 'month');
|
||||
@ -90,8 +90,8 @@ class ReportController extends \BaseController {
|
||||
'dateTypes' => $dateTypes,
|
||||
'chartTypes' => $chartTypes,
|
||||
'chartType' => $chartType,
|
||||
'startDate' => $startDate->format('m/d/Y'),
|
||||
'endDate' => $endDate->modify('-1'.$padding)->format('m/d/Y'),
|
||||
'startDate' => $startDate->format(Session::get(SESSION_DATE_FORMAT)),
|
||||
'endDate' => $endDate->modify('-1'.$padding)->format(Session::get(SESSION_DATE_FORMAT)),
|
||||
'groupBy' => $groupBy
|
||||
];
|
||||
|
||||
|
@ -233,8 +233,8 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->boolean('is_deleted');
|
||||
$t->integer('payment_terms');
|
||||
|
||||
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
$t->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$t->foreign('country_id')->references('id')->on('countries');
|
||||
$t->foreign('client_industry_id')->references('id')->on('client_industries');
|
||||
$t->foreign('client_size_id')->references('id')->on('client_sizes');
|
||||
@ -262,7 +262,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->timestamp('last_login');
|
||||
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');;
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
@ -314,7 +314,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
$t->foreign('account_id')->references('id')->on('accounts');
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
$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');
|
||||
@ -338,7 +338,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->timestamp('sent_date');
|
||||
$t->timestamp('viewed_date');
|
||||
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');;
|
||||
$t->foreign('contact_id')->references('id')->on('contacts')->onDelete('cascade');
|
||||
$t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
|
||||
|
||||
@ -358,7 +358,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->decimal('rate', 13, 4);
|
||||
|
||||
$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')->onDelete('cascade');;
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
@ -378,7 +378,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->decimal('qty', 13, 4);
|
||||
|
||||
$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')->onDelete('cascade');;
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
@ -405,7 +405,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
|
||||
$t->foreign('invoice_id')->references('id')->on('invoices')->onDelete('cascade');
|
||||
$t->foreign('product_id')->references('id')->on('products');
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');;
|
||||
|
||||
$t->unsignedInteger('public_id');
|
||||
$t->unique( array('account_id','public_id') );
|
||||
@ -434,7 +434,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->foreign('account_id')->references('id')->on('accounts');
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
$t->foreign('contact_id')->references('id')->on('contacts');
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');;
|
||||
$t->foreign('currency_id')->references('id')->on('currencies');
|
||||
|
||||
$t->unsignedInteger('public_id')->index();
|
||||
@ -460,7 +460,7 @@ class ConfideSetupUsersTable extends Migration {
|
||||
$t->foreign('account_id')->references('id')->on('accounts');
|
||||
$t->foreign('client_id')->references('id')->on('clients')->onDelete('cascade');
|
||||
$t->foreign('contact_id')->references('id')->on('contacts');
|
||||
$t->foreign('user_id')->references('id')->on('users');
|
||||
$t->foreign('user_id')->references('id')->on('users')->onDelete('cascade');;
|
||||
$t->foreign('currency_id')->references('id')->on('currencies');
|
||||
|
||||
$t->unsignedInteger('public_id')->index();
|
||||
|
@ -83,7 +83,7 @@ class ConstantsSeeder extends Seeder
|
||||
DatetimeFormat::create(array('format' => 'D M jS, Y g:ia', 'label' => 'Mon March 10th, 2013, 6:15 pm'));
|
||||
|
||||
DateFormat::create(array('format' => 'F j, Y', 'picker_format' => 'MM d, yyyy', 'label' => 'March 10, 2013'));
|
||||
DateFormat::create(array('format' => 'D M jS, Y', 'picker_format' => 'D MM d, yyyy', 'label' => 'Mon March 10th, 2013'));
|
||||
DateFormat::create(array('format' => 'D M j, Y', 'picker_format' => 'D MM d, yyyy', 'label' => 'Mon March 10, 2013'));
|
||||
|
||||
/*
|
||||
d, dd: Numeric date, no leading zero and leading zero, respectively. Eg, 5, 05.
|
||||
|
@ -35,7 +35,7 @@ App::after(function($request, $response)
|
||||
|
||||
Route::filter('auth', function()
|
||||
{
|
||||
if (Auth::guest()) return Redirect::guest('login');
|
||||
if (Auth::guest()) return Redirect::guest('/');
|
||||
});
|
||||
|
||||
|
||||
|
@ -107,13 +107,10 @@ class Utils
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT);
|
||||
return DateTime::createFromFormat($format, $date, new DateTimeZone($timezone));
|
||||
*/
|
||||
$timezone = Session::get(SESSION_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT);
|
||||
|
||||
return DateTime::createFromFormat('Y-m-d', $date);
|
||||
return DateTime::createFromFormat($format, $date, new DateTimeZone($timezone));
|
||||
}
|
||||
|
||||
public static function fromSqlDate($date)
|
||||
@ -123,14 +120,26 @@ class Utils
|
||||
return '';
|
||||
}
|
||||
|
||||
/*
|
||||
$timezone = Session::get(SESSION_TIMEZONE, DEFAULT_TIMEZONE);
|
||||
$timezone = Session::get(SESSION_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT);
|
||||
|
||||
return DateTime::createFromFormat('Y-m-d', $date, new DateTimeZone($timezone))->format($format);
|
||||
*/
|
||||
|
||||
$format = Session::get(SESSION_DATE_FORMAT, DEFAULT_DATE_FORMAT);
|
||||
|
||||
return DateTime::createFromFormat('Y-m-d', $date)->format($format);
|
||||
}
|
||||
|
||||
public static function today($formatResult = true)
|
||||
{
|
||||
$timezone = Session::get(SESSION_TIMEZONE);
|
||||
$format = Session::get(SESSION_DATE_FORMAT);
|
||||
$date = date_create(null, new DateTimeZone($timezone));
|
||||
|
||||
if ($formatResult)
|
||||
{
|
||||
return $date->format($format);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $date;
|
||||
}
|
||||
}
|
||||
|
||||
public static function trackViewed($name, $type, $url = false)
|
||||
|
@ -93,14 +93,18 @@ class InvoiceRepository
|
||||
$invoice->public_notes = trim($data['public_notes']);
|
||||
$invoice->po_number = trim($data['po_number']);
|
||||
$invoice->currency_id = $data['currency_id'];
|
||||
$invoice->tax_rate = 0;
|
||||
|
||||
|
||||
if (isset($data['tax']) && isset($data['tax']->rate) && floatval($data['tax']->rate) > 0)
|
||||
{
|
||||
$invoice->tax_rate = floatval($data['tax']->rate);
|
||||
$invoice->tax_name = trim($data['tax']->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
$invoice->tax_rate = 0;
|
||||
$invoice->tax_name = '';
|
||||
}
|
||||
|
||||
|
||||
$invoice->save();
|
||||
$invoice->invoice_items()->forceDelete();
|
||||
|
||||
|
@ -47,14 +47,6 @@ Route::post('forgot_password', 'UserController@do_forgot_password');
|
||||
Route::get('logout', 'UserController@logout');
|
||||
|
||||
|
||||
Route::filter('auth', function()
|
||||
{
|
||||
if (!Auth::check())
|
||||
{
|
||||
return Redirect::to('/');
|
||||
}
|
||||
});
|
||||
|
||||
Route::group(array('before' => 'auth'), function()
|
||||
{
|
||||
Route::get('home', function() { return View::make('header'); });
|
||||
@ -178,7 +170,6 @@ define('SESSION_DATETIME_FORMAT', 'datetimeFormat');
|
||||
define('DEFAULT_TIMEZONE', 'US/Eastern');
|
||||
define('DEFAULT_CURRENCY', 1); // US Dollar
|
||||
define('DEFAULT_DATE_FORMAT', 'M j, Y');
|
||||
define('DEFAULT_DATE_PICKER_FORMAT', 'yyyy-mm-dd');
|
||||
define('DEFAULT_DATE_PICKER_FORMAT', 'M d, yyyy');
|
||||
define('DEFAULT_DATETIME_FORMAT', 'F j, Y, g:i a');
|
||||
|
||||
define('DEFAULT_QUERY_CACHE', 120);
|
@ -16,7 +16,7 @@
|
||||
@if ($credit)
|
||||
{{ Former::populate($credit) }}
|
||||
@else
|
||||
{{ Former::populateField('credit_date', date('Y-m-d')) }}
|
||||
{{ Former::populateField('credit_date', Utils::today()) }}
|
||||
@endif
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
{{ Former::select('client')->addOption('', '')->addGroupClass('client-select') }}
|
||||
{{ Former::text('amount') }}
|
||||
{{ Former::text('credit_date')->data_date_format(DEFAULT_DATE_PICKER_FORMAT) }}
|
||||
{{ 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)) }}
|
||||
|
||||
@ -68,7 +68,8 @@
|
||||
|
||||
$('#credit_date').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true
|
||||
todayHighlight: true,
|
||||
keyboardNavigation: false
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -167,7 +167,7 @@
|
||||
{{ Former::close() }}
|
||||
</div>
|
||||
|
||||
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') }}.
|
||||
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>
|
||||
@ -185,15 +185,19 @@
|
||||
</div>
|
||||
|
||||
<div style="padding-right:20px" id="signUpDiv" onkeyup="validateSignUp()" onkeydown="checkForEnter(event)">
|
||||
|
||||
{{ Former::open('signup/submit')->addClass('signUpForm') }}
|
||||
|
||||
@if (Auth::check())
|
||||
{{ Former::populate(Auth::user()) }}
|
||||
{{ Former::populateField('new_first_name', Auth::user()->first_name); }}
|
||||
{{ Former::populateField('new_last_name', Auth::user()->last_name); }}
|
||||
{{ Former::populateField('new_email', Auth::user()->email); }}
|
||||
@endif
|
||||
{{ Former::hidden('path')->value(Request::path()) }}
|
||||
{{ Former::text('first_name') }}
|
||||
{{ Former::text('last_name') }}
|
||||
{{ Former::text('email') }}
|
||||
{{ Former::password('password') }}
|
||||
{{ Former::text('new_first_name')->label('First name') }}
|
||||
{{ Former::text('new_last_name')->label('Last name') }}
|
||||
{{ Former::text('new_email')->label('Email') }}
|
||||
{{ Former::password('new_password')->label('Password') }}
|
||||
{{ Former::close() }}
|
||||
<center><div id="errorTaken" style="display:none"> <br/>The email address is already regiestered</div></center>
|
||||
</div>
|
||||
@ -224,7 +228,7 @@
|
||||
|
||||
<div class="container">
|
||||
<h3>Are you sure?</h3>
|
||||
<p>This will erase all of your data.</p>
|
||||
<p>This will permanently erase your data.</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer" id="signUpFooter">
|
||||
@ -253,7 +257,7 @@
|
||||
{
|
||||
var isFormValid = true;
|
||||
$(['first_name','last_name','email','password']).each(function(i, field) {
|
||||
var $input = $('form.signUpForm #'+field),
|
||||
var $input = $('form.signUpForm #new_'+field),
|
||||
val = $.trim($input.val());
|
||||
var isValid = val && val.length >= (field == 'password' ? 6 : 1);
|
||||
if (isValid && field == 'email') {
|
||||
@ -372,6 +376,12 @@
|
||||
*/
|
||||
@endif
|
||||
|
||||
@if (Session::has('message'))
|
||||
setTimeout(function() {
|
||||
$('.alert-info').fadeOut();
|
||||
}, 5000);
|
||||
@endif
|
||||
|
||||
@yield('onReady')
|
||||
});
|
||||
|
||||
|
@ -60,13 +60,13 @@
|
||||
<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("value: invoice_date, valueUpdate: 'afterkeydown'")->data_date_format(DEFAULT_DATE_PICKER_FORMAT) }}
|
||||
{{ Former::text('due_date')->data_bind("value: due_date, valueUpdate: 'afterkeydown'")->data_date_format(DEFAULT_DATE_PICKER_FORMAT) }}
|
||||
{{ Former::text('invoice_date')->data_bind("value: invoice_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
|
||||
{{ Former::text('due_date')->data_bind("value: due_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
|
||||
</div>
|
||||
<div data-bind="visible: is_recurring">
|
||||
{{ Former::select('frequency_id')->label('How often')->options($frequencies)->data_bind("value: frequency_id") }}
|
||||
{{ Former::text('start_date')->data_bind("value: start_date, valueUpdate: 'afterkeydown'")->data_date_format(DEFAULT_DATE_PICKER_FORMAT) }}
|
||||
{{ Former::text('end_date')->data_bind("value: end_date, valueUpdate: 'afterkeydown'")->data_date_format(DEFAULT_DATE_PICKER_FORMAT) }}
|
||||
{{ Former::text('start_date')->data_bind("value: start_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
|
||||
{{ Former::text('end_date')->data_bind("value: end_date, valueUpdate: 'afterkeydown'")->data_date_format(Session::get(SESSION_DATE_PICKER_FORMAT)) }}
|
||||
</div>
|
||||
@if ($invoice && $invoice->recurring_invoice_id)
|
||||
<div class="pull-right" style="padding-top: 6px">
|
||||
@ -202,12 +202,12 @@
|
||||
array('Delete Invoice', "javascript:onDeleteClick()"),
|
||||
)
|
||||
)
|
||||
, array('id'=>'actionDropDown','style'=>'text-align:left'))->split(); }}
|
||||
, array('id'=>'actionDropDown', 'style'=>'text-align:left', 'data-bind'=>'css: saveButtonEnabled'))->split(); }}
|
||||
@else
|
||||
{{ Button::primary_submit('Save Invoice') }}
|
||||
{{ Button::primary_submit('Save Invoice', array('data-bind'=>'css: saveButtonEnabled')) }}
|
||||
@endif
|
||||
|
||||
{{ Button::primary('Send Email', array('id' => 'email_button', 'onclick' => 'onEmailClick()')) }}
|
||||
{{ Button::primary('Send Email', array('id' => 'email_button', 'onclick' => 'onEmailClick()', 'data-bind' => 'css: emailButtonEnabled')) }}
|
||||
</div>
|
||||
<p> </p>
|
||||
|
||||
@ -358,14 +358,10 @@
|
||||
$('#country_id').combobox();
|
||||
$('[rel=tooltip]').tooltip();
|
||||
|
||||
$('#invoice_date').datepicker({
|
||||
$('#invoice_date, #due_date, #start_date, #end_date').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true
|
||||
});
|
||||
|
||||
$('#due_date, #start_date, #end_date').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true
|
||||
todayHighlight: true,
|
||||
keyboardNavigation: false
|
||||
});
|
||||
|
||||
@if ($client && !$invoice)
|
||||
@ -378,7 +374,7 @@
|
||||
if (clientId > 0) {
|
||||
model.loadClient(clientMap[clientId]);
|
||||
} else {
|
||||
model.loadClient(new ClientModel());
|
||||
model.loadClient($.parseJSON(ko.toJSON(new ClientModel())));
|
||||
}
|
||||
refreshPDF();
|
||||
}).trigger('change');
|
||||
@ -476,14 +472,15 @@
|
||||
return invoice;
|
||||
}
|
||||
|
||||
/*
|
||||
function refreshPDF() {
|
||||
setTimeout(function() {
|
||||
_refreshPDF();
|
||||
}, 100);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
function _refreshPDF() {
|
||||
function refreshPDF() {
|
||||
console.log("refreshPDF");
|
||||
var invoice = createInvoiceModel();
|
||||
var doc = generatePDF(invoice);
|
||||
@ -576,7 +573,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function InvoiceModel() {
|
||||
function InvoiceModel(data) {
|
||||
var self = this;
|
||||
this.client = new ClientModel();
|
||||
self.discount = ko.observable('');
|
||||
@ -590,7 +587,7 @@
|
||||
self.due_date = ko.observable('');
|
||||
self.start_date = ko.observable('');
|
||||
self.end_date = ko.observable('');
|
||||
self.tax = ko.observable('');
|
||||
self.tax = ko.observable();
|
||||
self.is_recurring = ko.observable(false);
|
||||
self.invoice_status_id = ko.observable(0);
|
||||
|
||||
@ -607,7 +604,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.loadClient = function(client) {
|
||||
//console.log(client);
|
||||
ko.mapping.fromJS(client, model.client.mapping, model.client);
|
||||
@ -632,7 +628,7 @@
|
||||
}
|
||||
if (self.tax() && self.tax().rate() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
@ -667,6 +663,39 @@
|
||||
return self.client.public_id() ? 'Edit client details' : 'Create new client';
|
||||
});
|
||||
|
||||
self.saveButtonEnabled = ko.computed(function() {
|
||||
var isValid = false;
|
||||
|
||||
for (var i=0; i<self.client.contacts().length; i++) {
|
||||
var contact = self.client.contacts()[i];
|
||||
if (isValidEmailAddress(contact.email())) {
|
||||
isValid = true;
|
||||
} else {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isValid ? "enabled" : "disabled";
|
||||
});
|
||||
|
||||
self.emailButtonEnabled = ko.computed(function() {
|
||||
var isValid = false;
|
||||
var sendTo = false;
|
||||
for (var i=0; i<self.client.contacts().length; i++) {
|
||||
var contact = self.client.contacts()[i];
|
||||
if (isValidEmailAddress(contact.email())) {
|
||||
isValid = true;
|
||||
if (contact.send_invoice()) {
|
||||
sendTo = true;
|
||||
}
|
||||
} else {
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isValid && sendTo ? "enabled" : "disabled";
|
||||
});
|
||||
|
||||
self.showTaxesForm = function() {
|
||||
self.taxBackup = ko.mapping.toJS(self.tax_rates);
|
||||
|
||||
@ -809,7 +838,7 @@
|
||||
|
||||
self.onDragged = function(item) {
|
||||
refreshPDF();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function ClientModel(data) {
|
||||
@ -1087,9 +1116,17 @@
|
||||
model.addTaxRate({{ $taxRate }});
|
||||
@endforeach
|
||||
model.addTaxRate();
|
||||
model.tax(model.getBlankTaxRate());
|
||||
@if ($invoice)
|
||||
var invoice = {{ $invoice }};
|
||||
ko.mapping.fromJS(invoice, model.mapping, model);
|
||||
for (var i=0; i<model.tax_rates().length; i++) {
|
||||
var taxRate = model.tax_rates()[i];
|
||||
if (model.tax_name() == taxRate.name() && model.tax_rate() == taxRate.rate()) {
|
||||
model.tax(taxRate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!model.discount()) model.discount('');
|
||||
var invitationContactIds = {{ json_encode($invitationContactIds) }};
|
||||
var client = clientMap[invoice.client.public_id];
|
||||
@ -1098,8 +1135,8 @@
|
||||
contact.send_invoice = invitationContactIds.indexOf(contact.public_id) >= 0;
|
||||
}
|
||||
@else
|
||||
model.invoice_date('{{ date('Y-m-d') }}');
|
||||
model.start_date('{{ date('Y-m-d') }}');
|
||||
model.invoice_date('{{ Utils::today() }}');
|
||||
model.start_date('{{ Utils::today() }}');
|
||||
model.invoice_number('{{ $invoiceNumber }}');
|
||||
model.terms(wordWrapText('{{ $account->invoice_terms }}', 340));
|
||||
@endif
|
||||
|
@ -17,7 +17,7 @@
|
||||
@if ($payment)
|
||||
{{-- Former::populate($payment) --}}
|
||||
@else
|
||||
{{ Former::populateField('payment_date', date('Y-m-d')) }}
|
||||
{{ Former::populateField('payment_date', Utils::today()) }}
|
||||
@endif
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
{{ Former::select('client')->addOption('', '')->addGroupClass('client-select') }}
|
||||
{{ Former::select('invoice')->addOption('', '')->addGroupClass('invoice-select') }}
|
||||
{{ Former::text('amount') }}
|
||||
{{ Former::text('payment_date')->data_date_format(DEFAULT_DATE_PICKER_FORMAT) }}
|
||||
{{ 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)) }}
|
||||
|
||||
@ -140,7 +140,8 @@
|
||||
|
||||
$('#payment_date').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true
|
||||
todayHighlight: true,
|
||||
keyboardNavigation: false
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -79,7 +79,8 @@
|
||||
|
||||
$('#start_date, #end_date').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true
|
||||
todayHighlight: true,
|
||||
keyboardNavigation: false
|
||||
});
|
||||
|
||||
@stop
|
@ -173,9 +173,9 @@ table.invoice-table tbody tr:hover {
|
||||
|
||||
|
||||
/* Animate col width changes */
|
||||
.row div {
|
||||
-webkit-transition: width 0.5s ease, margin 0.5s ease;
|
||||
-moz-transition: width 0.5s ease, margin 0.5s ease;
|
||||
-o-transition: width 0.5s ease, margin 0.5s ease;
|
||||
transition: width 0.5s ease, margin 0.5s ease;
|
||||
body {
|
||||
-webkit-transition: all 0.5s ease;
|
||||
-moz-transition: all 0.5s ease;
|
||||
-o-transition: all 0.5s ease;
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user