<<

NAME

    C4::Koha - Perl Module containing convenience functions for Koha scripts

SYNOPSIS

  use C4::Koha;

DESCRIPTION

    Koha.pm provides many functions for Koha scripts.

FUNCTIONS

slashifyDate

  $slash_date = &slashifyDate($dash_date);

    Takes a string of the form "DD-MM-YYYY" (or anything separated by
    dashes), converts it to the form "YYYY/MM/DD", and returns the result.

DisplayISBN

    my $string = DisplayISBN( $isbn );

GetItemTypes

  $itemtypes = &GetItemTypes();

Returns information about existing itemtypes.

build a HTML select with the following code :

in PERL SCRIPT

    my $itemtypes = GetItemTypes;
    my @itemtypesloop;
    foreach my $thisitemtype (sort keys %$itemtypes) {
        my $selected = 1 if $thisitemtype eq $itemtype;
        my %row =(value => $thisitemtype,
                    selected => $selected,
                    description => $itemtypes->{$thisitemtype}->{'description'},
                );
        push @itemtypesloop, \%row;
    }
    $template->param(itemtypeloop => \@itemtypesloop);

in TEMPLATE

    <form action='<!-- TMPL_VAR name="script_name" -->' method=post>
        <select name="itemtype">
            <option value="">Default</option>
        <!-- TMPL_LOOP name="itemtypeloop" -->
            <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="description" --></option>
        <!-- /TMPL_LOOP -->
        </select>
        <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
        <input type="submit" value="OK" class="button">
    </form>

getauthtypes

  $authtypes = &getauthtypes();

Returns information about existing authtypes.

build a HTML select with the following code :

in PERL SCRIPT

my $authtypes = getauthtypes; my @authtypesloop; foreach my $thisauthtype (keys %$authtypes) { my $selected = 1 if $thisauthtype eq $authtype; my %row =(value => $thisauthtype, selected => $selected, authtypetext => $authtypes->{$thisauthtype}->{'authtypetext'}, ); push @authtypesloop, \%row; } $template->param(itemtypeloop => \@itemtypesloop);

in TEMPLATE

<form action='<!-- TMPL_VAR name="script_name" -->' method=post> <select name="authtype"> <!-- TMPL_LOOP name="authtypeloop" --> <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="authtypetext" --></option> <!-- /TMPL_LOOP --> </select> <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->"> <input type="submit" value="OK" class="button"> </form>

getframework

  $frameworks = &getframework();

Returns information about existing frameworks

build a HTML select with the following code :

in PERL SCRIPT

my $frameworks = frameworks(); my @frameworkloop; foreach my $thisframework (keys %$frameworks) { my $selected = 1 if $thisframework eq $frameworkcode; my %row =(value => $thisframework, selected => $selected, description => $frameworks->{$thisframework}->{'frameworktext'}, ); push @frameworksloop, \%row; } $template->param(frameworkloop => \@frameworksloop);

in TEMPLATE

<form action='<!-- TMPL_VAR name="script_name" -->' method=post> <select name="frameworkcode"> <option value="">Default</option> <!-- TMPL_LOOP name="frameworkloop" --> <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="frameworktext" --></option> <!-- /TMPL_LOOP --> </select> <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->"> <input type="submit" value="OK" class="button"> </form>

getframeworkinfo

  $frameworkinfo = &getframeworkinfo($frameworkcode);

Returns information about an frameworkcode.

getitemtypeinfo

  $itemtype = &getitemtype($itemtype);

Returns information about an itemtype.

GetPrinters

  $printers = &GetPrinters();
  @queues = keys %$printers;

Returns information about existing printer queues.

$printers is a reference-to-hash whose keys are the print queues defined in the printers table of the Koha database. The values are references-to-hash, whose keys are the fields in the printers table.

GetPrinter

$printer = GetPrinter( $query, $printers );

getnbpages

Returns the number of pages to display in a pagination bar, given the number of items and the number of items per page.

getallthemes
  (@themes) = &getallthemes('opac');
  (@themes) = &getallthemes('intranet');

Returns an array of all available themes.

get_infos_of

Return a href where a key is associated to a href. You give a query, the name of the key among the fields returned by the query. If you also give as third argument the name of the value, the function returns a href of scalar.

  my $query = '
SELECT itemnumber,
       notforloan,
       barcode
  FROM items
';

  # generic href of any information on the item, href of href.
  my $iteminfos_of = get_infos_of($query, 'itemnumber');
  print $iteminfos_of->{$itemnumber}{barcode};

  # specific information, href of scalar
  my $barcode_of_item = get_infos_of($query, 'itemnumber', 'barcode');
  print $barcode_of_item->{$itemnumber};

get_notforloan_label_of

  my $notforloan_label_of = get_notforloan_label_of();

Each authorised value of notforloan (information available in items and itemtypes) is link to a single label.

Returns a href where keys are authorised values and values are corresponding labels.

  foreach my $authorised_value (keys %{$notforloan_label_of}) {
    printf(
        "authorised_value: %s => %s\n",
        $authorised_value,
        $notforloan_label_of->{$authorised_value}
    );
  }

GetAuthValCode

$authvalcode = GetAuthValCode($kohafield,$frameworkcode);

GetAuthorisedValues

$authvalues = GetAuthorisedValues($category);

this function get all authorised values from 'authosied_value' table into a reference to array which each value containt an hashref.

Set $category on input args if you want to limits your query to this one. This params is not mandatory.

GetKohaAuthorisedValues

        Takes $dbh , $kohafield as parameters.
        returns hashref of authvalCode => liblibrarian
        or undef if no authvals defined for kohafield.

GetManagedTagSubfields

$res = GetManagedTagSubfields();

Returns a reference to a big hash of hash, with the Marc structure fro the given frameworkcode

NOTE: This function is used only by the (incomplete) bulk editing feature. Since that feature currently does not deal with items and biblioitems changes correctly, those tags are specifically excluded from the list prepared by this function.

For future reference, if a bulk item editing feature is implemented at some point, it needs some design thought -- for example, circulation status fields should not be changed willy-nilly.

AUTHOR

Koha Team

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 77:

You forgot a '=back' before '=head2'

Around line 515:

'=item' outside of any '=over'

Around line 656:

You forgot a '=back' before '=head2'

<<