View | Details | Raw Unified | Return to bug 7178
Collapse All | Expand All

(-)a/acqui/check_uniqueness.pl (+70 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 2 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
use C4::Context;
24
use C4::Output;
25
use C4::Auth;
26
27
my $input     = new CGI;
28
my @field     = $input->param('field');
29
my @value     = $input->param('value');
30
31
my $dbh = C4::Context->dbh;
32
33
my $r;
34
my $index = 0;
35
for my $f ( @field ) {
36
    my $query;
37
    given ( $f ) {
38
        when ( "barcode" ) {
39
            $query = "SELECT barcode FROM items WHERE barcode=?";
40
        }
41
        when ( "stocknumber" ) {
42
            $query = "SELECT stocknumber FROM items WHERE stocknumber=?";
43
        }
44
        when ( "copynumber" ) {
45
            $query = "SELECT copynumber FROM items WHERE copynumber=?";
46
        }
47
    }
48
49
    if($query) {
50
        my $sth = $dbh->prepare( $query );
51
        $sth->execute( $value[$index] );
52
        my @values = $sth->fetchrow_array;
53
        if ( @values ) {
54
            $r .= "$f:$values[0];";
55
        }
56
    }
57
    $index++;
58
}
59
60
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
61
    {   template_name   => "acqui/ajax.tmpl",
62
        query           => $input,
63
        type            => "intranet",
64
        authnotrequired => 0,
65
        debug           => 1,
66
    }
67
);
68
$template->param( return => $r );
69
70
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/acqui/neworderempty.pl (-9 / +4 lines)
Lines 317-333 if ($CGIsort2) { Link Here
317
}
317
}
318
318
319
if (C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber) {
319
if (C4::Context->preference('AcqCreateItem') eq 'ordering' && !$ordernumber) {
320
    # prepare empty item form
320
    # Check if ACQ framework exists
321
    my $cell = PrepareItemrecordDisplay('','','','ACQ');
321
    my $marc = GetMarcStructure(1, 'ACQ');
322
#     warn "==> ".Data::Dumper::Dumper($cell);
322
    unless($marc) {
323
    unless ($cell) {
324
        $cell = PrepareItemrecordDisplay('','','','');
325
        $template->param('NoACQframework' => 1);
323
        $template->param('NoACQframework' => 1);
326
    }
324
    }
327
    my @itemloop;
325
    $template->param(AcqCreateItemOrdering => 1);
328
    push @itemloop,$cell;
329
    
330
    $template->param(items => \@itemloop);
331
}
326
}
332
# 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
327
# 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
333
my @itemtypes;
328
my @itemtypes;
(-)a/acqui/orderreceive.pl (-8 / +4 lines)
Lines 116-131 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
116
# prepare the form for receiving
116
# prepare the form for receiving
117
if ( $count == 1 ) {
117
if ( $count == 1 ) {
118
    if (C4::Context->preference('AcqCreateItem') eq 'receiving') {
118
    if (C4::Context->preference('AcqCreateItem') eq 'receiving') {
119
        # prepare empty item form
119
        # Check if ACQ framework exists
120
        my $cell = PrepareItemrecordDisplay('','','','ACQ');
120
        my $marc = GetMarcStructure(1, 'ACQ');
121
        unless ($cell) {
121
        unless($marc) {
122
            $cell = PrepareItemrecordDisplay('','','','');
123
            $template->param('NoACQframework' => 1);
122
            $template->param('NoACQframework' => 1);
124
        }
123
        }
125
        my @itemloop;
124
        $template->param(AcqCreateItemReceiving => 1);
126
        push @itemloop,$cell;
127
        
128
        $template->param(items => \@itemloop);
129
    }
125
    }
130
126
131
    if ( @$results[0]->{'quantityreceived'} == 0 ) {
127
    if ( @$results[0]->{'quantityreceived'} == 0 ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/additem.js.inc (+10 lines)
Line 0 Link Here
1
<script type="text/javascript">
2
//<![CDATA[
3
var MSG_ADDITEM_JS_SHOW = _("Show");
4
var MSG_ADDITEM_JS_DELETE = _("Delete");
5
var MSG_ADDITEM_JS_CLEAR = _("Clear");
6
var MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS = _("You can't receive any more items");
7
var MSG_ADDITEM_JS_IS_DUPLICATE = _("is duplicated");
8
var MSG_ADDITEM_JS_ALREADY_EXISTS_IN_DB = _("already exists in database");
9
//]]>
10
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js (-103 / +223 lines)
Lines 1-110 Link Here
1
function deleteItemBlock(index) {
1
function addItem( node ) {
2
    var aDiv = document.getElementById(index);
2
    var index = $(node).parent().attr('id');
3
    aDiv.parentNode.removeChild(aDiv);
3
    var current_qty = parseInt($("#quantity").val());
4
    var quantity = document.getElementById('quantity');
4
    var max_qty;
5
    quantity.setAttribute('value',parseFloat(quantity.getAttribute('value'))-1);
5
    if($("#quantity_to_receive").length != 0){
6
        max_qty = parseInt($("#quantity_to_receive").val());
7
    } else  {
8
        max_qty = 99999;
9
    }
10
    if ( $("#items_list table").find('tr[idblock="' + index + '"]').length == 0 ) {
11
        if ( current_qty < max_qty ) {
12
            if ( current_qty < max_qty - 1 )
13
                cloneItemBlock(index);
14
            addItemInList(index);
15
            $("#quantity").val(current_qty + 1);
16
        } else if ( current_qty >= max_qty ) {
17
            alert(window.MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS
18
                || "You can't receive any more items.");
19
        }
20
    } else {
21
        if ( current_qty < max_qty )
22
            cloneItemBlock(index);
23
        var tr = constructTrNode(index);
24
        $("#items_list table").find('tr[idblock="' + index + '"]:first').replaceWith(tr);
25
    }
26
    $("#" + index).hide();
27
}
28
29
function showItem(index) {
30
    $("#outeritemblock").children("div").each(function(){
31
        if ( $(this).attr('id') == index ) {
32
            $(this).show();
33
        } else {
34
            if ( $("#items_list table").find('tr[idblock="' + $(this).attr('id') + '"]').length == 0 ) {
35
                $(this).remove();
36
            } else {
37
                $(this).hide();
38
            }
39
        }
40
    });
41
}
42
43
function constructTrNode(index) {
44
    var barcode = $('#' + index).find("[name='kohafield'][value='items.barcode']").prevAll("[name='field_value']")[0];
45
    barcode = $(barcode).val();
46
    var homebranch = $("#" + index).find("[name='kohafield'][value='items.homebranch']").prevAll("[name='field_value']")[0];
47
    homebranch = $(homebranch).val();
48
    var loc = $("#" + index).find("[name='kohafield'][value='items.location']").prevAll("[name='field_value']")[0];
49
    loc = $(loc).val();
50
    var callnumber = $("#" + index).find("[name='kohafield'][value='items.itemcallnumber']").prevAll("[name='field_value']")[0];
51
    callnumber = $(callnumber).val();
52
    var show_link = "<a href='#items' onclick='showItem(\"" + index + "\");'>"
53
        + (window.MSG_ADDITEM_JS_SHOW || "Show") + "</a>";
54
    var del_link = "<a href='#' onclick='deleteItemBlock(this, \"" + index + "\");'>"
55
        + (window.MSG_ADDITEM_JS_DELETE || "Delete") + "</a>";
56
    var result = "<tr idblock='" + index + "'>";
57
    result += "<td>" + barcode + "</td>";
58
    result += "<td>" + homebranch + "</td>";
59
    result += "<td>" + loc + "</td>";
60
    result += "<td>" + callnumber + "</td>";
61
    result += "<td>" + show_link + "</td>";
62
    result += "<td>" + del_link + "</td>";
63
    result += "</tr>";
64
65
    return result;
6
}
66
}
7
function cloneItemBlock(index) {    
67
8
    var original = document.getElementById(index); //original <div>
68
function addItemInList(index) {
9
    var clone = clone_with_selected(original)
69
    $("#items_list").show();
70
    var tr = constructTrNode(index);
71
    $("#items_list table tbody").append(tr);
72
}
73
74
function deleteItemBlock(node_a, index) {
75
    $("#" + index).remove();
76
    var current_qty = parseInt($("#quantity").val());
77
    var max_qty;
78
    if($("#quantity_to_receive").length != 0) {
79
        max_qty = parseInt($("#quantity_to_receive").val());
80
    } else {
81
        max_qty = 99999;
82
    }
83
    $("#quantity").val(current_qty - 1);
84
    $(node_a).parents('tr').remove();
85
    if(current_qty - 1 == 0)
86
        $("#items_list").hide();
87
88
    if ( $("#quantity").val() <= max_qty - 1) {
89
        if ( $("#outeritemblock").children("div :visible").length == 0 ) {
90
            $("#outeritemblock").children("div:last").show();
91
        }
92
    }
93
    if ( $("#quantity").val() == 0 && $("#outeritemblock > div").length == 0) {
94
        cloneItemBlock();
95
    }
96
}
97
98
function cloneItemBlock(index) {
99
    var original;
100
    if(index) {
101
        original = $("#" + index); //original <div>
102
    }
103
    var dont_copy_fields = ['items.barcode'];
104
10
    var random = Math.floor(Math.random()*100000); // get a random itemid.
105
    var random = Math.floor(Math.random()*100000); // get a random itemid.
11
    // set the attribute for the new 'div' subfields
106
    var clone = $("<div id='itemblock"+random+"'></div>")
12
    clone.setAttribute('id',index + random);//set another id.
107
    $.ajax({
13
    var NumTabIndex;
108
        url: "/cgi-bin/koha/services/itemrecorddisplay.pl",
14
    NumTabIndex = parseInt(original.getAttribute('tabindex'));
109
        dataType: 'html',
15
    if(isNaN(NumTabIndex)) NumTabIndex = 0;
110
        data: {
16
    clone.setAttribute('tabindex',NumTabIndex+1);
111
            frameworkcode: 'ACQ'
17
    var CloneButtonPlus;
112
        },
18
    var CloneButtonMinus;
113
        success: function(data, textStatus, jqXHR) {
19
  //  try{
114
            /* Create the item block */
20
        var jclone = $(clone);
115
            $(clone).append(data);
21
        CloneButtonPlus = $("a.addItem", jclone).get(0);
116
            /* Change all itemid fields value */
22
        CloneButtonPlus.setAttribute('onclick',"cloneItemBlock('" + index + random + "')");
117
            $(clone).find("input[name='itemid']").each(function(){
23
    CloneButtonMinus = $("a.delItem", jclone).get(0);
118
                $(this).val(random);
24
    CloneButtonMinus.setAttribute('onclick',"deleteItemBlock('" + index + random + "')");
119
            });
25
    CloneButtonMinus.setAttribute('style',"display:inline");
120
            /* Add buttons + and Clear */
26
    // change itemids of the clone
121
            var buttonPlus = '<a name="buttonPlus" style="cursor:pointer; color:grey; font-size:180%; margin:0 1em;" onclick="addItem(this)">+</a>';
27
    var elems = clone.getElementsByTagName('input');
122
            var buttonClear = '<a name="buttonClear" style="cursor:pointer; color:grey; font-size:180%" onclick="clearItemBlock(this)">' + (window.MSG_ADDITEM_JS_CLEAR || 'Clear') + '</a>';
28
    for( i = 0 ; elems[i] ; i++ )
123
            $(clone).append(buttonPlus).append(buttonClear);
29
    {
124
            /* Copy values from the original block (input) */
30
        if(elems[i].name.match(/^itemid/)) {
125
            $(original).find("input[name='field_value']").each(function(){
31
            elems[i].value = random;
126
                var kohafield = $(this).siblings("input[name='kohafield']").val();
127
                if($(this).val() && dont_copy_fields.indexOf(kohafield) == -1) {
128
                    $(this).parent("div").attr("id").match(/^(subfield.)/);
129
                    var id = RegExp.$1;
130
                    var value = $(this).val();
131
                    $(clone).find("div[id^='"+id+"'] input[name='field_value']").val(value);
132
                }
133
            });
134
            /* Copy values from the original block (select) */
135
            $(original).find("select[name='field_value']").each(function(){
136
                var kohafield = $(this).siblings("input[name='kohafield']").val();
137
                if($(this).val() && dont_copy_fields.indexOf(kohafield) == -1) {
138
                    $(this).parent("div").attr("id").match(/^(subfield.)/);
139
                    var id = RegExp.$1;
140
                    var value = $(this).val();
141
                    $(clone).find("div[id^='"+id+"'] select[name='field_value']").val(value);
142
                }
143
            });
144
145
            $("#outeritemblock").append(clone);
32
        }
146
        }
33
    }    
147
    });
34
   // }
148
}
35
    //catch(e){        // do nothig if ButtonPlus & CloneButtonPlus don't exist.
149
36
    //}
150
function clearItemBlock(node) {
37
    // insert this line on the page    
151
    var index = $(node).parent().attr('id');
38
    original.parentNode.insertBefore(clone,original.nextSibling);
152
    var block = $("#"+index);
39
    var quantity = document.getElementById('quantity');
153
    $(block).find("input[type='text']").each(function(){
40
    quantity.setAttribute('value',parseFloat(quantity.getAttribute('value'))+1);
154
        $(this).val("");
155
    });
156
    $(block).find("select").each(function(){
157
        $(this).find("option:first").attr("selected", true);
158
    });
41
}
159
}
160
42
function check_additem() {
161
function check_additem() {
43
	var	barcodes = document.getElementsByName('barcode');
162
    var success = true;
44
	var success = true;
163
    var array_fields = ['items.barcode'];
45
	for(i=0;i<barcodes.length;i++){
164
    var url = '../acqui/check_uniqueness.pl?'; // Url for ajax call
46
		for(j=0;j<barcodes.length;j++){
165
    $(".error").empty(); // Clear error div
47
			if( (i > j) && (barcodes[i].value == barcodes[j].value) && barcodes[i].value !='') {
166
48
				barcodes[i].className='error';
167
    // Check if a value is duplicated in form
49
				barcodes[j].className='error';
168
    for ( field in array_fields ) {
50
				success = false;
169
        var fieldname = array_fields[field].split('.')[1];
51
			}
170
        var values = new Array();
52
		}
171
        $("[name='kohafield'][value="+array_fields[field]+"]").each(function(){
53
	}
172
            var input = $(this).prevAll("input[name='field_value']")[0];
54
	// TODO : Add AJAX function to test against barcodes already in the database, not just 
173
            if($(input).val()) {
55
	// duplicates within the form.  
174
                values.push($(input).val());
56
	return success;
175
                url += "field=" + fieldname + "&value=" + $(input).val() + "&"; // construct url
176
            }
177
        });
178
179
        var sorted_arr = values.sort();
180
        for (var i = 0; i < sorted_arr.length - 1; i += 1) {
181
            if (sorted_arr[i + 1] == sorted_arr[i]) {
182
                $(".error").append(
183
                    fieldname + " '" + sorted_arr[i] + "' "
184
                    + (window.MSG_ADDITEM_JS_IS_DUPLICATE || "is duplicated")
185
                    + "<br/>");
186
                success = false;
187
            }
188
        }
189
    }
190
191
    // If there is a duplication, we raise an error
192
    if ( success == false ) {
193
        $(".error").show();
194
        return false;
195
    }
196
197
    // Else, we check in DB
198
    var xmlhttp = null;
199
    xmlhttp = new XMLHttpRequest();
200
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
201
        xmlhttp.overrideMimeType('text/xml');
202
    }
203
204
    xmlhttp.open('GET', url, false);
205
    xmlhttp.send(null);
206
207
    xmlhttp.onreadystatechange = function() {
208
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {} else {}
209
    };
210
    var response  =  xmlhttp.responseText;
211
    var elts = response.split(';');
212
    if ( response.length > 0 && elts.length > 0 ) {
213
        for ( var i = 0 ; i < elts.length - 1 ; i += 1 ) {
214
            var fieldname = elts[i].split(':')[0];
215
            var value = elts[i].split(':')[1];
216
            $(".error").append(
217
                fieldname + " '" + value + "' "
218
                + window.MSG_ADDITEM_JS_ALREADY_EXISTS_IN_DB || "already exists in database"
219
                + "<br/>"
220
            );
221
        }
222
        success = false;
223
    }
224
225
    if ( success == false ) {
226
        $(".error").show();
227
    }
228
    return success;
57
}
229
}
58
230
59
function clone_with_selected (node) {
60
	   var origin = node.getElementsByTagName("select");
61
	   var tmp = node.cloneNode(true)
62
	   var selectelem = tmp.getElementsByTagName("select");
63
	   for (var i=0; i<origin.length; i++) {
64
	       selectelem[i].selectedIndex = origin[i].selectedIndex;
65
	   }
66
	   origin = null;
67
	   selectelem = null;
68
	   return tmp;
69
	}
70
71
$(document).ready(function(){
72
	$(".cloneItemBlock").click(function(){
73
		var clonedRow = $(this).parent().parent().clone(true);
74
		clonedRow.insertAfter($(this).parent().parent()).find("a.deleteItemBlock").show();
75
		// find ID of cloned row so we can increment it for the clone
76
		var count = $("input[id^=volinf]",clonedRow).attr("id");
77
		var current = Number(count.replace("volinf",""));
78
		var increment = current + 1;
79
		// loop over inputs
80
		var inputs = ["volinf","barcode"];
81
		jQuery.each(inputs,function() {
82
			// increment IDs of labels and inputs in the clone
83
			$("label[for="+this+current+"]",clonedRow).attr("for",this+increment);
84
			$("input[name="+this+"]",clonedRow).attr("id",this+increment);
85
		});
86
		// loop over selects
87
		var selects = ["homebranch","location","itemtype","ccode"];
88
		jQuery.each(selects,function() {
89
			// increment IDs of labels and selects in the clone
90
			$("label[for="+this+current+"]",clonedRow).attr("for",this+increment);
91
			$("input[name="+this+"]",clonedRow).attr("id",this+increment);
92
			$("select[name="+this+"]",clonedRow).attr("id",this+increment);
93
			// find the selected option and select it in the clone
94
			var selectedVal = $("select#"+this+current).find("option:selected").attr("value");
95
			$("select[name="+this+"] option[value="+selectedVal+"]",clonedRow).attr("selected","selected");
96
		});
97
		
98
		var quantityrec = parseFloat($("#quantityrec").attr("value"));
99
		quantityrec++;
100
		$("#quantityrec").attr("value",quantityrec);
101
		return false;
102
	});
103
	$(".deleteItemBlock").click(function(){
104
		$(this).parent().parent().remove();
105
		var quantityrec = parseFloat($("#quantityrec").attr("value"));
106
		quantityrec--;
107
		$("#quantityrec").attr("value",quantityrec);
108
		return false;
109
	});
110
});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-36 / +54 lines)
Lines 3-14 Link Here
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
4
5
<script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
5
<script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
6
[% INCLUDE 'additem.js.inc' %]
6
<script type="text/javascript" src="[% themelang %]/js/additem.js"></script>
7
<script type="text/javascript" src="[% themelang %]/js/additem.js"></script>
7
<script type="text/javascript">
8
<script type="text/javascript">
8
//<![CDATA[
9
//<![CDATA[
9
actTotal = "";
10
actTotal = "";
10
11
11
function Check(ff) {
12
function Check(ff) {
13
    [% IF (AcqCreateItemOrdering) %]
14
        // Remove last itemblock if it is not in items_list
15
        var lastitemblock = $("#outeritemblock > div:last");
16
        var tobedeleted = true;
17
        var listitems = $("#items_list tr");
18
        $(listitems).each(function(){
19
            if($(this).attr('idblock') == $(lastitemblock).attr('id')){
20
                tobedeleted = false;
21
            }
22
        });
23
        if(tobedeleted){
24
            $(lastitemblock).remove();
25
        }
26
    [% END %]
27
12
    var ok=0;
28
    var ok=0;
13
    var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
29
    var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
14
30
Lines 24-30 function Check(ff) { Link Here
24
					_alertString += "\n- "+ _("You must select a budget");
40
					_alertString += "\n- "+ _("You must select a budget");
25
    }
41
    }
26
42
27
    if (!(isNum(ff.quantity,0))){
43
    if (!(isNum(ff.quantity,0)) || ff.quantity.value == 0){
28
        ok=1;
44
        ok=1;
29
                    _alertString += "\n- " + _("Quantity must be greater than '0'");
45
                    _alertString += "\n- " + _("Quantity must be greater than '0'");
30
    }
46
    }
Lines 106-118 function Check(ff) { Link Here
106
        alert(_alertString);
122
        alert(_alertString);
107
        return false;
123
        return false;
108
    }
124
    }
109
110
    ff.submit();
111
112
}
125
}
113
126
114
$(document).ready(function() 
127
$(document).ready(function() 
115
    {
128
    {
129
        [% IF (AcqCreateItemOrdering) %]
130
            cloneItemBlock();
131
        [% END %]
116
        //We apply the fonction only for modify option
132
        //We apply the fonction only for modify option
117
        [% IF ( quantityrec ) %]
133
        [% IF ( quantityrec ) %]
118
        $('#quantity').blur(function() 
134
        $('#quantity').blur(function() 
Lines 169-174 $(document).ready(function() Link Here
169
        [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %]
185
        [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %]
170
</h2>
186
</h2>
171
187
188
<div class="error" style="display:none"></div>
189
172
[% IF ( basketno ) %]
190
[% IF ( basketno ) %]
173
    <div id="acqui_basket_summary"  class="yui-g">
191
    <div id="acqui_basket_summary"  class="yui-g">
174
	<fieldset class="rows">
192
	<fieldset class="rows">
Lines 208-214 $(document).ready(function() Link Here
208
    </div>
226
    </div>
209
[% END %]
227
[% END %]
210
228
211
<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform">
229
<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);">
212
230
213
<fieldset class="rows">
231
<fieldset class="rows">
214
        <legend>
232
        <legend>
Lines 310-350 $(document).ready(function() Link Here
310
            [% END %]
328
            [% END %]
311
        </ol>
329
        </ol>
312
    </fieldset>
330
    </fieldset>
313
    [% IF ( items ) %]
331
    [% IF (AcqCreateItemOrdering) %]
332
333
    <fieldset class="rows" id="items_list" style="display:none">
334
        <a name="items"><legend>Items list</legend></a>
335
        <table>
336
            <thead>
337
                <tr>
338
                    <th>Barcode</th>
339
                    <th>Home branch</th>
340
                    <th>Location</th>
341
                    <th>Call number</th>
342
                    <th>&nbsp;</th>
343
                    <th>&nbsp;</th>
344
                </tr>
345
            </thead>
346
            <tbody>
347
            </tbody>
348
        </table>
349
    </fieldset>
350
314
    <fieldset class="rows">
351
    <fieldset class="rows">
315
        <legend>Item</legend>
352
        <legend>Item</legend>
316
        [% IF ( NoACQframework ) %]
353
        [% IF ( NoACQframework ) %]
317
            <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
354
            <div class="dialog message">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</div>
318
        [% END %]
355
        [% END %]
319
356
320
        [% FOREACH item IN items %]
357
        <div id="outeritemblock"></div>
321
        <div id="outeritemblock">
322
        <div id="itemblock">
323
            <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
324
                <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
325
326
                    <label>[% iteminformatio.subfield %] - [% IF ( iteminformatio.mandatory ) %]<b>[% END %][% iteminformatio.marc_lib %][% IF ( iteminformatio.mandatory ) %] *</b>[% END %]</label>
327
                    [% iteminformatio.marc_value %]
328
                    <input type="hidden" name="itemid" value="1" />
329
                    <input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" />
330
                    <input type="hidden" name="tag" value="[% iteminformatio.tag %]" />
331
                    <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" />
332
                    <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" />
333
                    [% IF ( iteminformatio.ITEM_SUBFIELDS_ARE_NOT_REPEATABLE ) %]
334
                        <span class="buttonPlus" onclick="CloneSubfield('subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]')">+</span>
335
                    [% END %]
336
358
337
                </div></li>
338
            [% END %]
339
            </ol>
340
            <a class="addItem" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">Add</a>
341
            <a class="delItem" style="display:none;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">Delete</a>
342
        </div><!-- /iteminformation -->
343
        </div>
344
345
        [% END %] <!-- /items -->
346
    </fieldset>
359
    </fieldset>
347
    [% END %] <!-- items -->
360
    [% END %][%# IF (AcqCreateItemOrdering) %]
348
    <fieldset class="rows">
361
    <fieldset class="rows">
349
        <legend>Accounting Details</legend>
362
        <legend>Accounting Details</legend>
350
        <ol>
363
        <ol>
Lines 353-361 $(document).ready(function() Link Here
353
            <span class="label required">Quantity: </span>
366
            <span class="label required">Quantity: </span>
354
                    <input type="hidden" size="20" name="quantity" value="[% quantity %]" />[% quantity %]
367
                    <input type="hidden" size="20" name="quantity" value="[% quantity %]" />[% quantity %]
355
                [% ELSE %]
368
                [% ELSE %]
356
                <label class="required" for="quantity">Quantity: </label>
369
                    <label class="required" for="quantity">Quantity: </label>
357
                    [% IF ( items ) %]
370
                    [% IF (AcqCreateItemOrdering) %]
358
                        <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" onchange="calcNeworderTotal();" />
371
                        <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" onchange="updateCosts();" />
359
                    [% ELSE %]
372
                    [% ELSE %]
360
                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" />
373
                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" />
361
                    [% END %]
374
                    [% END %]
Lines 507-513 $(document).ready(function() Link Here
507
</ol>
520
</ol>
508
    </fieldset>
521
    </fieldset>
509
    <fieldset class="action">
522
    <fieldset class="action">
510
        <input type="button" value="Save" onclick="Check(this.form)" /> [% IF ( suggestionid ) %]<a class="cancel" href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Cancel</a>[% ELSE %]<a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>[% END %]
523
        <input type="submit" value="Save" />
524
        [% IF (suggestionid) %]
525
            <a class="cancel" href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Cancel</a>
526
        [% ELSE %]
527
            <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
528
        [% END %]
511
    </fieldset>
529
    </fieldset>
512
</form>
530
</form>
513
</div>
531
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-45 / +74 lines)
Lines 1-7 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Acquisitions &rsaquo; Receipt summary for : [% name %] [% IF ( invoice ) %]invoice, [% invoice %][% END %]</title>
2
<title>Koha &rsaquo; Acquisitions &rsaquo; Receipt summary for : [% name %] [% IF ( invoice ) %]invoice, [% invoice %][% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
[% INCLUDE 'additem.js.inc' %]
4
<script type="text/javascript" src="[% themelang %]/js/additem.js"> </script>
5
<script type="text/javascript" src="[% themelang %]/js/additem.js"> </script>
6
<script type="text/javascript">
7
//<![CDATA[
8
    function Check(form) {
9
        [% IF (AcqCreateItemReceiving) %]
10
            // Remove last itemblock if it is not in items_list
11
            var lastitemblock = $("#outeritemblock > div:last");
12
            var tobedeleted = true;
13
            var listitems = $("#items_list tr");
14
            $(listitems).each(function(){
15
                if($(this).attr('idblock') == $(lastitemblock).attr('id')){
16
                    tobedeleted = false;
17
                }
18
            });
19
            if(tobedeleted){
20
                $(lastitemblock).remove();
21
            }
22
23
            if(check_additem() == false){
24
                alert(_('Duplicate values detected. Please correct the errors and resubmit.') );
25
                return false;
26
            };
27
        [% END %]
28
29
        return true;
30
    }
31
32
    $(document).ready(function() {
33
        [% IF (AcqCreateItemReceiving) %]
34
            cloneItemBlock();
35
        [% END %]
36
    });
37
//]]>
38
</script>
5
</head>
39
</head>
6
<body>
40
<body>
7
[% INCLUDE 'header.inc' %]
41
[% INCLUDE 'header.inc' %]
Lines 18-27 Link Here
18
<h1>Receive items from : [% name %] [% IF ( invoice ) %][[% invoice %]] [% END %] (order #[% ordernumber %])</h1>
52
<h1>Receive items from : [% name %] [% IF ( invoice ) %][[% invoice %]] [% END %] (order #[% ordernumber %])</h1>
19
53
20
[% IF ( count ) %]
54
[% IF ( count ) %]
21
    <form action="/cgi-bin/koha/acqui/finishreceive.pl" method="post">
55
    <form action="/cgi-bin/koha/acqui/finishreceive.pl" method="post" onsubmit="return Check(this);">
22
<div class="yui-g">
56
<div class="yui-g">
23
<div class="yui-u first">
57
<div class="yui-u first">
24
    
58
    <div class="error" style="display:none"></div>
59
25
    <fieldset class="rows">
60
    <fieldset class="rows">
26
    <legend>Catalog Details</legend>
61
    <legend>Catalog Details</legend>
27
    <ol><li><span class="label">Title: </span><span class="title">[% title |html %]</span></li>
62
    <ol><li><span class="label">Title: </span><span class="title">[% title |html %]</span></li>
Lines 35-82 Link Here
35
        [% seriestitle %]</li>
70
        [% seriestitle %]</li>
36
    </ol>
71
    </ol>
37
	</fieldset>
72
	</fieldset>
38
    [% IF ( items ) %]
73
    [% IF (AcqCreateItemReceiving) %]
39
    <fieldset class="rows">
74
        <fieldset class="rows" id="items_list" style="display:none">
40
        <legend>Item</legend>
75
            <a name="items"><legend>Items list</legend></a>
41
        [% IF ( NoACQframework ) %]
76
            <table>
42
            <p class="required">No ACQ framework, using default. You should create a framework with code ACQ, the items framework would be used</p>
77
                <thead>
43
        [% END %]
78
                    <tr>
79
                        <th>Barcode</th>
80
                        <th>Home branch</th>
81
                        <th>Location</th>
82
                        <th>Call number</th>
83
                        <th>&nbsp;</th>
84
                        <th>&nbsp;</th>
85
                    </tr>
86
                </thead>
87
                <tbody>
88
                </tbody>
89
            </table>
90
        </fieldset>
44
91
45
        [% FOREACH item IN items %]
92
        <fieldset class="rows">
46
        <div id="outeritemblock">
93
            <legend>Item</legend>
47
        <div id="itemblock">
94
            [% IF ( NoACQframework ) %]
48
            <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
95
                <p class="required">
49
                <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
96
                    No ACQ framework, using default. You should create a
50
                                
97
                    framework with code ACQ, the items framework would be
51
                    <label>[% iteminformatio.subfield %] - [% IF ( iteminformatio.mandatory ) %]<b>[% END %][% iteminformatio.marc_lib %][% IF ( iteminformatio.mandatory ) %] *</b>[% END %]</label>
98
                    used
52
                    [% iteminformatio.marc_value %]
99
                </p>
53
                    <input type="hidden" name="itemid" value="1" />
54
                    <input type="hidden" name="kohafield" value="[% iteminformatio.kohafield %]" />
55
                    <input type="hidden" name="tag" value="[% iteminformatio.tag %]" />
56
                    <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" />
57
                    <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" />
58
                    [% IF ( iteminformatio.ITEM_SUBFIELDS_ARE_NOT_REPEATABLE ) %]
59
                        <span class="buttonPlus" onclick="CloneSubfield('subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]')">+</span>
60
                    [% END %]
61
            
62
                </div></li>
63
            [% END %]
100
            [% END %]
64
            </ol>
101
            <div id="outeritemblock"></div>
65
            <a class="addItem" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">Add</a>
102
        </fieldset>
66
            <a class="delItem" style="display:none;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">Delete</a>
103
    [% END %][%# IF (AcqCreateItemReceiving) %]
67
        </div><!-- /iteminformation -->
68
        </div>
69
        
70
        <input type="hidden" name="moditem" value="" /> 
71
        <input type="hidden" name="tag" value="[% item.itemtagfield %]" />
72
        <input type="hidden" name="subfield" value="[% item.itemtagsubfield %]" />
73
        <input type="hidden" name="serial" value="[% item.serialid %]" />
74
        <input type="hidden" name="bibnum" value="[% item.biblionumber %]" />
75
        <input type="hidden" name="itemid" value="1" />
76
        <input type="hidden" name="field_value" value="[% item.itemnumber %]" />
77
        [% END %] <!-- /items -->
78
    </fieldset>
79
    [% END %] <!-- items -->
80
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
104
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
81
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
105
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
82
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
106
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
Lines 94-105 Link Here
94
       <li><label for="creator">Created by: </label><span> [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]</span></li>
118
       <li><label for="creator">Created by: </label><span> [% IF ( memberfirstname and membersurname ) %][% IF ( memberfirstname ) %][% memberfirstname %][% END %] [% membersurname %][% ELSE %]No name[% END %]</span></li>
95
       <li><label for="quantityto">Quantity to receive: </label><span class="label">
119
       <li><label for="quantityto">Quantity to receive: </label><span class="label">
96
           [% IF ( edit ) %]
120
           [% IF ( edit ) %]
97
               <input type="text" name="quantity" value="[% quantity %]" />
121
               <input type="text" id="quantity_to_receive" name="quantity" value="[% quantity %]" />
98
           [% ELSE %]
122
           [% ELSE %]
99
               <input type="text" READONLY name="quantity" value="[% quantity %]" />
123
               <input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" value="[% quantity %]" />
100
           [% END %]
124
           [% END %]
101
           </span></li>
125
           </span></li>
102
        <li><label for="quantity">Quantity received: </label>
126
        <li><label for="quantity">Quantity received: </label>
127
          [% IF (AcqCreateItemReceiving) %]
128
            <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="0" />
129
          [% ELSE %]
103
            [% IF ( quantityreceived ) %]
130
            [% IF ( quantityreceived ) %]
104
                [% IF ( edit ) %]
131
                [% IF ( edit ) %]
105
                    <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived %]" />
132
                    <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived %]" />
Lines 120-125 Link Here
120
                [% END %]
147
                [% END %]
121
                <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="0" />
148
                <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="0" />
122
            [% END %]
149
            [% END %]
150
          [% END %][%# IF (AcqCreateItemReceiving) %]
123
		</li>
151
		</li>
124
        <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li>
152
        <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li>
125
        <li><label for="ecost">Budgeted cost: </label><input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /></li>
153
        <li><label for="ecost">Budgeted cost: </label><input type="text" size="20" name="ecost" id="ecost" value="[% ecost %]" /></li>
Lines 135-141 Link Here
135
163
136
</div>
164
</div>
137
</div><div class="yui-g"><fieldset class="action">
165
</div><div class="yui-g"><fieldset class="action">
138
        <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 %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
166
        <input type="submit"  value="Save" />
167
        <a class="cancel" href="/cgi-bin/koha/acqui/parcel.pl?supplierid=[% supplierid %]&amp;invoice=[% invoice %]&amp;gst=[% gst %]&amp;freight=[% freight %]">Cancel</a>
139
</fieldset></div>    </form>
168
</fieldset></div>    </form>
140
[% ELSE %]
169
[% ELSE %]
141
<div id="acqui_acquire_orderlist">
170
<div id="acqui_acquire_orderlist">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt (+25 lines)
Line 0 Link Here
1
<ol>
2
  [% FOREACH iteminfo IN iteminformation %]
3
    <li>
4
      <div class="subfield_line" style="[% iteminfo.hidden %];" id="subfield[% iteminfo.serialid %][% iteminfo.countitems %][% iteminfo.subfield %][% iteminfo.random %]">
5
        <label>
6
            [% iteminfo.subfield %] -
7
            [% IF ( iteminfo.mandatory ) %]
8
                <b>
9
            [% END %]
10
            [% iteminfo.marc_lib %]
11
            [% IF ( iteminfo.mandatory ) %]
12
                *</b>
13
            [% END %]
14
        </label>
15
        [% iteminfo.marc_value %]
16
        <input type="hidden" name="itemid" value="1" />
17
        <input type="hidden" name="kohafield" value="[% iteminfo.kohafield %]" />
18
        <input type="hidden" name="tag" value="[% iteminfo.tag %]" />
19
        <input type="hidden" name="subfield" value="[% iteminfo.subfield %]" />
20
        <input type="hidden" name="mandatory" value="[% iteminfo.mandatory %]" />
21
      </div>
22
    </li>
23
  [% END %]
24
</ol>
25
(-)a/services/itemrecorddisplay.pl (-1 / +58 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2011 BibLibre SARL
4
# This file is part of Koha.
5
#
6
# Koha is free software; you can redistribute it and/or modify it under the
7
# terms of the GNU General Public License as published by the Free Software
8
# Foundation; either version 2 of the License, or (at your option) any later
9
# version.
10
#
11
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with Koha; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19
=head1 NAME
20
21
itemrecorddisplay.pl
22
23
=head1 DESCRIPTION
24
25
Return a HTML form for Item record modification or creation.
26
It uses PrepareItemrecordDisplay
27
28
=cut
29
30
use strict;
31
use warnings;
32
33
use CGI;
34
use C4::Auth;
35
use C4::Output;
36
use C4::Biblio;
37
38
my $input = new CGI;
39
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user( {
40
    template_name   => 'services/itemrecorddisplay.tmpl',
41
    query           => $input,
42
    type            => 'intranet',
43
    authnotrequired => 1,
44
} );
45
46
my $biblionumber = $input->param('biblionumber') || '';
47
my $itemnumber = $input->param('itemnumber') || '';
48
my $frameworkcode = $input->param('frameworkcode') || '';
49
50
my $result = PrepareItemrecordDisplay($biblionumber, $itemnumber, undef, $frameworkcode);
51
unless($result) {
52
    $result = PrepareItemrecordDisplay($biblionumber, $itemnumber, undef, '');
53
}
54
55
$template->param(%$result);
56
57
output_html_with_http_headers $input, $cookie, $template->output;
58

Return to bug 7178