Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical...

29
Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting St. Catharine College, June 2, 2006

Transcript of Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical...

Page 1: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Web-based Voyager® reports with

Michael Stapleton, Systems LibrarianKentucky Community & Technical College System

Kentucky Voyager Users Group MeetingSt. Catharine College, June 2, 2006

Page 2: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 2

What's it all about?

• A Web application for Voyager reports• Why?• What?• How?• Examples• Advanced topics (a brief intro)• Further inquiry• Questions

Page 3: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 3

Climb every mountain…

• The dream: Libraries create and run their own reports

• Endeavor’s reporting solution– MS Access, with “canned” reports– ODBC (Open Database Connectivity) link to

Voyager– Detailed information about the Voyager table

structure and relationships

Page 4: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 4

Ford every stream…

• Efforts to facilitate local reporting– Training and workshops– Support for installing Oracle client (ODBC

drivers)– Assistance to local report developers

Page 5: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 5

Hey, batter!

• Can you hit a learning curve?– Strike one: MS Access

• Amazon.com says, “Microsoft Access has the steepest learning curve of all the Microsoft Office applications.1”

– Strike two: The Oracle client / “ODBC drivers”– Strike three: Class diagrams

• List of Voyager tables, their contents, and how they are related

• Formerly known as Entity Relationship diagrams. “E.R.” Wonder why they changed the name?

Page 6: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 6

It’s a hard-knock life…

• Reality sets in– Like I’ve got all this spare time– Isn’t that what Paul and Michael are for?

• Result– Little utilization of Voyager information

• Collection development• Record maintenance• Inventory• Patrons• Fine/fee

Page 7: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 7

That toolkit is our only hope…

• No, there is another…

• Voyager reports with PHP– Server-based Web application– Eliminates desktop support– Users select from a list of reports– Built-in customizable query criteria– Users can concentrate on the data, not the

process

Page 8: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 8

Building blocks…

• Web server ( Apache / IIS )

• PHP

• Oracle client

Web serverPHP

Oracle client

Oracle (Voyager tables)

Page 9: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 9

Tamagotchi?

Web server

Reporting application

• PHP scripts

• SQL queries

• HTML forms for selectable report criteria

• Style sheets and formatting for Excel

Oracle client SSH server

SSL digital certificate

libsys.kctcs.edu

encrypted

Active directory login to secure website

Voyager data (Oracle)

westlib.kyvl.org

PHP

encryption by Aug '06, pending vendor support

Report results sent to Web browser or MS Excel spreadsheet (user's choice)

Page 10: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 10

Web server

• Apache or Internet Information Server?– Both support PHP– Both are reasonably secure– Apache is much easier to configure for PHP– IIS is much easier to configure for authorized

logins

Page 11: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 11

• What is it?– A web-friendly scripting language

• How much does it cost?– Free

• Is it hard to learn?– Not if you have a good book, an interest in

learning something new, and a knack for standing on the shoulders of giants

Page 12: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 12

Oracle client

• Enabling software for connecting to a database

• Oracle 9i client

• Oracle Instant Client

Page 13: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 13

Synergy

• The whole…– “Zend Core for Oracle”

• …is greater than the sum of the parts– PHP– Oracle Instant Client– Zend Optimizer

• More stable and somewhat faster than PHP and Instant Client installed separately

Page 14: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 14

A simple example…• Connect to Oracle

• Run a query

• Return the output in some format– HTML– Excel– Other (CSV or other delimited)

• Close the connection

Page 15: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 15

Knee bone connected to…

• Step 1

// Create a connection identifier for Oracle.

$conn = @oci_connect( "user", "password", "//westlib.kyvl.org/VGER");

Page 16: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 16

Query me this…

• Step 2

// Define a query, and assign it to a variable

$query = " SELECT location_code, location_name, location_display_name AS \"OPAC Display Name\", suppress_in_opac AS \"OPAC suppress?\", mfhd_count FROM kctcsdb.location WHERE (location_code like '$_POST[location]%') OR location_display_name like '$_POST[location]%'ORDER BY location_code";

Page 17: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 17

Mumbo-jumbo…

• Step 3

// Begin the magic incantations...

// Prepare $query for execution using $conn, and assign the resulting statement identifier to a variable...

$stmt = oci_parse($conn, $query);

// Execute the Oracle statement...oci_execute($stmt);

Page 18: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 18

Row, row, row…

• Step 4$nrows = oci_fetch_all($stmt, $results);if ($nrows > 0) { echo "<table>\n"; echo "<p><strong>$nrows records matched...</strong>\n<br />"; echo "<tr>\n"; while (list($key, $val) = each($results)) { // Show the field names echo "<th>$key</th>\n"; } echo "</tr>\n"; for ($i = 0; $i < $nrows; $i++) { // Display the query results... reset($results); echo "<tr>\n"; while ($column = each($results)) { $data = $column['value']; echo "<td>$data[$i]</td>\n"; } echo "</tr>\n"; } echo "</table>\n";} else { echo "No data found<br />\n";}

Page 19: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 19

Quitting gracefully…

• Step 5

// Free all resources associated with the query statement...

oci_free_statement($stmt);

// Close the Oracle connection...

oci_close($conn);

Page 20: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 20

Sorry, I didn't get that…

• Example script

• Demo

Page 21: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 21

Selectable criteria…

• Interactive query criteria: PHP + HTML form<form action="MFHD_count_by_location_sql.php" method="post"> <select name="location" size="2"> <option value="A">Ashland</option> <option value="PR">Big Sandy</option> <option value="BL">Bluegrass</option> </select></form>

---------------------------------------------------------------

<php?> // MFHD_count_by_location_sql.php accepts variables from HTML form $query = "

... WHERE (location_code like '$_POST[location]%') OR location_display_name like '$_POST[location]%' ";</php>

Page 22: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 22

Criteria as "handoff"…

This HTML form value... <select name="location"> <option value="Ashland">Ashland</option>...is passed to this variable in the PHP script... '$_POST[location]'...and interpreted by PHP as... 'Ashland'

Page 23: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 23

• External and internal– Cascading style sheets (CSS)– "Include" files

Page 24: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 24

Dumping to a file…

• Other output formats– Excel– Delimited

• CSV (Comma separated values)

– Raw MARC

Page 25: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 25

Security, Part 1

• Browser-to-Web server: SSL

Web server / PHPSecure Sockets Layer

(SSL)

encrypted

Page 26: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 26

• Web server-to-Oracle: SSH

Web server / PHPSSH server

encrypted

Oracle (Voyager tables)

Security, Part 2

Voyager serverSSH server

Page 27: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 27

Further investigation…• CSS formatting for printing Web pages

– "Zebra stripe" tables?– Borders around table data?

• Progress indicator

• Advanced queries– Inventory: pass barcodes to an Oracle table?

• Criteria selectors

• Scheduled jobs and auto-posting results

Page 28: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 28

Free stuff…

• PHP functions used in this presentation– http://us2.php.net/manual/en/– oci_connect(), oci_parse(), oci_execute(), oci_fetch_all(), oci_free_statement(), oci_close()

• Zend Core for Oracle– http://www.zend.com/products/zend_core/zend_core_for_oracle/

• Apache Web server– http://httpd.apache.org/

Page 29: Web-based Voyager® reports with Michael Stapleton, Systems Librarian Kentucky Community & Technical College System Kentucky Voyager Users Group Meeting.

Michael Stapleton, KCTCS - KVUG 2006 29

Wrapping up…

• Questions?

Thank you!

• Contact info and example scripts

[email protected]://libsys.kctcs.edu/stapleton/kvug2006/