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

(-)a/C4/Items.pm (+38 lines)
Lines 80-85 BEGIN { Link Here
80
	GetAnalyticsCount
80
	GetAnalyticsCount
81
        GetItemHolds
81
        GetItemHolds
82
82
83
        SearchItems
83
84
84
        PrepareItemrecordDisplay
85
        PrepareItemrecordDisplay
85
86
Lines 2496-2501 sub GetItemHolds { Link Here
2496
    $holds = $sth->fetchrow;
2497
    $holds = $sth->fetchrow;
2497
    return $holds;
2498
    return $holds;
2498
}
2499
}
2500
2501
# Return the list of the column names of items table
2502
sub _get_items_columns {
2503
    my $dbh = C4::Context->dbh;
2504
    my $sth = $dbh->column_info(undef, undef, 'items', '%');
2505
    $sth->execute;
2506
    my $results = $sth->fetchall_hashref('COLUMN_NAME');
2507
    return keys %$results;
2508
}
2509
2510
=head2 SearchItems
2511
2512
    my $items = SearchItems($field, $value);
2513
2514
SearchItems will search for items on a specific given field.
2515
For instance you can search all items with a specific stocknumber like this:
2516
2517
    my $items = SearchItems('stocknumber', $stocknumber);
2518
2519
=cut
2520
2521
sub SearchItems {
2522
    my ($field, $value) = @_;
2523
2524
    my $dbh = C4::Context->dbh;
2525
    my @columns = _get_items_columns;
2526
    my $results = [];
2527
    if(0 < grep /^$field$/, @columns) {
2528
        my $query = "SELECT $field FROM items WHERE $field = ?";
2529
        my $sth = $dbh->prepare( $query );
2530
        $sth->execute( $value );
2531
        $results = $sth->fetchall_arrayref({});
2532
    }
2533
    return $results;
2534
}
2535
2536
2499
=head1  OTHER FUNCTIONS
2537
=head1  OTHER FUNCTIONS
2500
2538
2501
=head2 _find_value
2539
=head2 _find_value
(-)a/acqui/check_uniqueness.pl (-21 / +6 lines)
Lines 33-68 use Modern::Perl; Link Here
33
33
34
use CGI;
34
use CGI;
35
use JSON;
35
use JSON;
36
use C4::Context;
37
use C4::Output;
36
use C4::Output;
38
use C4::Auth;
37
use C4::Items;
39
38
40
my $input = new CGI;
39
my $input = new CGI;
41
my @field = $input->param('field');
40
my @field = $input->param('field');
42
my @value = $input->param('value');
41
my @value = $input->param('value');
43
42
44
my $dbh = C4::Context->dbh;
45
46
my $query = "SHOW COLUMNS FROM items";
47
my $sth = $dbh->prepare($query);
48
$sth->execute;
49
my $results = $sth->fetchall_hashref('Field');
50
my @columns = keys %$results;
51
52
my $r = {};
43
my $r = {};
53
my $index = 0;
44
my $i = 0;
54
for my $f ( @field ) {
45
for ( my $i=0; $i<@field; $i++ ) {
55
    if(0 < grep /^$f$/, @columns) {
46
    my $items = C4::Items::SearchItems($field[$i], $value[$i]);
56
        $query = "SELECT $f FROM items WHERE $f = ?";
57
        $sth = $dbh->prepare( $query );
58
        $sth->execute( $value[$index] );
59
        my @values = $sth->fetchrow_array;
60
47
61
        if ( @values ) {
48
    if ( @$items ) {
62
            push @{ $r->{$f} }, $values[0];
49
        push @{ $r->{$field[$i]} }, $value[$i];
63
        }
64
    }
50
    }
65
    $index++;
66
}
51
}
67
52
68
output_with_http_headers $input, undef, to_json($r), 'json';
53
output_with_http_headers $input, undef, to_json($r), 'json';
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/additem.js (-2 / +2 lines)
Lines 13-19 function addItem( node, unique_item_fields ) { Link Here
13
                cloneItemBlock(index, unique_item_fields);
13
                cloneItemBlock(index, unique_item_fields);
14
            addItemInList(index, unique_item_fields);
14
            addItemInList(index, unique_item_fields);
15
            $("#" + index).find("a[name='buttonPlus']").text("Update");
15
            $("#" + index).find("a[name='buttonPlus']").text("Update");
16
            $("#quantity").val(current_qty + 1);
16
            $("#quantity").val(current_qty + 1).change();
17
        } else if ( current_qty >= max_qty ) {
17
        } else if ( current_qty >= max_qty ) {
18
            alert(window.MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS
18
            alert(window.MSG_ADDITEM_JS_CANT_RECEIVE_MORE_ITEMS
19
                || "You can't receive any more items.");
19
                || "You can't receive any more items.");
Lines 87-93 function deleteItemBlock(node_a, index, unique_item_fields) { Link Here
87
    } else {
87
    } else {
88
        max_qty = 99999;
88
        max_qty = 99999;
89
    }
89
    }
90
    $("#quantity").val(current_qty - 1);
90
    $("#quantity").val(current_qty - 1).change();
91
    $(node_a).parents('tr').remove();
91
    $(node_a).parents('tr').remove();
92
    if(current_qty - 1 == 0)
92
    if(current_qty - 1 == 0)
93
        $("#items_list").hide();
93
        $("#items_list").hide();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt (-3 / +7 lines)
Lines 104-109 $(document).ready(function() Link Here
104
        [% IF (AcqCreateItemOrdering) %]
104
        [% IF (AcqCreateItemOrdering) %]
105
            cloneItemBlock(0, '[% UniqueItemFields %]');
105
            cloneItemBlock(0, '[% UniqueItemFields %]');
106
        [% END %]
106
        [% END %]
107
108
        $("#quantity").change(function() {
109
            calcNeworderTotal();
110
        });
111
107
        //We apply the fonction only for modify option
112
        //We apply the fonction only for modify option
108
        [% IF ( quantityrec ) %]
113
        [% IF ( quantityrec ) %]
109
        $('#quantity').blur(function() 
114
        $('#quantity').blur(function() 
Lines 376-384 $(document).ready(function() Link Here
376
                [% ELSE %]
381
                [% ELSE %]
377
                    <label class="required" for="quantity">Quantity: </label>
382
                    <label class="required" for="quantity">Quantity: </label>
378
                    [% IF (AcqCreateItemOrdering) %]
383
                    [% IF (AcqCreateItemOrdering) %]
379
                        <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" onchange="updateCosts();" />
384
                        <input type="text" readonly="readonly" size="20" id="quantity" name="quantity" value="0" />
380
                    [% ELSE %]
385
                    [% ELSE %]
381
                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" onchange="calcNeworderTotal();" />
386
                        <input type="text" size="20" id="quantity" name="quantity" value="[% quantityrec %]" />
382
                    [% END %]
387
                    [% END %]
383
                [% END %]
388
                [% END %]
384
                <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
389
                <!-- origquantityrec only here for javascript compatibility (additem.js needs it, useless here, usefull when receiveing an order -->
385
- 

Return to bug 7178