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

(-)a/acqui/check_unicity.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/js/additem.js (-91 / +214 lines)
Lines 1-97 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(_("You can't receive any more items."));
18
        }
19
    } else {
20
        if ( current_qty < max_qty )
21
            cloneItemBlock(index);
22
        var tr = constructTrNode(index);
23
        $("#items_list table").find('tr[idblock="' + index + '"]:first').replaceWith(tr);
24
    }
25
    $("#" + index).hide();
26
}
27
28
function showItem(index) {
29
    $("#outeritemblock").children("div").each(function(){
30
        if ( $(this).attr('id') == index ) {
31
            $(this).show();
32
        } else {
33
            if ( $("#items_list table").find('tr[idblock="' + $(this).attr('id') + '"]').length == 0 ) {
34
                $(this).remove();
35
            } else {
36
                $(this).hide();
37
            }
38
        }
39
    });
40
}
41
42
function constructTrNode(index) {
43
    var barcode = $('#' + index).find("[name='kohafield'][value='items.barcode']").prevAll("[name='field_value']")[0];
44
    barcode = $(barcode).val();
45
    var homebranch = $("#" + index).find("[name='kohafield'][value='items.homebranch']").prevAll("[name='field_value']")[0];
46
    homebranch = $(homebranch).val();
47
    var loc = $("#" + index).find("[name='kohafield'][value='items.location']").prevAll("[name='field_value']")[0];
48
    loc = $(loc).val();
49
    var callnumber = $("#" + index).find("[name='kohafield'][value='items.itemcallnumber']").prevAll("[name='field_value']")[0];
50
    callnumber = $(callnumber).val();
51
    var show_link = "<a href='#items' onclick='showItem(\"" + index + "\");'>Show</a>";
52
    var del_link = "<a href='#' onclick='deleteItemBlock(this, \"" + index + "\");'>Delete</a>";
53
    var result = "<tr idblock='" + index + "'>";
54
    result += "<td>" + barcode + "</td>";
55
    result += "<td>" + homebranch + "</td>";
56
    result += "<td>" + loc + "</td>";
57
    result += "<td>" + callnumber + "</td>";
58
    result += "<td>" + show_link + "</td>";
59
    result += "<td>" + del_link + "</td>";
60
    result += "</tr>";
61
62
    return result;
63
}
64
65
function addItemInList(index) {
66
    $("#items_list").show();
67
    var tr = constructTrNode(index);
68
    $("#items_list table tbody").append(tr);
6
}
69
}
7
function cloneItemBlock(index) {    
70
8
    var original = document.getElementById(index); //original <div>
71
function deleteItemBlock(node_a, index) {
9
    var clone = original.cloneNode(true);
72
    $("#" + index).remove();
73
    var current_qty = parseInt($("#quantity").val());
74
    var max_qty;
75
    if($("#quantity_to_receive").length != 0) {
76
        max_qty = parseInt($("#quantity_to_receive").val());
77
    } else {
78
        max_qty = 99999;
79
    }
80
    $("#quantity").val(current_qty - 1);
81
    $(node_a).parents('tr').remove();
82
    if(current_qty - 1 == 0)
83
        $("#items_list").hide();
84
85
    if ( $("#quantity").val() <= max_qty - 1) {
86
        if ( $("#outeritemblock").children("div :visible").length == 0 ) {
87
            $("#outeritemblock").children("div:last").show();
88
        }
89
    }
90
    if ( $("#quantity").val() == 0 && $("#outeritemblock > div").length == 0) {
91
        cloneItemBlock();
92
    }
93
}
94
95
function cloneItemBlock(index) {
96
    var original;
97
    if(index) {
98
        original = $("#" + index); //original <div>
99
    }
100
    var dont_copy_fields = ['items.stocknumber', 'items.copynumber', 'items.barcode'];
101
10
    var random = Math.floor(Math.random()*100000); // get a random itemid.
102
    var random = Math.floor(Math.random()*100000); // get a random itemid.
11
    // set the attribute for the new 'div' subfields
103
    var clone = $("<div id='itemblock"+random+"'></div>")
12
    clone.setAttribute('id',index + random);//set another id.
104
    $.ajax({
13
    var NumTabIndex;
105
        url: "/cgi-bin/koha/services/itemrecorddisplay.pl",
14
    NumTabIndex = parseInt(original.getAttribute('tabindex'));
106
        dataType: 'html',
15
    if(isNaN(NumTabIndex)) NumTabIndex = 0;
107
        data: {
16
    clone.setAttribute('tabindex',NumTabIndex+1);
108
            frameworkcode: 'ACQ'
17
    var CloneButtonPlus;
109
        },
18
    var CloneButtonMinus;
110
        success: function(data, textStatus, jqXHR) {
19
  //  try{
111
            /* Create the item block */
20
        var jclone = $(clone);
112
            $(clone).append(data);
21
        CloneButtonPlus = $("a.addItem", jclone).get(0);
113
            /* Change all itemid fields value */
22
        CloneButtonPlus.setAttribute('onclick',"cloneItemBlock('" + index + random + "')");
114
            $(clone).find("input[name='itemid']").each(function(){
23
    CloneButtonMinus = $("a.delItem", jclone).get(0);
115
                $(this).val(random);
24
    CloneButtonMinus.setAttribute('onclick',"deleteItemBlock('" + index + random + "')");
116
            });
25
    CloneButtonMinus.setAttribute('style',"display:inline");
117
            /* Add buttons + and Clear */
26
    // change itemids of the clone
118
            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');
119
            var buttonClear = '<a name="buttonClear" style="cursor:pointer; color:grey; font-size:180%" onclick="clearItemBlock(this)">Clear</a>';
28
    for( i = 0 ; elems[i] ; i++ )
120
            $(clone).append(buttonPlus).append(buttonClear);
29
    {
121
            /* Copy values from the original block (input) */
30
        if(elems[i].name.match(/^itemid/)) {
122
            $(original).find("input[name='field_value']").each(function(){
31
            elems[i].value = random;
123
                var kohafield = $(this).siblings("input[name='kohafield']").val();
124
                if($(this).val() && dont_copy_fields.indexOf(kohafield) == -1) {
125
                    $(this).parent("div").attr("id").match(/^(subfield.)/);
126
                    var id = RegExp.$1;
127
                    var value = $(this).val();
128
                    $(clone).find("div[id^='"+id+"'] input[name='field_value']").val(value);
129
                }
130
            });
131
            /* Copy values from the original block (select) */
132
            $(original).find("select[name='field_value']").each(function(){
133
                var kohafield = $(this).siblings("input[name='kohafield']").val();
134
                if($(this).val() && dont_copy_fields.indexOf(kohafield) == -1) {
135
                    $(this).parent("div").attr("id").match(/^(subfield.)/);
136
                    var id = RegExp.$1;
137
                    var value = $(this).val();
138
                    $(clone).find("div[id^='"+id+"'] select[name='field_value']").val(value);
139
                }
140
            });
141
142
            $("#outeritemblock").append(clone);
32
        }
143
        }
33
    }    
144
    });
34
   // }
145
}
35
    //catch(e){        // do nothig if ButtonPlus & CloneButtonPlus don't exist.
146
36
    //}
147
function clearItemBlock(node) {
37
    // insert this line on the page    
148
    var index = $(node).parent().attr('id');
38
    original.parentNode.insertBefore(clone,original.nextSibling);
149
    var block = $("#"+index);
39
    var quantity = document.getElementById('quantity');
150
    $(block).find("input[type='text']").each(function(){
40
    quantity.setAttribute('value',parseFloat(quantity.getAttribute('value'))+1);
151
        $(this).val("");
152
    });
153
    $(block).find("select").each(function(){
154
        $(this).find("option:first").attr("selected", true);
155
    });
41
}
156
}
157
42
function check_additem() {
158
function check_additem() {
43
	var	barcodes = document.getElementsByName('barcode');
159
    var success = true;
44
	var success = true;
160
    var array_fields = ['items.stocknumber', 'items.copynumber', 'items.barcode'];
45
	for(i=0;i<barcodes.length;i++){
161
    var url = '../acqui/check_unicity.pl?'; // Url for ajax call
46
		for(j=0;j<barcodes.length;j++){
162
    $(".error").empty(); // Clear error div
47
			if( (i > j) && (barcodes[i].value == barcodes[j].value) && barcodes[i].value !='') {
163
48
				barcodes[i].className='error';
164
    // Check if a value is duplicated in form
49
				barcodes[j].className='error';
165
    for ( field in array_fields ) {
50
				success = false;
166
        var fieldname = array_fields[field].split('.')[1];
51
			}
167
        var values = new Array();
52
		}
168
        $("[name='kohafield'][value="+array_fields[field]+"]").each(function(){
53
	}
169
            var input = $(this).prevAll("input[name='field_value']")[0];
54
	// TODO : Add AJAX function to test against barcodes already in the database, not just 
170
            if($(input).val()) {
55
	// duplicates within the form.  
171
                values.push($(input).val());
56
	return success;
172
                url += "field=" + fieldname + "&value=" + $(input).val() + "&"; // construct url
173
            }
174
        });
175
176
        var sorted_arr = values.sort();
177
        for (var i = 0; i < sorted_arr.length - 1; i += 1) {
178
            if (sorted_arr[i + 1] == sorted_arr[i]) {
179
                $(".error").append( fieldname + " '" + sorted_arr[i] + "' is duplicated<br/>");
180
                success = false;
181
            }
182
        }
183
    }
184
185
    // If there is a duplication, we raise an error
186
    if ( success == false ) {
187
        $(".error").show();
188
        return false;
189
    }
190
191
    // Else, we check in DB
192
    var xmlhttp = null;
193
    xmlhttp = new XMLHttpRequest();
194
    if ( typeof xmlhttp.overrideMimeType != 'undefined') {
195
        xmlhttp.overrideMimeType('text/xml');
196
    }
197
198
    xmlhttp.open('GET', url, false);
199
    xmlhttp.send(null);
200
201
    xmlhttp.onreadystatechange = function() {
202
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {} else {}
203
    };
204
    var response  =  xmlhttp.responseText;
205
    var elts = response.split(';');
206
    if ( response.length > 0 && elts.length > 0 ) {
207
        for ( var i = 0 ; i < elts.length - 1 ; i += 1 ) {
208
            var fieldname = elts[i].split(':')[0];
209
            var value = elts[i].split(':')[1];
210
            $(".error").append( fieldname + " '" + value + "' already exist in database<br/>");
211
        }
212
        success = false;
213
    }
214
215
    if ( success == false ) {
216
        $(".error").show();
217
    }
218
    return success;
57
}
219
}
58
$(document).ready(function(){
220
59
	$(".cloneItemBlock").click(function(){
60
		var clonedRow = $(this).parent().parent().clone(true);
61
		clonedRow.insertAfter($(this).parent().parent()).find("a.deleteItemBlock").show();
62
		// find ID of cloned row so we can increment it for the clone
63
		var count = $("input[id^=volinf]",clonedRow).attr("id");
64
		var current = Number(count.replace("volinf",""));
65
		var increment = current + 1;
66
		// loop over inputs
67
		var inputs = ["volinf","barcode"];
68
		jQuery.each(inputs,function() {
69
			// increment IDs of labels and inputs in the clone
70
			$("label[for="+this+current+"]",clonedRow).attr("for",this+increment);
71
			$("input[name="+this+"]",clonedRow).attr("id",this+increment);
72
		});
73
		// loop over selects
74
		var selects = ["homebranch","location","itemtype","ccode"];
75
		jQuery.each(selects,function() {
76
			// increment IDs of labels and selects in the clone
77
			$("label[for="+this+current+"]",clonedRow).attr("for",this+increment);
78
			$("input[name="+this+"]",clonedRow).attr("id",this+increment);
79
			$("select[name="+this+"]",clonedRow).attr("id",this+increment);
80
			// find the selected option and select it in the clone
81
			var selectedVal = $("select#"+this+current).find("option:selected").attr("value");
82
			$("select[name="+this+"] option[value="+selectedVal+"]",clonedRow).attr("selected","selected");
83
		});
84
		
85
		var quantityrec = parseFloat($("#quantityrec").attr("value"));
86
		quantityrec++;
87
		$("#quantityrec").attr("value",quantityrec);
88
		return false;
89
	});
90
	$(".deleteItemBlock").click(function(){
91
		$(this).parent().parent().remove();
92
		var quantityrec = parseFloat($("#quantityrec").attr("value"));
93
		quantityrec--;
94
		$("#quantityrec").attr("value",quantityrec);
95
		return false;
96
	});
97
});
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-36 / +53 lines)
Lines 9-14 Link Here
9
actTotal = "";
9
actTotal = "";
10
10
11
function Check(ff) {
11
function Check(ff) {
12
    [% IF (AcqCreateItemOrdering) %]
13
        // Remove last itemblock if it is not in items_list
14
        var lastitemblock = $("#outeritemblock > div:last");
15
        var tobedeleted = true;
16
        var listitems = $("#items_list tr");
17
        $(listitems).each(function(){
18
            if($(this).attr('idblock') == $(lastitemblock).attr('id')){
19
                tobedeleted = false;
20
            }
21
        });
22
        if(tobedeleted){
23
            $(lastitemblock).remove();
24
        }
25
    [% END %]
26
12
    var ok=0;
27
    var ok=0;
13
    var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
28
    var _alertString= _("Form not submitted because of the following problem(s)")+"\n";
14
29
Lines 24-30 function Check(ff) { Link Here
24
					_alertString += "\n- "+ _("You must select a budget");
39
					_alertString += "\n- "+ _("You must select a budget");
25
    }
40
    }
26
41
27
    if (!(isNum(ff.quantity,0))){
42
    if (!(isNum(ff.quantity,0)) || ff.quantity.value == 0){
28
        ok=1;
43
        ok=1;
29
                    _alertString += "\n- " + _("Quantity must be greater than '0'");
44
                    _alertString += "\n- " + _("Quantity must be greater than '0'");
30
    }
45
    }
Lines 106-118 function Check(ff) { Link Here
106
        alert(_alertString);
121
        alert(_alertString);
107
        return false;
122
        return false;
108
    }
123
    }
