Bug 23376: Move AcqCreateItem logic to template
Signed-off-by: Agustin Moyano <agustinmoyano@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
5d4740dfb0
commit
15e35f77fb
|
|
@ -118,42 +118,6 @@ unless($acq_fw) {
|
|||
$template->param('NoACQframework' => 1);
|
||||
}
|
||||
|
||||
my $AcqCreateItem = $basket->effective_create_items;
|
||||
if ($AcqCreateItem eq 'receiving') {
|
||||
$template->param(
|
||||
AcqCreateItemReceiving => 1,
|
||||
UniqueItemFields => C4::Context->preference('UniqueItemFields'),
|
||||
);
|
||||
} elsif ($AcqCreateItem eq 'ordering') {
|
||||
my $fw = ($acq_fw) ? 'ACQ' : '';
|
||||
my $items = $order->items;
|
||||
$template->param(items => $items);
|
||||
}
|
||||
|
||||
$order->quantityreceived = '' if $order->quantityreceived == 0;
|
||||
|
||||
my $unitprice = $order->unitprice;
|
||||
my ( $rrp, $ecost );
|
||||
if ( $bookseller->invoiceincgst ) {
|
||||
$rrp = $order->rrp_tax_included;
|
||||
$ecost = $order->ecost_tax_included;
|
||||
unless ( $unitprice != 0 and defined $unitprice) {
|
||||
$unitprice = $order->ecost_tax_included;
|
||||
}
|
||||
} else {
|
||||
$rrp = $order->rrp_tax_excluded;
|
||||
$ecost = $order->ecost_tax_excluded;
|
||||
unless ( $unitprice != 0 and defined $unitprice) {
|
||||
$unitprice = $order->ecost_tax_excluded;
|
||||
}
|
||||
}
|
||||
|
||||
my $tax_rate;
|
||||
if( defined $order->tax_rate_on_receiving ) {
|
||||
$tax_rate = $order->tax_rate_on_receiving + 0.0;
|
||||
} else {
|
||||
$tax_rate = $order->tax_rate_on_ordering + 0.0;
|
||||
}
|
||||
|
||||
my $creator = Koha::Patrons->find( $order->created_by );
|
||||
|
||||
|
|
@ -188,7 +152,6 @@ if ( $order->subscriptionid ) {
|
|||
}
|
||||
|
||||
$template->param(
|
||||
AcqCreateItem => $AcqCreateItem,
|
||||
count => 1,
|
||||
order => $order,
|
||||
freight => $freight,
|
||||
|
|
@ -197,8 +160,6 @@ $template->param(
|
|||
currencies => scalar $currencies->search({ rate => { '!=' => 1 } }),
|
||||
invoiceincgst => $bookseller->invoiceincgst,
|
||||
bookfund => $budget->{budget_name},
|
||||
rrp => $rrp,
|
||||
ecost => $ecost,
|
||||
creator => $creator,
|
||||
invoiceid => $invoice->{invoiceid},
|
||||
invoice => $invoice->{invoicenumber},
|
||||
|
|
@ -225,6 +186,9 @@ foreach my $period (@$periods) {
|
|||
my @funds;
|
||||
foreach my $r ( @{$budget_hierarchy} ) {
|
||||
next unless ( CanUserUseBudget( $patron, $r, $userflags ) );
|
||||
if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
|
||||
next;
|
||||
}
|
||||
push @funds,
|
||||
{
|
||||
b_id => $r->{budget_id},
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
<div class="main container-fluid">
|
||||
<div class="row">
|
||||
[% AcqCreateItem = order.basket.effective_create_items %]
|
||||
<div class="col-sm-10 col-sm-push-2">
|
||||
<main>
|
||||
|
||||
|
|
@ -141,7 +142,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
[% ELSIF (AcqCreateItemReceiving) %]
|
||||
[% ELSIF (AcqCreateItem == 'receiving') %]
|
||||
<div id="items_list" style="display:none">
|
||||
<p><strong>Items list</strong></p>
|
||||
<div style="width:100%;overflow:auto;">
|
||||
|
|
@ -184,7 +185,7 @@
|
|||
</fieldset>
|
||||
[% END %]
|
||||
[% ELSIF (AcqCreateItem == 'ordering') %]
|
||||
[% IF (items.count) %]
|
||||
[% IF (order.items.size) %]
|
||||
<h5>Items</h5>
|
||||
<div style="width:100%;overflow:auto">
|
||||
<table>
|
||||
|
|
@ -208,7 +209,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
[% FOREACH item IN items %]
|
||||
[% FOREACH item IN order.items %]
|
||||
<tr id="item_[% item.itemnumber | html %]">
|
||||
<td style="text-align:center"><input type="checkbox" name="items_to_receive" value="[% item.itemnumber | html %]" /></td>
|
||||
<td><a style="cursor:pointer" onclick="PopupEditPage([% item.biblionumber | html %],[% item.itemnumber | html %]);">Edit</a></td>
|
||||
|
|
@ -277,7 +278,7 @@
|
|||
[% IF order.subscriptionid %]
|
||||
<input type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantity | html %]" />
|
||||
<input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% order.quantityreceived | html %]" />
|
||||
[% ELSIF AcqCreateItemReceiving %]
|
||||
[% ELSIF AcqCreateItem == 'receiving' %]
|
||||
<input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="0" />
|
||||
[% ELSE %]
|
||||
[% IF ( order.quantityreceived ) %]
|
||||
|
|
@ -285,7 +286,7 @@
|
|||
<input type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived | html %]" />
|
||||
<input id="origquantityrec" readonly="readonly" type="hidden" name="origquantityrec" value="[% order.quantityreceived | html %]" />
|
||||
[% ELSE %]
|
||||
[% IF ( items ) %]
|
||||
[% IF ( order.items.count ) %]
|
||||
<input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="[% order.quantityreceived + 1 | html %]" />
|
||||
[% ELSE %]
|
||||
<input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived + 1 | html %]" />
|
||||
|
|
@ -300,7 +301,7 @@
|
|||
<p class="error">Warning, you have entered more items than expected.
|
||||
Items will not be created.</p>
|
||||
</div>
|
||||
[% END %][%# IF (order.subscriptionid) ELSIF (AcqCreateItemReceiving) %]
|
||||
[% END %][%# IF (order.subscriptionid) ELSIF (AcqCreateItem == 'receiving' ) %]
|
||||
</li>
|
||||
|
||||
[% IF ( gst_values ) %]
|
||||
|
|
@ -391,7 +392,7 @@
|
|||
[% Asset.js("js/cataloging.js") | $raw %]
|
||||
<script>
|
||||
function Check(form) {
|
||||
[% IF (AcqCreateItemReceiving) %]
|
||||
[% IF (AcqCreateItem == 'receiving') %]
|
||||
var total_errors = CheckMandatorySubfields(form);
|
||||
if (total_errors != 0) {
|
||||
var alertString = _("Form not submitted because of the following problem(s)");
|
||||
|
|
@ -401,7 +402,7 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
if(check_additem('[% UniqueItemFields | html %]') == false){
|
||||
if(check_additem('[% Koha.Preference("UniqueItemFields") | html %]') == false){
|
||||
alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
|
||||
return false;
|
||||
};
|
||||
|
|
@ -419,7 +420,7 @@
|
|||
$(lastitemblock).remove();
|
||||
}
|
||||
|
||||
if(check_additem('[% UniqueItemFields | html %]') == false){
|
||||
if(check_additem('[% Koha.Preference("UniqueItemFields") | html %]') == false){
|
||||
alert(_("Duplicate values detected. Please correct the errors and resubmit.") );
|
||||
if(tobedeleted) {
|
||||
$(lastitemblock).appendTo("#outeritemblock");
|
||||
|
|
@ -478,7 +479,7 @@
|
|||
[% END %]
|
||||
|
||||
$(document).ready(function() {
|
||||
[% IF (AcqCreateItemReceiving) %]
|
||||
[% IF (AcqCreateItem == 'receiving') %]
|
||||
cloneItemBlock(0, '[% UniqueItemFields | html %]');
|
||||
[% ELSIF (AcqCreateItem == 'ordering') && not order.subscriptionid %]
|
||||
$("input[name='items_to_receive']").change(function() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue