<<

NAME

C4::Labels::Batch - A class for creating and manipulating batch objects in Koha

ABSTRACT

This module provides methods for creating, and otherwise manipulating batch objects used by Koha to create and export labels.

METHODS

new()

    Invoking the I<new> method constructs a new batch object with no items. It is possible to pre-populate the batch with items and a branch code by passing them
    as in the second example below.

    B<NOTE:> The items list must be an arrayref pointing to an array of hashes containing a key/data pair after this fashion: {item_number => item_number}. The order of
    the array elements determines the order of the items in the batch.

    example:
        C<my $batch = C4::Labels::Batch->new(); # Creates and returns a new batch object>

        C<my $batch = C4::Labels::Batch->new(items => $arrayref, branch_code => branch_code) #    Creates and returns a new batch object containing the items passed in
            with the branch code passed in.>

    B<NOTE:> This batch is I<not> written to the database until C<$batch->save()> is invoked. You have been warned!

$batch->add_item(item_number => $item_number, branch_code => $branch_code)

    Invoking the I<add_item> method will add the supplied item to the batch object.

    example:
        $batch->add_item(item_number => $item_number, branch_code => $branch_code);

$batch->get_attr($attribute)

    Invoking the I<get_attr> method will return the requested attribute.

    example:
        my @items = $batch->get_attr('items');

$batch->remove_item($item_number)

    Invoking the I<remove_item> method will remove the supplied item number from the batch object.

    example:
        $batch->remove_item($item_number);

C4::Labels::Batch->retrieve(batch_id => $batch_id)

    Invoking the I<retrieve> method constructs a new batch object containing the current values for batch_id. The method returns a new object upon success and 1 upon failure.
    Errors are logged to the Apache log.

    examples:

        my $batch = C4::Labels::Batch->retrieve(batch_id => 1); # Retrieves batch 1 and returns an object containing the record

delete()

    Invoking the delete method attempts to delete the template from the database. The method returns -1 upon failure. Errors are logged to the Apache log.
    NOTE: This method may also be called as a function and passed a key/value pair simply deleteing that batch from the database. See the example below.

    examples:
        my $exitstat = $batch->delete(); # to delete the record behind the $batch object
        my $exitstat = C4::Labels::Batch->delete(batch_id => 1); # to delete batch 1

remove_duplicates()

    Invoking the remove_duplicates method attempts to remove duplicate items in the batch from the database. The method returns the count of duplicate records removed upon
    success and -1 upon failure. Errors are logged to the Apache log.
    NOTE: This method may also be called as a function and passed a key/value pair removing duplicates in the batch passed in. See the example below.

    examples:
        my $remove_count = $batch->remove_duplicates(); # to remove duplicates the record behind the $batch object
        my $remove_count = C4::Labels::Batch->remove_duplicates(batch_id => 1); # to remove duplicates in batch 1

AUTHOR

Chris Nighswonger <cnighswonger AT foundations DOT edu>

COPYRIGHT

Copyright 2009 Foundations Bible College.

LICENSE

This file is part of Koha.

Koha is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

You should have received a copy of the GNU General Public License along with Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

DISCLAIMER OF WARRANTY

Koha is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

<<