Skip to content

Commit

Permalink
refs #451 Invoice edit,
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Aug 17, 2018
1 parent 17b5827 commit 1e2f012
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/Http/Controllers/Incomes/Invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,15 @@ public function edit(Invoice $invoice)

$currencies = Currency::enabled()->orderBy('name')->pluck('name', 'code');

$currency = Currency::where('code', '=', setting('general.default_currency'))->first();

$items = Item::enabled()->orderBy('name')->pluck('name', 'id');

$taxes = Tax::enabled()->orderBy('rate')->get()->pluck('title', 'id');

$categories = Category::enabled()->type('income')->orderBy('name')->pluck('name', 'id');

return view('incomes.invoices.edit', compact('invoice', 'customers', 'currencies', 'items', 'taxes', 'categories'));
return view('incomes.invoices.edit', compact('invoice', 'customers', 'currencies', 'currency', 'items', 'taxes', 'categories'));
}

/**
Expand Down
45 changes: 45 additions & 0 deletions resources/views/incomes/invoices/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,40 @@
}
});
var currency = json['data']['currency'];
$("#item-price-" + item_row).maskMoney({
thousands : currency.thousands_separator,
decimal : currency.decimal_mark,
precision : currency.precision,
allowZero : true,
prefix : (currency.symbol_first) ? currency.symbol : '',
suffix : (currency.symbol_first) ? '' : currency.symbol
});
$("#item-price-" + item_row).trigger('focusout');
item_row++;
}
}
});
});
$(document).ready(function(){
$(".input-price").maskMoney({
thousands : '{{ $currency->thousands_separator }}',
decimal : '{{ $currency->decimal_mark }}',
precision : {{ $currency->precision }},
allowZero : true,
@if($currency->symbol_first)
prefix : '{{ $currency->symbol }}'
@else
suffix : '{{ $currency->symbol }}'
@endif
});
$('.input-price').trigger('focusout');
totalItem();
//Date picker
Expand Down Expand Up @@ -346,9 +373,27 @@
$('#customer_tax_number').val(data.tax_number);
$('#customer_phone').val(data.phone);
$('#customer_address').val(data.address);
$('#currency_code').val(data.currency_code);
$('#currency_rate').val(data.currency_rate);
$('.input-price').each(function(){
amount = $(this).maskMoney('unmasked')[0];
$(this).maskMoney({
thousands : data.thousands_separator,
decimal : data.decimal_mark,
precision : data.precision,
allowZero : true,
prefix : (data.symbol_first) ? data.symbol : '',
suffix : (data.symbol_first) ? '' : data.symbol
});
$(this).val(amount);
$(this).trigger('focusout');
});
// This event Select2 Stylesheet
$('#currency_code').trigger('change');
}
Expand Down

0 comments on commit 1e2f012

Please sign in to comment.