mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added invoice and quote number prefixes and counters
This commit is contained in:
parent
edea8d0bc2
commit
65f58c64d6
@ -315,9 +315,9 @@ class AccountController extends \BaseController {
|
||||
}
|
||||
else if ($section == ACCOUNT_ADVANCED_SETTINGS)
|
||||
{
|
||||
if ($subSection == ACCOUNT_CUSTOM_FIELDS)
|
||||
if ($subSection == ACCOUNT_INVOICE_SETTINGS)
|
||||
{
|
||||
return AccountController::saveCustomFields();
|
||||
return AccountController::saveInvoiceSettings();
|
||||
}
|
||||
else if ($subSection == ACCOUNT_INVOICE_DESIGN)
|
||||
{
|
||||
@ -342,11 +342,12 @@ class AccountController extends \BaseController {
|
||||
return Redirect::to('company/products');
|
||||
}
|
||||
|
||||
private function saveCustomFields()
|
||||
private function saveInvoiceSettings()
|
||||
{
|
||||
if (Auth::user()->account->isPro())
|
||||
{
|
||||
$account = Auth::user()->account;
|
||||
|
||||
$account->custom_label1 = trim(Input::get('custom_label1'));
|
||||
$account->custom_value1 = trim(Input::get('custom_value1'));
|
||||
$account->custom_label2 = trim(Input::get('custom_label2'));
|
||||
@ -357,12 +358,26 @@ class AccountController extends \BaseController {
|
||||
$account->custom_invoice_label2 = trim(Input::get('custom_invoice_label2'));
|
||||
$account->custom_invoice_taxes1 = Input::get('custom_invoice_taxes1') ? true : false;
|
||||
$account->custom_invoice_taxes2 = Input::get('custom_invoice_taxes2') ? true : false;
|
||||
$account->save();
|
||||
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
$account->invoice_number_prefix = Input::get('invoice_number_prefix');
|
||||
$account->invoice_number_counter = Input::get('invoice_number_counter');
|
||||
$account->quote_number_prefix = Input::get('quote_number_prefix');
|
||||
$account->share_counter = Input::get('share_counter') ? true : false;
|
||||
|
||||
if (!$account->share_counter) {
|
||||
$account->quote_number_counter = Input::get('quote_number_counter');
|
||||
}
|
||||
|
||||
if (!$account->share_counter && $account->invoice_number_prefix == $account->quote_number_prefix) {
|
||||
Session::flash('error', trans('texts.invalid_counter'));
|
||||
return Redirect::to('company/advanced_settings/invoice_settings')->withInput();
|
||||
} else {
|
||||
$account->save();
|
||||
Session::flash('message', trans('texts.updated_settings'));
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect::to('company/advanced_settings/custom_fields');
|
||||
return Redirect::to('company/advanced_settings/invoice_settings');
|
||||
}
|
||||
|
||||
private function saveInvoiceDesign()
|
||||
|
@ -151,7 +151,7 @@ class InvoiceController extends \BaseController {
|
||||
if ($clone)
|
||||
{
|
||||
$invoice->id = null;
|
||||
$invoice->invoice_number = Auth::user()->account->getNextInvoiceNumber();
|
||||
$invoice->invoice_number = Auth::user()->account->getNextInvoiceNumber($invoice->is_quote);
|
||||
$invoice->balance = $invoice->amount;
|
||||
$method = 'POST';
|
||||
$url = "{$entityType}s";
|
||||
|
@ -60,7 +60,7 @@ class QuoteController extends \BaseController {
|
||||
}
|
||||
|
||||
$client = null;
|
||||
$invoiceNumber = Auth::user()->account->getNextInvoiceNumber();
|
||||
$invoiceNumber = Auth::user()->account->getNextInvoiceNumber(true);
|
||||
$account = Account::with('country')->findOrFail(Auth::user()->account_id);
|
||||
|
||||
if ($clientPublicId)
|
||||
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AddInvoiceNumberSettings extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('accounts', function($table)
|
||||
{
|
||||
$table->text('invoice_number_prefix')->nullable();
|
||||
$table->integer('invoice_number_counter')->default(1)->nullable();
|
||||
|
||||
$table->text('quote_number_prefix')->nullable();
|
||||
$table->integer('quote_number_counter')->default(1)->nullable();
|
||||
|
||||
$table->boolean('share_counter')->default(true);
|
||||
});
|
||||
|
||||
// set initial counter value for accounts with invoices
|
||||
$accounts = DB::table('accounts')->lists('id');
|
||||
|
||||
foreach ($accounts as $accountId) {
|
||||
|
||||
$invoiceNumbers = DB::table('invoices')->where('account_id', $accountId)->lists('invoice_number');
|
||||
$max = 0;
|
||||
|
||||
foreach ($invoiceNumbers as $invoiceNumber) {
|
||||
$number = intval(preg_replace('/[^0-9]/', '', $invoiceNumber));
|
||||
$max = max($max, $number);
|
||||
}
|
||||
|
||||
DB::table('accounts')->where('id', $accountId)->update(['invoice_number_counter' => ++$max]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('accounts', function($table)
|
||||
{
|
||||
$table->dropColumn('invoice_number_prefix');
|
||||
$table->dropColumn('invoice_number_counter');
|
||||
|
||||
$table->dropColumn('quote_number_prefix');
|
||||
$table->dropColumn('quote_number_counter');
|
||||
|
||||
$table->dropColumn('share_counter');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -424,5 +424,14 @@ return array(
|
||||
'sample_data' => 'Sample data shown',
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
);
|
||||
|
@ -433,4 +433,14 @@ return array(
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
|
||||
);
|
@ -422,5 +422,14 @@ return array(
|
||||
'sample_data' => 'Sample data shown',
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
);
|
||||
|
@ -425,5 +425,14 @@ return array(
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
);
|
||||
|
@ -425,5 +425,14 @@ return array(
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
|
||||
);
|
||||
|
@ -433,6 +433,15 @@ return array(
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
@ -433,5 +433,14 @@ return array(
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
|
||||
);
|
@ -425,6 +425,15 @@ return array(
|
||||
'sample_data' => 'Sample data shown',
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
|
||||
);
|
||||
|
@ -413,6 +413,15 @@ return array(
|
||||
'sample_data' => 'Sample data shown',
|
||||
'hide' => 'Hide',
|
||||
'new_version_available' => 'A new version of :releases_link is available. You\'re running v:user_version, the latest is v:latest_version',
|
||||
|
||||
'invoice_settings' => 'Invoice Settings',
|
||||
'invoice_number_prefix' => 'Invoice Number Prefix',
|
||||
'invoice_number_counter' => 'Invoice Number Counter',
|
||||
'quote_number_prefix' => 'Quote Number Prefix',
|
||||
'quote_number_counter' => 'Quote Number Counter',
|
||||
'share_invoice_counter' => 'Share invoice counter',
|
||||
'invoice_issued_to' => 'Invoice issued to',
|
||||
'invalid_counter' => 'To prevent a possible conflict please set either an invoice or quote number prefix',
|
||||
|
||||
|
||||
);
|
||||
|
@ -141,28 +141,25 @@ class Account extends Eloquent
|
||||
return $height;
|
||||
}
|
||||
|
||||
public function getNextInvoiceNumber()
|
||||
{
|
||||
$invoices = Invoice::withTrashed()->scope(false, $this->id)->get(['invoice_number']);
|
||||
public function getNextInvoiceNumber($isQuote = false)
|
||||
{
|
||||
$counter = $isQuote && !$this->share_counter ? $this->quote_number_counter : $this->invoice_number_counter;
|
||||
$prefix = $isQuote ? $this->quote_number_prefix : $this->invoice_number_prefix;
|
||||
|
||||
$max = 0;
|
||||
|
||||
foreach ($invoices as $invoice)
|
||||
{
|
||||
$number = intval(preg_replace("/[^0-9]/", "", $invoice->invoice_number));
|
||||
$max = max($max, $number);
|
||||
}
|
||||
|
||||
if ($max > 0)
|
||||
{
|
||||
return str_pad($max+1, 4, "0", STR_PAD_LEFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
return DEFAULT_INVOICE_NUMBER;
|
||||
}
|
||||
return $prefix . str_pad($counter, 4, "0", STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function incrementCounter($isQuote = false)
|
||||
{
|
||||
if ($isQuote && !$this->share_counter) {
|
||||
$this->quote_number_counter += 1;
|
||||
} else {
|
||||
$this->invoice_number_counter += 1;
|
||||
}
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
$language = Language::remember(DEFAULT_QUERY_CACHE)->where('id', '=', $this->account->language_id)->first();
|
||||
@ -208,6 +205,7 @@ class Account extends Eloquent
|
||||
'quote_date',
|
||||
'quote_number',
|
||||
'total',
|
||||
'invoice_issued_to',
|
||||
];
|
||||
|
||||
foreach ($fields as $field)
|
||||
|
@ -217,6 +217,7 @@ class Invoice extends EntityModel
|
||||
|
||||
Invoice::created(function($invoice)
|
||||
{
|
||||
$invoice->account->incrementCounter($invoice->is_quote);
|
||||
Activity::createInvoice($invoice);
|
||||
});
|
||||
|
||||
|
@ -359,12 +359,11 @@ class InvoiceRepository
|
||||
|
||||
$clone = Invoice::createNew($invoice);
|
||||
$clone->balance = $invoice->amount;
|
||||
$clone->invoice_number = $invoice->account->getNextInvoiceNumber();
|
||||
$clone->invoice_number = $invoice->account->getNextInvoiceNumber($invoice->is_quote);
|
||||
|
||||
foreach ([
|
||||
'client_id',
|
||||
'discount',
|
||||
//'shipping',
|
||||
'invoice_date',
|
||||
'po_number',
|
||||
'due_date',
|
||||
@ -378,7 +377,11 @@ class InvoiceRepository
|
||||
'tax_name',
|
||||
'tax_rate',
|
||||
'amount',
|
||||
'is_quote'] as $field)
|
||||
'is_quote',
|
||||
'custom_value1',
|
||||
'custom_value2',
|
||||
'custom_taxes1',
|
||||
'custom_taxes2'] as $field)
|
||||
{
|
||||
$clone->$field = $invoice->$field;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
@ -170,7 +171,7 @@ define('ACCOUNT_MAP', 'import_map');
|
||||
define('ACCOUNT_EXPORT', 'export');
|
||||
define('ACCOUNT_PRODUCTS', 'products');
|
||||
define('ACCOUNT_ADVANCED_SETTINGS', 'advanced_settings');
|
||||
define('ACCOUNT_CUSTOM_FIELDS', 'custom_fields');
|
||||
define('ACCOUNT_INVOICE_SETTINGS', 'invoice_settings');
|
||||
define('ACCOUNT_INVOICE_DESIGN', 'invoice_design');
|
||||
define('ACCOUNT_CHART_BUILDER', 'chart_builder');
|
||||
define('ACCOUNT_USER_MANAGEMENT', 'user_management');
|
||||
|
@ -63,13 +63,6 @@
|
||||
{{ Former::populateField('hide_quantity', intval($account->hide_quantity)) }}
|
||||
{{ Former::populateField('hide_paid_to_date', intval($account->hide_paid_to_date)) }}
|
||||
|
||||
{{ Former::legend('invoice_options') }}
|
||||
{{ Former::checkbox('hide_quantity')->text(trans('texts.hide_quantity_help')) }}
|
||||
{{ Former::checkbox('hide_paid_to_date')->text(trans('texts.hide_paid_to_date_help')) }}
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
{{ Former::legend('invoice_design') }}
|
||||
{{ Former::select('invoice_design_id')->style('display:inline;width:120px')
|
||||
->fromQuery($invoiceDesigns, 'name', 'id') }}
|
||||
@ -80,6 +73,13 @@
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
{{ Former::legend('invoice_options') }}
|
||||
{{ Former::checkbox('hide_quantity')->text(trans('texts.hide_quantity_help')) }}
|
||||
{{ Former::checkbox('hide_paid_to_date')->text(trans('texts.hide_paid_to_date_help')) }}
|
||||
|
||||
<p> </p>
|
||||
<p> </p>
|
||||
|
||||
@if (Auth::user()->isPro())
|
||||
{{ Former::actions( Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk') ) }}
|
||||
@else
|
||||
|
@ -8,6 +8,8 @@
|
||||
{{ Former::populate($account) }}
|
||||
{{ Former::populateField('custom_invoice_taxes1', intval($account->custom_invoice_taxes1)) }}
|
||||
{{ Former::populateField('custom_invoice_taxes2', intval($account->custom_invoice_taxes2)) }}
|
||||
{{ Former::populateField('share_counter', intval($account->share_counter)) }}
|
||||
|
||||
|
||||
{{ Former::legend('invoice_fields') }}
|
||||
{{ Former::text('custom_invoice_label1')->label(trans('texts.field_label'))
|
||||
@ -27,17 +29,45 @@
|
||||
<p> </p>
|
||||
{{ Former::text('custom_label2')->label(trans('texts.field_label')) }}
|
||||
{{ Former::text('custom_value2')->label(trans('texts.field_value')) }}
|
||||
<p> </p>
|
||||
|
||||
{{ Former::legend('invoice_number') }}
|
||||
{{ Former::text('invoice_number_prefix')->label(trans('texts.invoice_number_prefix')) }}
|
||||
{{ Former::text('invoice_number_counter')->label(trans('texts.invoice_number_counter')) }}
|
||||
<p> </p>
|
||||
|
||||
{{ Former::legend('quote_number') }}
|
||||
{{ Former::text('quote_number_prefix')->label(trans('texts.quote_number_prefix')) }}
|
||||
{{ Former::text('quote_number_counter')->label(trans('texts.quote_number_counter'))
|
||||
->append(Former::checkbox('share_counter')->raw()->onclick('setQuoteNumberEnabled()') . ' ' . trans('texts.share_invoice_counter')) }}
|
||||
<p> </p>
|
||||
|
||||
@if (Auth::user()->isPro())
|
||||
{{ Former::actions( Button::lg_success_submit(trans('texts.save'))->append_with_icon('floppy-disk') ) }}
|
||||
@else
|
||||
<script>
|
||||
$(function() {
|
||||
$('form.warn-on-exit input').prop('disabled', true);
|
||||
});
|
||||
$(function() {
|
||||
$('form.warn-on-exit input').prop('disabled', true);
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
|
||||
{{ Former::close() }}
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function setQuoteNumberEnabled() {
|
||||
var disabled = $('#share_counter').prop('checked');
|
||||
$('#quote_number_counter').prop('disabled', disabled);
|
||||
$('#quote_number_counter').val(disabled ? '' : '{{ $account->quote_number_counter }}');
|
||||
}
|
||||
|
||||
$(function() {
|
||||
setQuoteNumberEnabled();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@stop
|
@ -8,7 +8,7 @@
|
||||
{{ HTML::nav_link('company/products', 'product_library') }}
|
||||
{{ HTML::nav_link('company/notifications', 'notifications') }}
|
||||
{{ HTML::nav_link('company/import_export', 'import_export', 'company/import_map') }}
|
||||
{{ HTML::nav_link('company/advanced_settings/custom_fields', 'advanced_settings', '*/advanced_settings/*') }}
|
||||
{{ HTML::nav_link('company/advanced_settings/invoice_settings', 'advanced_settings', '*/advanced_settings/*') }}
|
||||
</ul>
|
||||
|
||||
<br/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<ul class="nav nav-tabs nav nav-justified">
|
||||
{{ HTML::nav_link('company/advanced_settings/custom_fields', 'custom_fields') }}
|
||||
{{ HTML::nav_link('company/advanced_settings/invoice_settings', 'invoice_settings') }}
|
||||
{{ HTML::nav_link('company/advanced_settings/invoice_design', 'invoice_design') }}
|
||||
{{ HTML::nav_link('company/advanced_settings/data_visualizations', 'data_visualizations') }}
|
||||
{{ HTML::nav_link('company/advanced_settings/chart_builder', 'chart_builder') }}
|
||||
|
@ -104,7 +104,7 @@
|
||||
<li>{{ link_to('company/products', uctrans('texts.product_library')) }}</li>
|
||||
<li>{{ link_to('company/notifications', uctrans('texts.notifications')) }}</li>
|
||||
<li>{{ link_to('company/import_export', uctrans('texts.import_export')) }}</li>
|
||||
<li><a href="{{ url('company/advanced_settings/custom_fields') }}">{{ uctrans('texts.advanced_settings') . Utils::getProLabel(ACCOUNT_ADVANCED_SETTINGS) }}</a></li>
|
||||
<li><a href="{{ url('company/advanced_settings/invoice_settings') }}">{{ uctrans('texts.advanced_settings') . Utils::getProLabel(ACCOUNT_ADVANCED_SETTINGS) }}</a></li>
|
||||
|
||||
<li class="divider"></li>
|
||||
<li>{{ link_to('#', trans('texts.logout'), array('onclick'=>'logout()')) }}</li>
|
||||
|
317
public/built.js
317
public/built.js
@ -46052,6 +46052,10 @@ function SetPdfColor(color, doc, role)
|
||||
return doc.setTextColor(251,251,251);//select color Custom Report GRAY Colour
|
||||
}
|
||||
|
||||
if (color=='orange') {
|
||||
return doc.setTextColor(234,121,45);//select color Custom Report GRAY Colour
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -46127,105 +46131,106 @@ function getQuarter(offset) {
|
||||
|
||||
|
||||
/* Default class modification */
|
||||
$.extend( $.fn.dataTableExt.oStdClasses, {
|
||||
"sWrapper": "dataTables_wrapper form-inline"
|
||||
} );
|
||||
if ($.fn.dataTableExt) {
|
||||
$.extend( $.fn.dataTableExt.oStdClasses, {
|
||||
"sWrapper": "dataTables_wrapper form-inline"
|
||||
} );
|
||||
|
||||
|
||||
/* API method to get paging information */
|
||||
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
||||
{
|
||||
return {
|
||||
"iStart": oSettings._iDisplayStart,
|
||||
"iEnd": oSettings.fnDisplayEnd(),
|
||||
"iLength": oSettings._iDisplayLength,
|
||||
"iTotal": oSettings.fnRecordsTotal(),
|
||||
"iFilteredTotal": oSettings.fnRecordsDisplay(),
|
||||
"iPage": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
|
||||
"iTotalPages": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
|
||||
/* API method to get paging information */
|
||||
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
||||
{
|
||||
return {
|
||||
"iStart": oSettings._iDisplayStart,
|
||||
"iEnd": oSettings.fnDisplayEnd(),
|
||||
"iLength": oSettings._iDisplayLength,
|
||||
"iTotal": oSettings.fnRecordsTotal(),
|
||||
"iFilteredTotal": oSettings.fnRecordsDisplay(),
|
||||
"iPage": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
|
||||
"iTotalPages": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/* Bootstrap style pagination control */
|
||||
$.extend( $.fn.dataTableExt.oPagination, {
|
||||
"bootstrap": {
|
||||
"fnInit": function( oSettings, nPaging, fnDraw ) {
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var fnClickHandler = function ( e ) {
|
||||
e.preventDefault();
|
||||
if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
|
||||
fnDraw( oSettings );
|
||||
/* Bootstrap style pagination control */
|
||||
$.extend( $.fn.dataTableExt.oPagination, {
|
||||
"bootstrap": {
|
||||
"fnInit": function( oSettings, nPaging, fnDraw ) {
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var fnClickHandler = function ( e ) {
|
||||
e.preventDefault();
|
||||
if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
|
||||
fnDraw( oSettings );
|
||||
}
|
||||
};
|
||||
|
||||
$(nPaging).addClass('pagination').append(
|
||||
'<ul class="pagination">'+
|
||||
'<li class="prev disabled"><a href="#">«</a></li>'+
|
||||
'<li class="next disabled"><a href="#">»</a></li>'+
|
||||
'</ul>'
|
||||
);
|
||||
var els = $('a', nPaging);
|
||||
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
|
||||
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
|
||||
},
|
||||
|
||||
"fnUpdate": function ( oSettings, fnDraw ) {
|
||||
var iListLength = 5;
|
||||
var oPaging = oSettings.oInstance.fnPagingInfo();
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
|
||||
|
||||
if ( oPaging.iTotalPages < iListLength) {
|
||||
iStart = 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
}
|
||||
};
|
||||
|
||||
$(nPaging).addClass('pagination').append(
|
||||
'<ul class="pagination">'+
|
||||
'<li class="prev disabled"><a href="#">«</a></li>'+
|
||||
'<li class="next disabled"><a href="#">»</a></li>'+
|
||||
'</ul>'
|
||||
);
|
||||
var els = $('a', nPaging);
|
||||
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
|
||||
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
|
||||
},
|
||||
|
||||
"fnUpdate": function ( oSettings, fnDraw ) {
|
||||
var iListLength = 5;
|
||||
var oPaging = oSettings.oInstance.fnPagingInfo();
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
|
||||
|
||||
if ( oPaging.iTotalPages < iListLength) {
|
||||
iStart = 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
}
|
||||
else if ( oPaging.iPage <= iHalf ) {
|
||||
iStart = 1;
|
||||
iEnd = iListLength;
|
||||
} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
|
||||
iStart = oPaging.iTotalPages - iListLength + 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
} else {
|
||||
iStart = oPaging.iPage - iHalf + 1;
|
||||
iEnd = iStart + iListLength - 1;
|
||||
}
|
||||
|
||||
for ( i=0, ien=an.length ; i<ien ; i++ ) {
|
||||
// Remove the middle elements
|
||||
$('li:gt(0)', an[i]).filter(':not(:last)').remove();
|
||||
|
||||
// Add the new list items and their event handlers
|
||||
for ( j=iStart ; j<=iEnd ; j++ ) {
|
||||
sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
|
||||
$('<li '+sClass+'><a href="#">'+j+'</a></li>')
|
||||
.insertBefore( $('li:last', an[i])[0] )
|
||||
.bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
|
||||
fnDraw( oSettings );
|
||||
} );
|
||||
}
|
||||
|
||||
// Add / remove disabled classes from the static elements
|
||||
if ( oPaging.iPage === 0 ) {
|
||||
$('li:first', an[i]).addClass('disabled');
|
||||
else if ( oPaging.iPage <= iHalf ) {
|
||||
iStart = 1;
|
||||
iEnd = iListLength;
|
||||
} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
|
||||
iStart = oPaging.iTotalPages - iListLength + 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
} else {
|
||||
$('li:first', an[i]).removeClass('disabled');
|
||||
iStart = oPaging.iPage - iHalf + 1;
|
||||
iEnd = iStart + iListLength - 1;
|
||||
}
|
||||
|
||||
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
|
||||
$('li:last', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:last', an[i]).removeClass('disabled');
|
||||
for ( i=0, ien=an.length ; i<ien ; i++ ) {
|
||||
// Remove the middle elements
|
||||
$('li:gt(0)', an[i]).filter(':not(:last)').remove();
|
||||
|
||||
// Add the new list items and their event handlers
|
||||
for ( j=iStart ; j<=iEnd ; j++ ) {
|
||||
sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
|
||||
$('<li '+sClass+'><a href="#">'+j+'</a></li>')
|
||||
.insertBefore( $('li:last', an[i])[0] )
|
||||
.bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
|
||||
fnDraw( oSettings );
|
||||
} );
|
||||
}
|
||||
|
||||
// Add / remove disabled classes from the static elements
|
||||
if ( oPaging.iPage === 0 ) {
|
||||
$('li:first', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:first', an[i]).removeClass('disabled');
|
||||
}
|
||||
|
||||
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
|
||||
$('li:last', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:last', an[i]).removeClass('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
/*
|
||||
* TableTools Bootstrap compatibility
|
||||
@ -46348,54 +46353,55 @@ function convertDataURIToBinary(dataURI) {
|
||||
return base64DecToArr(base64);
|
||||
}
|
||||
|
||||
ko.bindingHandlers.dropdown = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||
var options = allBindingsAccessor().dropdownOptions|| {};
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||
if (id) $(element).val(id);
|
||||
//console.log("combo-init: %s", id);
|
||||
$(element).combobox(options);
|
||||
if (window.ko) {
|
||||
ko.bindingHandlers.dropdown = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||
var options = allBindingsAccessor().dropdownOptions|| {};
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||
if (id) $(element).val(id);
|
||||
//console.log("combo-init: %s", id);
|
||||
$(element).combobox(options);
|
||||
|
||||
/*
|
||||
ko.utils.registerEventHandler(element, "change", function () {
|
||||
console.log("change: %s", $(element).val());
|
||||
//var
|
||||
valueAccessor($(element).val());
|
||||
//$(element).combobox('refresh');
|
||||
});
|
||||
*/
|
||||
},
|
||||
update: function (element, valueAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||
//console.log("combo-update: %s", id);
|
||||
if (id) {
|
||||
$(element).val(id);
|
||||
$(element).combobox('refresh');
|
||||
} else {
|
||||
$(element).combobox('clearTarget');
|
||||
$(element).combobox('clearElement');
|
||||
}
|
||||
}
|
||||
};
|
||||
/*
|
||||
ko.utils.registerEventHandler(element, "change", function () {
|
||||
console.log("change: %s", $(element).val());
|
||||
//var
|
||||
valueAccessor($(element).val());
|
||||
//$(element).combobox('refresh');
|
||||
});
|
||||
*/
|
||||
},
|
||||
update: function (element, valueAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||
//console.log("combo-update: %s", id);
|
||||
if (id) {
|
||||
$(element).val(id);
|
||||
$(element).combobox('refresh');
|
||||
} else {
|
||||
$(element).combobox('clearTarget');
|
||||
$(element).combobox('clearElement');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ko.bindingHandlers.datePicker = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (value) $(element).datepicker('update', value);
|
||||
$(element).change(function() {
|
||||
var value = valueAccessor();
|
||||
value($(element).val());
|
||||
})
|
||||
},
|
||||
update: function (element, valueAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (value) $(element).datepicker('update', value);
|
||||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers.datePicker = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (value) $(element).datepicker('update', value);
|
||||
$(element).change(function() {
|
||||
var value = valueAccessor();
|
||||
value($(element).val());
|
||||
})
|
||||
},
|
||||
update: function (element, valueAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (value) $(element).datepicker('update', value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function wordWrapText(value, width)
|
||||
{
|
||||
@ -46986,6 +46992,21 @@ function displayInvoiceItems(doc, invoice, layout) {
|
||||
doc.rect(left, top, width-left, newTop-top, 'FD');
|
||||
|
||||
}
|
||||
} else if (invoice.invoice_design_id == 5) {
|
||||
if (i%2 == 0) {
|
||||
doc.setDrawColor(255,255,255);
|
||||
doc.setFillColor(247,247,247);
|
||||
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
||||
doc.setLineWidth(0.3);
|
||||
doc.setDrawColor(255,255,255);
|
||||
} else {
|
||||
doc.setDrawColor(255,255,255);
|
||||
doc.setFillColor(232,232,232);
|
||||
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
||||
|
||||
doc.setLineWidth(0.3);
|
||||
doc.setDrawColor(255,255,255);
|
||||
}
|
||||
} else {
|
||||
doc.setLineWidth(0.3);
|
||||
doc.setDrawColor(150,150,150);
|
||||
@ -47000,10 +47021,38 @@ function displayInvoiceItems(doc, invoice, layout) {
|
||||
SetPdfColor('SomeGreen', doc, 'primary');
|
||||
} else if (invoice.invoice_design_id == 3) {
|
||||
doc.setFontType('bold');
|
||||
} else {
|
||||
} else if (invoice.invoice_design_id == 4) {
|
||||
SetPdfColor('Black', doc);
|
||||
} else if (invoice.invoice_design_id == 5) {
|
||||
SetPdfColor('Black', doc);
|
||||
}
|
||||
doc.text(layout.marginLeft, y+2, productKey);
|
||||
|
||||
var splitTitle = doc.splitTextToSize(productKey, 60);
|
||||
doc.text(layout.marginLeft, y+2, splitTitle);
|
||||
|
||||
if (invoice.invoice_design_id == 5) {
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(layout.descriptionLeft-8, y-16,layout.descriptionLeft-8, y+55);
|
||||
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(costX-30, y-16,costX-30, y+55);
|
||||
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(qtyX-45, y-16,qtyX-45, y+55);
|
||||
|
||||
if (invoice.has_taxes) {
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(taxX-15, y-16,taxX-15, y+55);
|
||||
}
|
||||
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(totalX-27, y-16,totalX-27, y+55);
|
||||
}
|
||||
|
||||
SetPdfColor('Black', doc);
|
||||
doc.setFontType('normal');
|
||||
|
@ -127,6 +127,10 @@ function SetPdfColor(color, doc, role)
|
||||
return doc.setTextColor(251,251,251);//select color Custom Report GRAY Colour
|
||||
}
|
||||
|
||||
if (color=='orange') {
|
||||
return doc.setTextColor(234,121,45);//select color Custom Report GRAY Colour
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -202,105 +206,106 @@ function getQuarter(offset) {
|
||||
|
||||
|
||||
/* Default class modification */
|
||||
$.extend( $.fn.dataTableExt.oStdClasses, {
|
||||
"sWrapper": "dataTables_wrapper form-inline"
|
||||
} );
|
||||
if ($.fn.dataTableExt) {
|
||||
$.extend( $.fn.dataTableExt.oStdClasses, {
|
||||
"sWrapper": "dataTables_wrapper form-inline"
|
||||
} );
|
||||
|
||||
|
||||
/* API method to get paging information */
|
||||
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
||||
{
|
||||
return {
|
||||
"iStart": oSettings._iDisplayStart,
|
||||
"iEnd": oSettings.fnDisplayEnd(),
|
||||
"iLength": oSettings._iDisplayLength,
|
||||
"iTotal": oSettings.fnRecordsTotal(),
|
||||
"iFilteredTotal": oSettings.fnRecordsDisplay(),
|
||||
"iPage": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
|
||||
"iTotalPages": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
|
||||
/* API method to get paging information */
|
||||
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
|
||||
{
|
||||
return {
|
||||
"iStart": oSettings._iDisplayStart,
|
||||
"iEnd": oSettings.fnDisplayEnd(),
|
||||
"iLength": oSettings._iDisplayLength,
|
||||
"iTotal": oSettings.fnRecordsTotal(),
|
||||
"iFilteredTotal": oSettings.fnRecordsDisplay(),
|
||||
"iPage": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
|
||||
"iTotalPages": oSettings._iDisplayLength === -1 ?
|
||||
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/* Bootstrap style pagination control */
|
||||
$.extend( $.fn.dataTableExt.oPagination, {
|
||||
"bootstrap": {
|
||||
"fnInit": function( oSettings, nPaging, fnDraw ) {
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var fnClickHandler = function ( e ) {
|
||||
e.preventDefault();
|
||||
if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
|
||||
fnDraw( oSettings );
|
||||
/* Bootstrap style pagination control */
|
||||
$.extend( $.fn.dataTableExt.oPagination, {
|
||||
"bootstrap": {
|
||||
"fnInit": function( oSettings, nPaging, fnDraw ) {
|
||||
var oLang = oSettings.oLanguage.oPaginate;
|
||||
var fnClickHandler = function ( e ) {
|
||||
e.preventDefault();
|
||||
if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
|
||||
fnDraw( oSettings );
|
||||
}
|
||||
};
|
||||
|
||||
$(nPaging).addClass('pagination').append(
|
||||
'<ul class="pagination">'+
|
||||
'<li class="prev disabled"><a href="#">«</a></li>'+
|
||||
'<li class="next disabled"><a href="#">»</a></li>'+
|
||||
'</ul>'
|
||||
);
|
||||
var els = $('a', nPaging);
|
||||
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
|
||||
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
|
||||
},
|
||||
|
||||
"fnUpdate": function ( oSettings, fnDraw ) {
|
||||
var iListLength = 5;
|
||||
var oPaging = oSettings.oInstance.fnPagingInfo();
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
|
||||
|
||||
if ( oPaging.iTotalPages < iListLength) {
|
||||
iStart = 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
}
|
||||
};
|
||||
|
||||
$(nPaging).addClass('pagination').append(
|
||||
'<ul class="pagination">'+
|
||||
'<li class="prev disabled"><a href="#">«</a></li>'+
|
||||
'<li class="next disabled"><a href="#">»</a></li>'+
|
||||
'</ul>'
|
||||
);
|
||||
var els = $('a', nPaging);
|
||||
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
|
||||
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
|
||||
},
|
||||
|
||||
"fnUpdate": function ( oSettings, fnDraw ) {
|
||||
var iListLength = 5;
|
||||
var oPaging = oSettings.oInstance.fnPagingInfo();
|
||||
var an = oSettings.aanFeatures.p;
|
||||
var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
|
||||
|
||||
if ( oPaging.iTotalPages < iListLength) {
|
||||
iStart = 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
}
|
||||
else if ( oPaging.iPage <= iHalf ) {
|
||||
iStart = 1;
|
||||
iEnd = iListLength;
|
||||
} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
|
||||
iStart = oPaging.iTotalPages - iListLength + 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
} else {
|
||||
iStart = oPaging.iPage - iHalf + 1;
|
||||
iEnd = iStart + iListLength - 1;
|
||||
}
|
||||
|
||||
for ( i=0, ien=an.length ; i<ien ; i++ ) {
|
||||
// Remove the middle elements
|
||||
$('li:gt(0)', an[i]).filter(':not(:last)').remove();
|
||||
|
||||
// Add the new list items and their event handlers
|
||||
for ( j=iStart ; j<=iEnd ; j++ ) {
|
||||
sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
|
||||
$('<li '+sClass+'><a href="#">'+j+'</a></li>')
|
||||
.insertBefore( $('li:last', an[i])[0] )
|
||||
.bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
|
||||
fnDraw( oSettings );
|
||||
} );
|
||||
}
|
||||
|
||||
// Add / remove disabled classes from the static elements
|
||||
if ( oPaging.iPage === 0 ) {
|
||||
$('li:first', an[i]).addClass('disabled');
|
||||
else if ( oPaging.iPage <= iHalf ) {
|
||||
iStart = 1;
|
||||
iEnd = iListLength;
|
||||
} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
|
||||
iStart = oPaging.iTotalPages - iListLength + 1;
|
||||
iEnd = oPaging.iTotalPages;
|
||||
} else {
|
||||
$('li:first', an[i]).removeClass('disabled');
|
||||
iStart = oPaging.iPage - iHalf + 1;
|
||||
iEnd = iStart + iListLength - 1;
|
||||
}
|
||||
|
||||
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
|
||||
$('li:last', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:last', an[i]).removeClass('disabled');
|
||||
for ( i=0, ien=an.length ; i<ien ; i++ ) {
|
||||
// Remove the middle elements
|
||||
$('li:gt(0)', an[i]).filter(':not(:last)').remove();
|
||||
|
||||
// Add the new list items and their event handlers
|
||||
for ( j=iStart ; j<=iEnd ; j++ ) {
|
||||
sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
|
||||
$('<li '+sClass+'><a href="#">'+j+'</a></li>')
|
||||
.insertBefore( $('li:last', an[i])[0] )
|
||||
.bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
|
||||
fnDraw( oSettings );
|
||||
} );
|
||||
}
|
||||
|
||||
// Add / remove disabled classes from the static elements
|
||||
if ( oPaging.iPage === 0 ) {
|
||||
$('li:first', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:first', an[i]).removeClass('disabled');
|
||||
}
|
||||
|
||||
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
|
||||
$('li:last', an[i]).addClass('disabled');
|
||||
} else {
|
||||
$('li:last', an[i]).removeClass('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
/*
|
||||
* TableTools Bootstrap compatibility
|
||||
@ -423,54 +428,55 @@ function convertDataURIToBinary(dataURI) {
|
||||
return base64DecToArr(base64);
|
||||
}
|
||||
|
||||
ko.bindingHandlers.dropdown = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||
var options = allBindingsAccessor().dropdownOptions|| {};
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||
if (id) $(element).val(id);
|
||||
//console.log("combo-init: %s", id);
|
||||
$(element).combobox(options);
|
||||
if (window.ko) {
|
||||
ko.bindingHandlers.dropdown = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||
var options = allBindingsAccessor().dropdownOptions|| {};
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||
if (id) $(element).val(id);
|
||||
//console.log("combo-init: %s", id);
|
||||
$(element).combobox(options);
|
||||
|
||||
/*
|
||||
ko.utils.registerEventHandler(element, "change", function () {
|
||||
console.log("change: %s", $(element).val());
|
||||
//var
|
||||
valueAccessor($(element).val());
|
||||
//$(element).combobox('refresh');
|
||||
});
|
||||
*/
|
||||
},
|
||||
update: function (element, valueAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||
//console.log("combo-update: %s", id);
|
||||
if (id) {
|
||||
$(element).val(id);
|
||||
$(element).combobox('refresh');
|
||||
} else {
|
||||
$(element).combobox('clearTarget');
|
||||
$(element).combobox('clearElement');
|
||||
}
|
||||
}
|
||||
};
|
||||
/*
|
||||
ko.utils.registerEventHandler(element, "change", function () {
|
||||
console.log("change: %s", $(element).val());
|
||||
//var
|
||||
valueAccessor($(element).val());
|
||||
//$(element).combobox('refresh');
|
||||
});
|
||||
*/
|
||||
},
|
||||
update: function (element, valueAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
var id = (value && value.public_id) ? value.public_id() : (value && value.id) ? value.id() : value ? value : false;
|
||||
//console.log("combo-update: %s", id);
|
||||
if (id) {
|
||||
$(element).val(id);
|
||||
$(element).combobox('refresh');
|
||||
} else {
|
||||
$(element).combobox('clearTarget');
|
||||
$(element).combobox('clearElement');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
ko.bindingHandlers.datePicker = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (value) $(element).datepicker('update', value);
|
||||
$(element).change(function() {
|
||||
var value = valueAccessor();
|
||||
value($(element).val());
|
||||
})
|
||||
},
|
||||
update: function (element, valueAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (value) $(element).datepicker('update', value);
|
||||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers.datePicker = {
|
||||
init: function (element, valueAccessor, allBindingsAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (value) $(element).datepicker('update', value);
|
||||
$(element).change(function() {
|
||||
var value = valueAccessor();
|
||||
value($(element).val());
|
||||
})
|
||||
},
|
||||
update: function (element, valueAccessor) {
|
||||
var value = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (value) $(element).datepicker('update', value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function wordWrapText(value, width)
|
||||
{
|
||||
@ -1061,6 +1067,21 @@ function displayInvoiceItems(doc, invoice, layout) {
|
||||
doc.rect(left, top, width-left, newTop-top, 'FD');
|
||||
|
||||
}
|
||||
} else if (invoice.invoice_design_id == 5) {
|
||||
if (i%2 == 0) {
|
||||
doc.setDrawColor(255,255,255);
|
||||
doc.setFillColor(247,247,247);
|
||||
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
||||
doc.setLineWidth(0.3);
|
||||
doc.setDrawColor(255,255,255);
|
||||
} else {
|
||||
doc.setDrawColor(255,255,255);
|
||||
doc.setFillColor(232,232,232);
|
||||
doc.rect(left, top, width-left+17, newTop-top, 'FD');
|
||||
|
||||
doc.setLineWidth(0.3);
|
||||
doc.setDrawColor(255,255,255);
|
||||
}
|
||||
} else {
|
||||
doc.setLineWidth(0.3);
|
||||
doc.setDrawColor(150,150,150);
|
||||
@ -1075,10 +1096,38 @@ function displayInvoiceItems(doc, invoice, layout) {
|
||||
SetPdfColor('SomeGreen', doc, 'primary');
|
||||
} else if (invoice.invoice_design_id == 3) {
|
||||
doc.setFontType('bold');
|
||||
} else {
|
||||
} else if (invoice.invoice_design_id == 4) {
|
||||
SetPdfColor('Black', doc);
|
||||
} else if (invoice.invoice_design_id == 5) {
|
||||
SetPdfColor('Black', doc);
|
||||
}
|
||||
doc.text(layout.marginLeft, y+2, productKey);
|
||||
|
||||
var splitTitle = doc.splitTextToSize(productKey, 60);
|
||||
doc.text(layout.marginLeft, y+2, splitTitle);
|
||||
|
||||
if (invoice.invoice_design_id == 5) {
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(layout.descriptionLeft-8, y-16,layout.descriptionLeft-8, y+55);
|
||||
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(costX-30, y-16,costX-30, y+55);
|
||||
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(qtyX-45, y-16,qtyX-45, y+55);
|
||||
|
||||
if (invoice.has_taxes) {
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(taxX-15, y-16,taxX-15, y+55);
|
||||
}
|
||||
|
||||
doc.setDrawColor(255, 255, 255);
|
||||
doc.setLineWidth(1);
|
||||
doc.line(totalX-27, y-16,totalX-27, y+55);
|
||||
}
|
||||
|
||||
SetPdfColor('Black', doc);
|
||||
doc.setFontType('normal');
|
||||
|
Loading…
x
Reference in New Issue
Block a user