Edit Custom Reports | Best Book Buddies
  1. Koha ManualKoha Manual
  2. Reports
  3. How to manage custom reports?

Reports

How to manage custom reports?

Koha's data is stored in a MySQL database which means that librarians can generate nearly any report they would like by either using the Guided Reports Wizard or writing their own SQL query.

In addition to the report wizard, you have the option to write your own queries using SQL. To find reports written by other Koha users, visit the Koha Wiki: http://wiki.koha-community.org/wiki/SQL_Reports_Library. You can also find your database structure in /installer/data/mysql/kohastructure.sql or online at: http://schema.koha-community.org.

To add your query, click the link to 'Create from SQL' on the main reports module or the 'New report' button at the top of the 'Saved reports' page.

newsql

Fill in the form presented

reportfromsql
  • The 'Name' is what will appear on the Saved Reports page to help you identify the report later. It will also be searchable using the filters found the left of the Saved Reports page.

  • You can use the 'Report group' to organize your reports so that you can easily filter reports by groups. Report groups are set in the REPORT_GROUP authorized value category or can be added on the fly when creating the report by choosing the 'or create' radio button.

    reportgroup

      Note

      If you're adding a report group on the fly, remember that you code should be fewer than 10 characters and should not include special characters or spaces.

  • You can use 'Report subgroup' to further organize your reports so that you can easily filter reports by groups and subgroups. Report subgroups are set in the REPORT_SUBGROUP authorized value category or can be added on the fly when creating the report by choosing the 'or create' radio button.

    reportsubgroup

      Note

      If you're adding a report subgroup on the fly, remember that you code should be fewer than 10 characters and should not include special characters or spaces.

  • 'Report is public' should be left to the default of 'No' in most cases. A report can be made public if you intend to allow access to it through the JSON webservice interface. This is a system that can be used by developers to make custom presentations of the data from the report, for example displaying it using a graphing API. To learn more speak to your local developer.

    • A public report is accessible via a URL that looks like this: http://MYOPAC/cgi-bin/koha/svc/report?id=REPORTID

  • 'Notes' will also appear on the Saved Reports page, this can be used to provide more details about the report or tips on how to enter values when it runs

  • The type should always be 'Tabular' at this time since the other formats have not been implemented

  • In the 'SQL' box you will type or paste the SQL for the report

  • If you feel that your report might be too resource intensive you might want to consider using runtime parameters to your query. Runtime parameters basically make a filter appear before the report is run to save your system resources.

    There is a specific syntax that Koha will understand as 'ask for values when running the report'. The syntax is <<Question to ask|authorized_value>>.

    • The << and >> are just delimiters. You must put << at the beginning and >> at the end of your parameter

    • The 'Question to ask' will be displayed on the left of the string to enter.

    • The authorized_value can be omitted if not applicable. If it contains an authorized value category, or branches or itemtype or categorycode or biblio_framework, a list with the Koha authorized values will be displayed instead of a free field Note that you can have more than one parameter in a given SQL Note that entering nothing at run time won't probably work as you expect. It will be considered as "value empty" not as "ignore this parameter". For example entering nothing for : "title=<<Enter title>>" will display results with title='' (no title). If you want to have to have something not mandatory, use "title like <<Enter title>>" and enter a % at run time instead of nothing

    Examples:

    • SELECT surname,firstname FROM borrowers WHERE branchcode=<<Enter patrons library|branches>> AND surname like <<Enter filter for patron surname (% if none)>>

    • SELECT * FROM items WHERE homebranch = <<Pick your branch|branches>> and barcode like <<Partial barcode value here>>

    • SELECT title , author FROM biblio WHERE frameworkcode=<<Enter the frameworkcode|biblio_framework>>

Note

To generate a date picker calendar to the right of the field when running a report you can use the 'date' keyword like this: <<Enter Date|date>>

datepicker
Note

You have to put "%" in a text box to 'leave it blank'. Otherwise, it literally looks for "" (empty string) as the value for the field.

Important

In addition to using any authorized value code to generate a dropdown, you can use the following values as well: Framework codes (biblio_framework), Branches (branches), Item Types (itemtypes) and Patron Categories (categorycode). For example a branch pull down would be generated like this <<Branch|branches>>

branchpulldown
Note

There is a limit of 10,000 records put on SQL statements entered in Koha. To get around this you want to add 'LIMIT 100000' to the end of your SQL statement (or any other number above 10,000).

Note

If your system administrator has set up memcache on your server you might see one more option for the Cache expiry. This is related to your public reports. If you make the report public then it's constantly running and will cause a large load on your system. Setting this value prevents that.

cacheexpiry

Once everything is entered click the 'Save Report' button and you'll be presented with options to run it. Once a report is saved you do not have to recreate it you can simply find it on the Saved Reports page and run or edit it.

"You are seeing this manual, thanks to Koha Community"