109
110
    ff.submit();
111
112
}
124
}
113
125
114
$(document).ready(function() 
126
$(document).ready(function() 
115
    {
127
    {
128
        [% IF (AcqCreateItemOrdering) %]
129
            cloneItemBlock();
130
        [% END %]
116
        //We apply the fonction only for modify option
131
        //We apply the fonction only for modify option
117
        [% IF ( quantityrec ) %]
132
        [% IF ( quantityrec ) %]
118
        $('#quantity').blur(function() 
133
        $('#quantity').blur(function() 
Lines 169-174 $(document).ready(function() Link Here
169
        [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %]
184
        [% IF ( suggestionid ) %](defined from suggestion #[% suggestionid %])[% END %]
170
</h2>
185
</h2>
171
186
187
<div class="error" style="display:none"></div>
188
172
[% IF ( basketno ) %]
189
[% IF ( basketno ) %]
173
    <div id="acqui_basket_summary"  class="yui-g">
190
    <div id="acqui_basket_summary"  class="yui-g">
174
	<fieldset class="rows">
191
	<fieldset class="rows">
Lines 208-214 $(document).ready(function() Link Here
208
    </div>
225
    </div>
209
[% END %]
226
[% END %]
210
227
211
<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform">
228
<form action="/cgi-bin/koha/acqui/addorder.pl" method="post" id="Aform" onsubmit="return Check(this);">
212
229
213
<fieldset class="rows">
230
<fieldset class="rows">
214
        <legend>
231
        <legend>
Lines 310-350 $(document).ready(function() Link Here
310
            [% END %]
327
            [% END %]
311
        </ol>
328
        </ol>
312
    </fieldset>
329
    </fieldset>
313
    [% IF ( items ) %]
330
    [% IF (AcqCreateItemOrdering) %]
331
332
    <fieldset class="rows" id="items_list" style="display:none">
333
        <a name="items"><legend>Items list</legend></a>
334
        <table>
335
            <thead>
336
                <tr>
337
                    <th>Barcode</th>
338
                    <th>Home branch</th>
339
                    <th>Location</th>
340
                    <th>Call number</th>
341
                    <th>&nbsp;</th>
342
                    <th>&nbsp;</th>
343
                </tr>
344
            </thead>
345
            <tbody>
346
            </tbody>
347
        </table>
348
    </fieldset>
349
314
    <fieldset class="rows">
350
    <fieldset class="rows">
315
        <legend>Item</legend>
351
        <legend>Item</legend>
316
        [% IF ( NoACQframework ) %]
352
        [% 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>
353
            <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 %]
354
        [% END %]
319
355
320
        [% FOREACH item IN items %]
356
        <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
357
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>
358
    </fieldset>
347
    [% END %] <!-- items -->
359
    [% END %][%# IF (AcqCreateItemOrdering) %]
348
    <fieldset class="rows">
360
    <fieldset class="rows">
349
        <legend>Accounting Details</legend>
361
        <legend>Accounting Details</legend>
350
        <ol>
362
        <ol>
Lines 353-361 $(document).ready(function() Link Here
353
            <span class="label required">Quantity: </span>
365
            <span class="label required">Quantity: </span>
354
                    <input type="hidden" size="20" name="quantity" value="[% quantity %]" />[% quantity %]
366
                    <input type="hidden" size="20" name="quantity" value="[% quantity %]" />[% quantity %]
355
                [% ELSE %]
367
                [% ELSE %]
356
                <label class="required" for="quantity">Quantity: </label>
368
                    <label class="required" for="quantity">Quantity: </label>
357
                    [% IF ( items ) %]
369
                    [% IF (AcqCreateItemOrdering) %]
358
                        <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="1" onchange="calcNeworderTotal();" />
370
                        <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" onchange="updateCosts();" />
359
                    [% ELSE %]
371
                    [% ELSE %]
360
                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" />
372
                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" />
361
                    [% END %]
373
                    [% END %]
Lines 507-513 $(document).ready(function() Link Here
507
</ol>
519
</ol>
508
    </fieldset>
520
    </fieldset>
509
    <fieldset class="action">
521
    <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 %]
522
        <input type="submit" value="Save" />
523
        [% IF (suggestionid) %]
524
            <a class="cancel" href="/cgi-bin/koha/acqui/newordersuggestion.pl?booksellerid=[% booksellerid %]&amp;basketno=[% basketno %]">Cancel</a>
525
        [% ELSE %]
526
            <a class="cancel" href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basketno %]">Cancel</a>
527
        [% END %]
511
    </fieldset>
528
    </fieldset>
512
</form>
529
</form>
513
</div>
530
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt (-45 / +73 lines)
Lines 2-7 Link Here
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
<script type="text/javascript" src="[% themelang %]/js/additem.js"> </script>
4
<script type="text/javascript" src="[% themelang %]/js/additem.js"> </script>
5
<script type="text/javascript">
6
//<![CDATA[
7
    function Check(form) {
8
        [% IF (AcqCreateItemReceiving) %]
9
            // Remove last itemblock if it is not in items_list
10
            var lastitemblock = $("#outeritemblock > div:last");
11
            var tobedeleted = true;
12
            var listitems = $("#items_list tr");
13
            $(listitems).each(function(){
14
                if($(this).attr('idblock') == $(lastitemblock).attr('id')){
15
                    tobedeleted = false;
16
                }
17
            });
18
            if(tobedeleted){
19
                $(lastitemblock).remove();
20
            }
21
22
            if(check_additem() == false){
23
                alert(_('Duplicate values detected. Please correct the errors and resubmit.') );
24
                return false;
25
            };
26
        [% END %]
27
28
        return true;
29
    }
30
31
    $(document).ready(function() {
32
        [% IF (AcqCreateItemReceiving) %]
33
            cloneItemBlock();
34
        [% END %]
35
    });
36
//]]>
37
</script>
5
</head>
38
</head>
6
<body>
39
<body>
7
[% INCLUDE 'header.inc' %]
40
[% INCLUDE 'header.inc' %]
Lines 18-27 Link Here
18
<h1>Receive items from : [% name %] [% IF ( invoice ) %][[% invoice %]] [% END %] (order #[% ordernumber %])</h1>
51
<h1>Receive items from : [% name %] [% IF ( invoice ) %][[% invoice %]] [% END %] (order #[% ordernumber %])</h1>
19
52
20
[% IF ( count ) %]
53
[% IF ( count ) %]
21
    <form action="/cgi-bin/koha/acqui/finishreceive.pl" method="post">
54
    <form action="/cgi-bin/koha/acqui/finishreceive.pl" method="post" onsubmit="return Check(this);">
22
<div class="yui-g">
55
<div class="yui-g">
23
<div class="yui-u first">
56
<div class="yui-u first">
24
    
57
    <div class="error" style="display:none"></div>
58
25
    <fieldset class="rows">
59
    <fieldset class="rows">
26
    <legend>Catalog Details</legend>
60
    <legend>Catalog Details</legend>
27
    <ol><li><span class="label">Title: </span><span class="title">[% title |html %]</span></li>
61
    <ol><li><span class="label">Title: </span><span class="title">[% title |html %]</span></li>
Lines 35-82 Link Here
35
        [% seriestitle %]</li>
69
        [% seriestitle %]</li>
36
    </ol>
70
    </ol>
37
	</fieldset>
71
	</fieldset>
38
    [% IF ( items ) %]
72
    [% IF (AcqCreateItemReceiving) %]
39
    <fieldset class="rows">
73
        <fieldset class="rows" id="items_list" style="display:none">
40
        <legend>Item</legend>
74
            <a name="items"><legend>Items list</legend></a>
41
        [% IF ( NoACQframework ) %]
75
            <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>
76
                <thead>
43
        [% END %]
77
                    <tr>
78
                        <th>Barcode</th>
79
                        <th>Home branch</th>
80
                        <th>Location</th>
81
                        <th>Call number</th>
82
                        <th>&nbsp;</th>
83
                        <th>&nbsp;</th>
84
                    </tr>
85
                </thead>
86
                <tbody>
87
                </tbody>
88
            </table>
89
        </fieldset>
44
90
45
        [% FOREACH item IN items %]
91
        <fieldset class="rows">
46
        <div id="outeritemblock">
92
            <legend>Item</legend>
47
        <div id="itemblock">
93
            [% IF ( NoACQframework ) %]
48
            <ol>[% FOREACH iteminformatio IN item.iteminformation %]<li style="[% iteminformatio.hidden %];">
94
                <p class="required">
49
                <div class="subfield_line" id="subfield[% iteminformatio.serialid %][% iteminformatio.countitems %][% iteminformatio.subfield %][% iteminformatio.random %]">
95
                    No ACQ framework, using default. You should create a
50
                                
96
                    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>
97
                    used
52
                    [% iteminformatio.marc_value %]
98
                </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 %]
99
            [% END %]
64
            </ol>
100
            <div id="outeritemblock"></div>
65
            <a class="addItem" onclick="cloneItemBlock('itemblock[% item.itemBlockIndex %]')">Add</a>
101
        </fieldset>
66
            <a class="delItem" style="display:none;" onclick="deleteItemBlock('itemblock[% item.itemBlockIndex %]')">Delete</a>
102
    [% 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 %]" />
103
    <input type="hidden" name="biblionumber" value="[% biblionumber %]" />
81
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
104
    <input type="hidden" name="ordernumber" value="[% ordernumber %]" />
82
    <input type="hidden" name="biblioitemnumber" value="[% biblioitemnumber %]" />
105
    <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>
117
       <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">
118
       <li><label for="quantityto">Quantity to receive: </label><span class="label">
96
           [% IF ( edit ) %]
119
           [% IF ( edit ) %]
97
               <input type="text" name="quantity" value="[% quantity %]" />
120
               <input type="text" id="quantity_to_receive" name="quantity" value="[% quantity %]" />
98
           [% ELSE %]
121
           [% ELSE %]
99
               <input type="text" READONLY name="quantity" value="[% quantity %]" />
122
               <input type="text" readonly="readonly" id="quantity_to_receive" name="quantity" value="[% quantity %]" />
100
           [% END %]
123
           [% END %]
101
           </span></li>
124
           </span></li>
102
        <li><label for="quantity">Quantity received: </label>
125
        <li><label for="quantity">Quantity received: </label>
126
          [% IF (AcqCreateItemReceiving) %]
127
            <input readonly="readonly" type="text" size="20" name="quantityrec" id="quantity" value="0" />
128
          [% ELSE %]
103
            [% IF ( quantityreceived ) %]
129
            [% IF ( quantityreceived ) %]
104
                [% IF ( edit ) %]
130
                [% IF ( edit ) %]
105
                    <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived %]" />
131
                    <input type="text" size="20" name="quantityrec" id="quantity" value="[% quantityreceived %]" />
Lines 120-125 Link Here
120
                [% END %]
146
                [% END %]
121
                <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="0" />
147
                <input id="origquantityrec" READONLY type="hidden" name="origquantityrec" value="0" />
122
            [% END %]
148
            [% END %]
149
          [% END %][%# IF (AcqCreateItemReceiving) %]
123
		</li>
150
		</li>
124
        <li><label for="rrp">Replacement cost: </label><input type="text" size="20" name="rrp" id="rrp" value="[% rrp %]" /></li>
151
        <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>
152
        <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
162
136
</div>
163
</div>
137
</div><div class="yui-g"><fieldset class="action">
164
</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>
165
        <input type="submit"  value="Save" />
166
        <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>
167
</fieldset></div>    </form>
140
[% ELSE %]
168
[% ELSE %]
141
<div id="acqui_acquire_orderlist">
169
<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