Bugzilla – Attachment 7249 Details for
Bug 7178
Improve order item creation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7178: Acquisition item creation improvement
0001-Bug-7178-Acquisition-item-creation-improvement.patch (text/plain), 37.02 KB, created by
Julian Maurice
on 2012-01-19 16:09:34 UTC
(
hide
)
Description:
Bug 7178: Acquisition item creation improvement
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2012-01-19 16:09:34 UTC
Size:
37.02 KB
patch
obsolete
>From 383879f87ff1adb2ccb7cc1dbcbe24dac0f837fe Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 19 Jan 2012 16:59:58 +0100 >Subject: [PATCH] Bug 7178: Acquisition item creation improvement > >- Display a unique item block at once > >On orderreceive.pl when AcqCreateItem is 'receiving', and on >neworderempty.pl when AcqCreateItem is 'ordering' it displays an >item block with item infos to fill, and a '+' button. >When user clicks on '+', the block is hidden and a list shows up with >the items that will be received. User can then edit or delete items in >the list and click 'Save' to receive items. > >- PrepareItemrecordDisplay is now used for cloning block > >Previous cloning function was duplicating ids, the side effect is that >plugins didn't work when several items were displayed. >PrepareItemrecordDisplay regenerate the form with new ids >--- > acqui/check_unicity.pl | 70 +++++ > acqui/neworderempty.pl | 13 +- > acqui/orderreceive.pl | 12 +- > koha-tmpl/intranet-tmpl/prog/en/js/additem.js | 305 ++++++++++++++------ > .../prog/en/modules/acqui/neworderempty.tt | 89 ++++--- > .../prog/en/modules/acqui/orderreceive.tt | 118 +++++--- > .../prog/en/modules/services/itemrecorddisplay.tt | 25 ++ > services/itemrecorddisplay.pl | 58 ++++ > 8 files changed, 501 insertions(+), 189 deletions(-) > create mode 100755 acqui/check_unicity.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt > create mode 100755 services/itemrecorddisplay.pl > >diff --git a/acqui/check_unicity.pl b/acqui/check_unicity.pl >new file mode 100755 >index 0000000..d7cac5b >--- /dev/null >+++ b/acqui/check_unicity.pl >@@ -0,0 +1,70 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011 BibLibre SARL >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use CGI; >+use C4::Context; >+use C4::Output; >+use C4::Auth; >+ >+my $input = new CGI; >+my @field = $input->param('field'); >+my @value = $input->param('value'); >+ >+my $dbh = C4::Context->dbh; >+ >+my $r; >+my $index = 0; >+for my $f ( @field ) { >+ my $query; >+ given ( $f ) { >+ when ( "barcode" ) { >+ $query = "SELECT barcode FROM items WHERE barcode=?"; >+ } >+ when ( "stocknumber" ) { >+ $query = "SELECT stocknumber FROM items WHERE stocknumber=?"; >+ } >+ when ( "copynumber" ) { >+ $query = "SELECT copynumber FROM items WHERE copynumber=?"; >+ } >+ } >+ >+ if($query) { >+ my $sth = $dbh->prepare( $query ); >+ $sth->execute( $value[$index] ); >+ my @values = $sth->fetchrow_array; >+ if ( @values ) { >+ $r .= "$f:$values[0];"; >+ } >+ } >+ $index++; >+} >+ >+my ( $template, $loggedinuser, $cookie ) = get_template_and_user( >+ { template_name => "acqui/ajax.tmpl", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ debug => 1, >+ } >+); >+$template->param( return => $r ); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl >index 459dfe8..cd61218 100755 >--- a/acqui/neworderempty.pl >+++ b/acqui/neworderempty.pl >@@ -317,17 +317,12 @@ if ($CGIsort2) { > } > > if (C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber) { >- # prepare empty item form >- my $cell = PrepareItemrecordDisplay('','','','ACQ'); >-# warn "==> ".Data::Dumper::Dumper($cell); >- unless ($cell) { >- $cell = PrepareItemrecordDisplay('','','',''); >+ # Check if ACQ framework exists >+ my $marc = GetMarcStructure(1, 'ACQ'); >+ unless($marc) { > $template->param('NoACQframework' => 1); > } >- my @itemloop; >- push @itemloop,$cell; >- >- $template->param(items => \@itemloop); >+ $template->param(AcqCreateItemOrdering => 1); > } > # Get the item types list, but only if item_level_itype is YES. Otherwise, it will be in the item, no need to display it in the biblio > my @itemtypes; >diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl >index 753071d..20cb30f 100755 >--- a/acqui/orderreceive.pl >+++ b/acqui/orderreceive.pl >@@ -116,16 +116,12 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > # prepare the form for receiving > if ( $count == 1 ) { > if (C4::Context->preference('AcqCreateItem') eq 'receiving') { >- # prepare empty item form >- my $cell = PrepareItemrecordDisplay('','','','ACQ'); >- unless ($cell) { >- $cell = PrepareItemrecordDisplay('','','',''); >+ # Check if ACQ framework exists >+ my $marc = GetMarcStructure(1, 'ACQ'); >+ unless($marc) { > $template->param('NoACQframework' => 1); > } >- my @itemloop; >- push @itemloop,$cell; >- >- $template->param(items => \@itemloop); >+ $template->param(AcqCreateItemReceiving => 1); > } > > if ( @$results[0]->{'quantityreceived'} == 0 ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js b/koha-tmpl/intranet-tmpl/prog/en/js/additem.js >index efcb8eb..cd9c58b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/additem.js >@@ -1,97 +1,220 @@ >-function deleteItemBlock(index) { >- var aDiv = document.getElementById(index); >- aDiv.parentNode.removeChild(aDiv); >- var quantity = document.getElementById('quantity'); >- quantity.setAttribute('value',parseFloat(quantity.getAttribute('value'))-1); >+function addItem( node ) { >+ var index = $(node).parent().attr('id'); >+ var current_qty = parseInt($("#quantity").val()); >+ var max_qty; >+ if($("#quantity_to_receive").length != 0){ >+ max_qty = parseInt($("#quantity_to_receive").val()); >+ } else { >+ max_qty = 99999; >+ } >+ if ( $("#items_list table").find('tr[idblock="' + index + '"]').length == 0 ) { >+ if ( current_qty < max_qty ) { >+ if ( current_qty < max_qty - 1 ) >+ cloneItemBlock(index); >+ addItemInList(index); >+ $("#quantity").val(current_qty + 1); >+ } else if ( current_qty >= max_qty ) { >+ alert(_("You can't receive any more items.")); >+ } >+ } else { >+ if ( current_qty < max_qty ) >+ cloneItemBlock(index); >+ var tr = constructTrNode(index); >+ $("#items_list table").find('tr[idblock="' + index + '"]:first').replaceWith(tr); >+ } >+ $("#" + index).hide(); >+} >+ >+function showItem(index) { >+ $("#outeritemblock").children("div").each(function(){ >+ if ( $(this).attr('id') == index ) { >+ $(this).show(); >+ } else { >+ if ( $("#items_list table").find('tr[idblock="' + $(this).attr('id') + '"]').length == 0 ) { >+ $(this).remove(); >+ } else { >+ $(this).hide(); >+ } >+ } >+ }); >+} >+ >+function constructTrNode(index) { >+ var barcode = $('#' + index).find("[name='kohafield'][value='items.barcode']").prevAll("[name='field_value']")[0]; >+ barcode = $(barcode).val(); >+ var homebranch = $("#" + index).find("[name='kohafield'][value='items.homebranch']").prevAll("[name='field_value']")[0]; >+ homebranch = $(homebranch).val(); >+ var loc = $("#" + index).find("[name='kohafield'][value='items.location']").prevAll("[name='field_value']")[0]; >+ loc = $(loc).val(); >+ var callnumber = $("#" + index).find("[name='kohafield'][value='items.itemcallnumber']").prevAll("[name='field_value']")[0]; >+ callnumber = $(callnumber).val(); >+ var show_link = "<a href='#items' onclick='showItem(\"" + index + "\");'>Show</a>"; >+ var del_link = "<a href='#' onclick='deleteItemBlock(this, \"" + index + "\");'>Delete</a>"; >+ var result = "<tr idblock='" + index + "'>"; >+ result += "<td>" + barcode + "</td>"; >+ result += "<td>" + homebranch + "</td>"; >+ result += "<td>" + loc + "</td>"; >+ result += "<td>" + callnumber + "</td>"; >+ result += "<td>" + show_link + "</td>"; >+ result += "<td>" + del_link + "</td>"; >+ result += "</tr>"; >+ >+ return result; >+} >+ >+function addItemInList(index) { >+ $("#items_list").show(); >+ var tr = constructTrNode(index); >+ $("#items_list table tbody").append(tr); > } >-function cloneItemBlock(index) { >- var original = document.getElementById(index); //original <div> >- var clone = original.cloneNode(true); >+ >+function deleteItemBlock(node_a, index) { >+ $("#" + index).remove(); >+ var current_qty = parseInt($("#quantity").val()); >+ var max_qty; >+ if($("#quantity_to_receive").length != 0) { >+ max_qty = parseInt($("#quantity_to_receive").val()); >+ } else { >+ max_qty = 99999; >+ } >+ $("#quantity").val(current_qty - 1); >+ $(node_a).parents('tr').remove(); >+ if(current_qty - 1 == 0) >+ $("#items_list").hide(); >+ >+ if ( $("#quantity").val() <= max_qty - 1) { >+ if ( $("#outeritemblock").children("div :visible").length == 0 ) { >+ $("#outeritemblock").children("div:last").show(); >+ } >+ } >+ if ( $("#quantity").val() == 0 && $("#outeritemblock > div").length == 0) { >+ cloneItemBlock(); >+ } >+} >+ >+function cloneItemBlock(index) { >+ var original; >+ if(index) { >+ original = $("#" + index); //original <div> >+ } >+ var dont_copy_fields = ['items.stocknumber', 'items.copynumber', 'items.barcode']; >+ > var random = Math.floor(Math.random()*100000); // get a random itemid. >- // set the attribute for the new 'div' subfields >- clone.setAttribute('id',index + random);//set another id. >- var NumTabIndex; >- NumTabIndex = parseInt(original.getAttribute('tabindex')); >- if(isNaN(NumTabIndex)) NumTabIndex = 0; >- clone.setAttribute('tabindex',NumTabIndex+1); >- var CloneButtonPlus; >- var CloneButtonMinus; >- // try{ >- var jclone = $(clone); >- CloneButtonPlus = $("a.addItem", jclone).get(0); >- CloneButtonPlus.setAttribute('onclick',"cloneItemBlock('" + index + random + "')"); >- CloneButtonMinus = $("a.delItem", jclone).get(0); >- CloneButtonMinus.setAttribute('onclick',"deleteItemBlock('" + index + random + "')"); >- CloneButtonMinus.setAttribute('style',"display:inline"); >- // change itemids of the clone >- var elems = clone.getElementsByTagName('input'); >- for( i = 0 ; elems[i] ; i++ ) >- { >- if(elems[i].name.match(/^itemid/)) { >- elems[i].value = random; >+ var clone = $("<div id='itemblock"+random+"'></div>") >+ $.ajax({ >+ url: "/cgi-bin/koha/services/itemrecorddisplay.pl", >+ dataType: 'html', >+ data: { >+ frameworkcode: 'ACQ' >+ }, >+ success: function(data, textStatus, jqXHR) { >+ /* Create the item block */ >+ $(clone).append(data); >+ /* Change all itemid fields value */ >+ $(clone).find("input[name='itemid']").each(function(){ >+ $(this).val(random); >+ }); >+ /* Add buttons + and Clear */ >+ var buttonPlus = '<a name="buttonPlus" style="cursor:pointer; color:grey; font-size:180%; margin:0 1em;" onclick="addItem(this)">+</a>'; >+ var buttonClear = '<a name="buttonClear" style="cursor:pointer; color:grey; font-size:180%" onclick="clearItemBlock(this)">Clear</a>'; >+ $(clone).append(buttonPlus).append(buttonClear); >+ /* Copy values from the original block (input) */ >+ $(original).find("input[name='field_value']").each(function(){ >+ var kohafield = $(this).siblings("input[name='kohafield']").val(); >+ if($(this).val() && dont_copy_fields.indexOf(kohafield) == -1) { >+ $(this).parent("div").attr("id").match(/^(subfield.)/); >+ var id = RegExp.$1; >+ var value = $(this).val(); >+ $(clone).find("div[id^='"+id+"'] input[name='field_value']").val(value); >+ } >+ }); >+ /* Copy values from the original block (select) */ >+ $(original).find("select[name='field_value']").each(function(){ >+ var kohafield = $(this).siblings("input[name='kohafield']").val(); >+ if($(this).val() && dont_copy_fields.indexOf(kohafield) == -1) { >+ $(this).parent("div").attr("id").match(/^(subfield.)/); >+ var id = RegExp.$1; >+ var value = $(this).val(); >+ $(clone).find("div[id^='"+id+"'] select[name='field_value']").val(value); >+ } >+ }); >+ >+ $("#outeritemblock").append(clone); > } >- } >- // } >- //catch(e){ // do nothig if ButtonPlus & CloneButtonPlus don't exist. >- //} >- // insert this line on the page >- original.parentNode.insertBefore(clone,original.nextSibling); >- var quantity = document.getElementById('quantity'); >- quantity.setAttribute('value',parseFloat(quantity.getAttribute('value'))+1); >+ }); >+} >+ >+function clearItemBlock(node) { >+ var index = $(node).parent().attr('id'); >+ var block = $("#"+index); >+ $(block).find("input[type='text']").each(function(){ >+ $(this).val(""); >+ }); >+ $(block).find("select").each(function(){ >+ $(this).find("option:first").attr("selected", true); >+ }); > } >+ > function check_additem() { >- var barcodes = document.getElementsByName('barcode'); >- var success = true; >- for(i=0;i<barcodes.length;i++){ >- for(j=0;j<barcodes.length;j++){ >- if( (i > j) && (barcodes[i].value == barcodes[j].value) && barcodes[i].value !='') { >- barcodes[i].className='error'; >- barcodes[j].className='error'; >- success = false; >- } >- } >- } >- // TODO : Add AJAX function to test against barcodes already in the database, not just >- // duplicates within the form. >- return success; >+ var success = true; >+ var array_fields = ['items.stocknumber', 'items.copynumber', 'items.barcode']; >+ var url = '../acqui/check_unicity.pl?'; // Url for ajax call >+ $(".error").empty(); // Clear error div >+ >+ // Check if a value is duplicated in form >+ for ( field in array_fields ) { >+ var fieldname = array_fields[field].split('.')[1]; >+ var values = new Array(); >+ $("[name='kohafield'][value="+array_fields[field]+"]").each(function(){ >+ var input = $(this).prevAll("input[name='field_value']")[0]; >+ if($(input).val()) { >+ values.push($(input).val()); >+ url += "field=" + fieldname + "&value=" + $(input).val() + "&"; // construct url >+ } >+ }); >+ >+ var sorted_arr = values.sort(); >+ for (var i = 0; i < sorted_arr.length - 1; i += 1) { >+ if (sorted_arr[i + 1] == sorted_arr[i]) { >+ $(".error").append( fieldname + " '" + sorted_arr[i] + "' is duplicated<br/>"); >+ success = false; >+ } >+ } >+ } >+ >+ // If there is a duplication, we raise an error >+ if ( success == false ) { >+ $(".error").show(); >+ return false; >+ } >+ >+ // Else, we check in DB >+ var xmlhttp = null; >+ xmlhttp = new XMLHttpRequest(); >+ if ( typeof xmlhttp.overrideMimeType != 'undefined') { >+ xmlhttp.overrideMimeType('text/xml'); >+ } >+ >+ xmlhttp.open('GET', url, false); >+ xmlhttp.send(null); >+ >+ xmlhttp.onreadystatechange = function() { >+ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {} else {} >+ }; >+ var response = xmlhttp.responseText; >+ var elts = response.split(';'); >+ if ( response.length > 0 && elts.length > 0 ) { >+ for ( var i = 0 ; i < elts.length - 1 ; i += 1 ) { >+ var fieldname = elts[i].split(':')[0]; >+ var value = elts[i].split(':')[1]; >+ $(".error").append( fieldname + " '" + value + "' already exist in database<br/>"); >+ } >+ success = false; >+ } >+ >+ if ( success == false ) { >+ $(".error").show(); >+ } >+ return success; > } >-$(document).ready(function(){ >- $(".cloneItemBlock").click(function(){ >- var clonedRow = $(this).parent().parent().clone(true); >- clonedRow.insertAfter($(this).parent().parent()).find("a.deleteItemBlock").show(); >- // find ID of cloned row so we can increment it for the clone >- var count = $("input[id^=volinf]",clonedRow).attr("id"); >- var current = Number(count.replace("volinf","")); >- var increment = current + 1; >- // loop over inputs >- var inputs = ["volinf","barcode"]; >- jQuery.each(inputs,function() { >- // increment IDs of labels and inputs in the clone >- $("label[for="+this+current+"]",clonedRow).attr("for",this+increment); >- $("input[name="+this+"]",clonedRow).attr("id",this+increment); >- }); >- // loop over selects >- var selects = ["homebranch","location","itemtype","ccode"]; >- jQuery.each(selects,function() { >- // increment IDs of labels and selects in the clone >- $("label[for="+this+current+"]",clonedRow).attr("for",this+increment); >- $("input[name="+this+"]",clonedRow).attr("id",this+increment); >- $("select[name="+this+"]",clonedRow).attr("id",this+increment); >- // find the selected option and select it in the clone >- var selectedVal = $("select#"+this+current).find("option:selected").attr("value"); >- $("select[name="+this+"] option[value="+selectedVal+"]",clonedRow).attr("selected","selected"); >- }); >- >- var quantityrec = parseFloat($("#quantityrec").attr("value")); >- quantityrec++; >- $("#quantityrec").attr("value",quantityrec); >- return false; >- }); >- $(".deleteItemBlock").click(function(){ >- $(this).parent().parent().remove(); >- var quantityrec = parseFloat($("#quantityrec").attr("value")); >- quantityrec--; >- $("#quantityrec").attr("value",quantityrec); >- return false; >- }); >-}); >+ >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >index a6f26c4..0518448 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt >@@ -9,6 +9,21 @@ > actTotal = ""; > > function Check(ff) { >+ [% IF (AcqCreateItemOrdering) %] >+ // Remove last itemblock if it is not in items_list >+ var lastitemblock = $("#outeritemblock > div:last"); >+ var tobedeleted = true; >+ var listitems = $("#items_list tr"); >+ $(listitems).each(function(){ >+ if($(this).attr('idblock') == $(lastitemblock).attr('id')){ >+ tobedeleted = false; >+ } >+ }); >+ if(tobedeleted){ >+ $(lastitemblock).remove(); >+ } >+ [% END %] >+ > var ok=0; > var _alertString= _("Form not submitted because of the following problem(s)")+"\n"; > >@@ -24,7 +39,7 @@ function Check(ff) { > _alertString += "\n- "+ _("You must select a budget"); > } > >- if (!(isNum(ff.quantity,0))){ >+ if (!(isNum(ff.quantity,0)) || ff.quantity.value == 0){ > ok=1; > _alertString += "\n- " + _("Quantity must be greater than '0'"); > } >@@ -106,13 +121,13 @@ function Check(ff) { > alert(_alertString); > return false; > } >- >- ff.submit(); >- > } > > $(document).ready(function() > { >+ [% IF (AcqCreateItemOrdering) %] >+ cloneItemBlock(); >+ [% END %] > //We apply the fonction only for modify option > [% IF ( quantityrec ) %] > $('#quantity').blur(function() >@@ -169,6 +184,8 @@ $(document).ready(function() > [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %] > </h2> > >+<div class="error" style="display:none"></div> >+ > [% IF ( basketno ) %] > <div id="acqui_basket_summary" class="yui-g"> > <fieldset class="rows"> >@@ -208,7 +225,7 @@ $(document).ready(function() > </div> > [% END %] > >-<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform"> >+<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);"> > > <fieldset class="rows"> > <legend> >@@ -310,41 +327,36 @@ $(document).ready(function() > [% END %] > </ol> > </fieldset> >- [% IF ( items ) %] >+ [% IF (AcqCreateItemOrdering) %] >+ >+ <fieldset class="rows" id="items_list" style="display:none"> >+ <a name="items"><legend>Items list</legend></a> >+ <table> >+ <thead> >+ <tr> >+ <th>Barcode</th> >+ <th>Home branch</th> >+ <th>Location</th> >+ <th>Call number</th> >+ <th> </th> >+ <th> </th> >+ </tr> >+ </thead> >+ <tbody> >+ </tbody> >+ </table> >+ </fieldset> >+ > <fieldset class="rows"> > <legend>Item</legend> > [% IF ( NoACQframework ) %] > <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div> > [% END %] > >- [% FOREACH item IN items %] >- <div id="outeritemblock"> >- <div id="itemblock"> >- <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];"> >- <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]"> >- >- <label>[% iteminformatio.subfield %] - [% IF ( iteminformatio.mandatory ) %]<b>[% END %][% iteminformatio.marc_lib %][% IF ( iteminformatio.mandatory ) %] *</b>[% END %]</label> >- [% iteminformatio.marc_value %] >- <input type="hidden" name="itemid" value="1" /> >- <input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" /> >- <input type="hidden" name="tag" value="[% iteminformatio.tag %]" /> >- <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" /> >- <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" /> >- [% IF ( iteminformatio.ITEM_SUBFIELDS_ARE_NOT_REPEATABLE ) %] >- <span class="buttonPlus" onclick="CloneSubfield('subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]')">+</span> >- [% END %] >+ <div id="outeritemblock"></div> > >- </div></li> >- [% END %] >- </ol> >- <a class="addItem" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">Add</a> >- <a class="delItem" style="display:none;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">Delete</a> >- </div><!-- /iteminformation --> >- </div> >- >- [% END %] <!-- /items --> > </fieldset> >- [% END %] <!-- items --> >+ [% END %][%# IF (AcqCreateItemOrdering) %] > <fieldset class="rows"> > <legend>Accounting Details</legend> > <ol> >@@ -353,9 +365,9 @@ $(document).ready(function() > <span class="label required">Quantity: </span> > <input type="hidden" size="20" name="quantity" value="[% quantity %]" />[% quantity %] > [% ELSE %] >- <label class="required" for="quantity">Quantity: </label> >- [% IF ( items ) %] >- <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" onchange="calcNeworderTotal();" /> >+ <label class="required" for="quantity">Quantity: </label> >+ [% IF (AcqCreateItemOrdering) %] >+ <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" onchange="updateCosts();" /> > [% ELSE %] > <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" /> > [% END %] >@@ -507,7 +519,12 @@ $(document).ready(function() > </ol> > </fieldset> > <fieldset class="action"> >- <input type="button" value="Save" onclick="Check(this.form)" /> [% IF ( suggestionid ) %]<a class="cancel" href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&basketno=[% basketno %]">Cancel</a>[% ELSE %]<a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>[% END %] >+ <input type="submit" value="Save" /> >+ [% IF (suggestionid) %] >+ <a class="cancel" href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&basketno=[% basketno %]">Cancel</a> >+ [% ELSE %] >+ <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a> >+ [% END %] > </fieldset> > </form> > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >index ea422c8..fba3482 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt >@@ -2,6 +2,39 @@ > <title>Koha › Acquisitions › Receipt summary for : [% name %] [% IF ( invoice ) %]invoice, [% invoice %][% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/javascript" src="[% themelang %]/js/additem.js"> </script> >+<script type="text/javascript"> >+//<![CDATA[ >+ function Check(form) { >+ [% IF (AcqCreateItemReceiving) %] >+ // Remove last itemblock if it is not in items_list >+ var lastitemblock = $("#outeritemblock > div:last"); >+ var tobedeleted = true; >+ var listitems = $("#items_list tr"); >+ $(listitems).each(function(){ >+ if($(this).attr('idblock') == $(lastitemblock).attr('id')){ >+ tobedeleted = false; >+ } >+ }); >+ if(tobedeleted){ >+ $(lastitemblock).remove(); >+ } >+ >+ if(check_additem() == false){ >+ alert(_('Duplicate values detected. Please correct the errors and resubmit.') ); >+ return false; >+ }; >+ [% END %] >+ >+ return true; >+ } >+ >+ $(document).ready(function() { >+ [% IF (AcqCreateItemReceiving) %] >+ cloneItemBlock(); >+ [% END %] >+ }); >+//]]> >+</script> > </head> > <body> > [% INCLUDE 'header.inc' %] >@@ -18,10 +51,11 @@ > <h1>Receive items from : [% name %] [% IF ( invoice ) %][[% invoice %]] [% END %] (order #[% ordernumber %])</h1> > > [% IF ( count ) %] >- <form action="/cgi-bin/koha/acqui/finishreceive.pl" method="post"> >+ <form action="/cgi-bin/koha/acqui/finishreceive.pl" method="post" onsubmit="return Check(this);"> > <div class="yui-g"> > <div class="yui-u first"> >- >+ <div class="error" style="display:none"></div> >+ > <fieldset class="rows"> > <legend>Catalog Details</legend> > <ol><li><span class="label">Title: </span><span class="title">[% title |html %]</span></li> >@@ -35,48 +69,37 @@ > [% seriestitle %]</li> > </ol> > </fieldset> >- [% IF ( items ) %] >- <fieldset class="rows"> >- <legend>Item</legend> >- [% IF ( NoACQframework ) %] >- <p class="required">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</p> >- [% END %] >+ [% IF (AcqCreateItemReceiving) %] >+ <fieldset class="rows" id="items_list" style="display:none"> >+ <a name="items"><legend>Items list</legend></a> >+ <table> >+ <thead> >+ <tr> >+ <th>Barcode</th> >+ <th>Home branch</th> >+ <th>Location</th> >+ <th>Call number</th> >+ <th> </th> >+ <th> </th> >+ </tr> >+ </thead> >+ <tbody> >+ </tbody> >+ </table> >+ </fieldset> > >- [% FOREACH item IN items %] >- <div id="outeritemblock"> >- <div id="itemblock"> >- <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];"> >- <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]"> >- >- <label>[% iteminformatio.subfield %] - [% IF ( iteminformatio.mandatory ) %]<b>[% END %][% iteminformatio.marc_lib %][% IF ( iteminformatio.mandatory ) %] *</b>[% END %]</label> >- [% iteminformatio.marc_value %] >- <input type="hidden" name="itemid" value="1" /> >- <input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" /> >- <input type="hidden" name="tag" value="[% iteminformatio.tag %]" /> >- <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" /> >- <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" /> >- [% IF ( iteminformatio.ITEM_SUBFIELDS_ARE_NOT_REPEATABLE ) %] >- <span class="buttonPlus" onclick="CloneSubfield('subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]')">+</span> >- [% END %] >- >- </div></li> >+ <fieldset class="rows"> >+ <legend>Item</legend> >+ [% IF ( NoACQframework ) %] >+ <p class="required"> >+ No ACQ framework, using default. You should create a >+ framework with code ACQ, the items framework would be >+ used >+ </p> > [% END %] >- </ol> >- <a class="addItem" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">Add</a> >- <a class="delItem" style="display:none;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">Delete</a> >- </div><!-- /iteminformation --> >- </div> >- >- <input type="hidden" name="moditem" value="" /> >- <input type="hidden" name="tag" value="[% item.itemtagfield %]" /> >- <input type="hidden" name="subfield" value="[% item.itemtagsubfield %]" /> >- <input type="hidden" name="serial" value="[% item.serialid %]" /> >- <input type="hidden" name="bibnum" value="[% item.biblionumber %]" /> >- <input type="hidden" name="itemid" value="1" /> >- <input type="hidden" name="field_value" value="[% item.itemnumber %]" /> >- [% END %] <!-- /items --> >- </fieldset> >- [% END %] <!-- items --> >+ <div id="outeritemblock"></div> >+ </fieldset> >+ [% END %][%# IF (AcqCreateItemReceiving) %] > <input type="hidden" name="biblionumber" value="[% biblionumber %]" /> > <input type="hidden" name="ordernumber" value="[% ordernumber %]" /> > <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" /> >@@ -94,12 +117,15 @@ > <li><label for="creator">Created by: </label><span> [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]</span></li> > <li><label for="quantityto">Quantity to receive: </label><span class="label"> > [% IF ( edit ) %] >- <input type="text" name="quantity" value="[% quantity %]" /> >+ <input type="text" id="quantity_to_receive" name="quantity" value="[% quantity %]" /> > [% ELSE %] >- <input type="text" READONLY name="quantity" value="[% quantity %]" /> >+ <input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" value="[% quantity %]" /> > [% END %] > </span></li> > <li><label for="quantity">Quantity received: </label> >+ [% IF (AcqCreateItemReceiving) %] >+ <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="0" /> >+ [% ELSE %] > [% IF ( quantityreceived ) %] > [% IF ( edit ) %] > <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived %]" /> >@@ -120,6 +146,7 @@ > [% END %] > <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="0" /> > [% END %] >+ [% END %][%# IF (AcqCreateItemReceiving) %] > </li> > <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li> > <li><label for="ecost">Budgeted cost: </label><input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /></li> >@@ -135,7 +162,8 @@ > > </div> > </div><div class="yui-g"><fieldset class="action"> >- <input type="button" value="Save" onclick="javascript:if(check_additem()) { this.form.submit(); } else { alert( _('Duplicate barcodes detected. Please correct the errors and resubmit.') ); return false };" /> <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?supplierid=[% supplierid %]&invoice=[% invoice %]&gst=[% gst %]&freight=[% freight %]">Cancel</a> >+ <input type="submit" value="Save" /> >+ <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?supplierid=[% supplierid %]&invoice=[% invoice %]&gst=[% gst %]&freight=[% freight %]">Cancel</a> > </fieldset></div> </form> > [% ELSE %] > <div id="acqui_acquire_orderlist"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt >new file mode 100644 >index 0000000..696aca4 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt >@@ -0,0 +1,25 @@ >+<ol> >+ [% FOREACH iteminfo IN iteminformation %] >+ <li> >+ <div class="subfield_line" style="[% iteminfo.hidden %];" id="subfield[% iteminfo.serialid %][% iteminfo.countitems %][% iteminfo.subfield %][% iteminfo.random %]"> >+ <label> >+ [% iteminfo.subfield %] - >+ [% IF ( iteminfo.mandatory ) %] >+ <b> >+ [% END %] >+ [% iteminfo.marc_lib %] >+ [% IF ( iteminfo.mandatory ) %] >+ *</b> >+ [% END %] >+ </label> >+ [% iteminfo.marc_value %] >+ <input type="hidden" name="itemid" value="1" /> >+ <input type="hidden" name="kohafield" value="[% iteminfo.kohafield %]" /> >+ <input type="hidden" name="tag" value="[% iteminfo.tag %]" /> >+ <input type="hidden" name="subfield" value="[% iteminfo.subfield %]" /> >+ <input type="hidden" name="mandatory" value="[% iteminfo.mandatory %]" /> >+ </div> >+ </li> >+ [% END %] >+</ol> >+ >diff --git a/services/itemrecorddisplay.pl b/services/itemrecorddisplay.pl >new file mode 100755 >index 0000000..af22c35 >--- /dev/null >+++ b/services/itemrecorddisplay.pl >@@ -0,0 +1,58 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011 BibLibre SARL >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+=head1 NAME >+ >+itemrecorddisplay.pl >+ >+=head1 DESCRIPTION >+ >+Return a HTML form for Item record modification or creation. >+It uses PrepareItemrecordDisplay >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use CGI; >+use C4::Auth; >+use C4::Output; >+use C4::Biblio; >+ >+my $input = new CGI; >+my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( { >+ template_name => 'services/itemrecorddisplay.tmpl', >+ query => $input, >+ type => 'intranet', >+ authnotrequired => 1, >+} ); >+ >+my $biblionumber = $input->param('biblionumber') || ''; >+my $itemnumber = $input->param('itemnumber') || ''; >+my $frameworkcode = $input->param('frameworkcode') || ''; >+ >+my $result = PrepareItemrecordDisplay($biblionumber, $itemnumber, undef, $frameworkcode); >+unless($result) { >+ $result = PrepareItemrecordDisplay($biblionumber, $itemnumber, undef, ''); >+} >+ >+$template->param(%$result); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >+ >-- >1.7.8.3 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7178
:
6233
|
7249
|
7279
|
7450
|
7806
|
7807
|
7892
|
7963
|
8558
|
8672
|
8715
|
8857
|
8886
|
9511
|
9518
|
9690