--- /dev/null
+ <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+ <title>Koha › Tools › Patron Cards › Manage Patron Card Elements</title>
+ <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+ <!-- TMPL_INCLUDE NAME="greybox.inc" -->
+ <script type="text/javascript">
+ //<![CDATA[
+ function DeleteConfirm() {
+ var element_id = selected_layout("delete");
+ if (element_id>-1) {
+ var msg = "Are you sure you want to delete <!-- TMPL_VAR NAME="card_element" --> " + element_id + "?"
+ var answer = confirm(msg);
+ if (answer) {
+ window.location = "/cgi-bin/koha/patroncards/manage.pl?op=delete&card_element=<!-- TMPL_VAR NAME="card_element" -->&element_id=" + element_id;
+ }
+ else {
+ return; // abort delete
+ }
+ }
+ else {
+ return; // no layout selected
+ };
+ };
+ function Edit() {
+ var element_id = selected_layout("edit");
+ if (element_id>-1) {
+ window.location = "/cgi-bin/koha/patroncards/edit-<!-- TMPL_VAR NAME="card_element" -->.pl?op=edit&element_id=" + element_id;
+ }
+ else {
+ return; // no layout selected
+ };
+ };
+ function Xport() {
+ batches= new Array;
+ if(document.layouts.action.length > 0) {
+ for (var i=0; i < document.layouts.action.length; i++) {
+ if (document.layouts.action[i].checked) {
+ batches.push("batch_id=" + document.layouts.action[i].value);
+ }
+ }
+ if (batches.length < 1) {
+ alert("Please select at least one batch to export.");
+ return; // no batch selected
+ }
+ getstr = batches.join("&");
+ }
+ else if (document.layouts.action.checked) {
+ getstr = "batch_id="+document.layouts.action.value;
+ }
+ else {
+ alert("Please select at least one batch to export.");
+ return; // no batch selected
+ }
+ return GB_showCenter('Export Patron Cards', "/cgi-bin/koha/patroncards/print.pl?" + getstr, 700, 800);
+ };
+ function selected_layout(op) {
+ var selected = new Array;
+ if (document.layouts.action.length) {
+ for (i=0;i<document.layouts.action.length;i++){
+ if (document.layouts.action[i].checked){
+ selected.push(i);
+ }
+ };
+ if (selected.length == 1) {
+ return(document.layouts.action[selected[0]].value);
+ }
+ else {
+ alert("Please select only one <!-- TMPL_VAR NAME="card_element" --> to " + op + ".");
+ return (-1);
+ }
+ }
+ else {
+ if (document.layouts.action.checked){
+ return(document.layouts.action.value);
+ }
+ };
+ alert("Please select a <!-- TMPL_VAR NAME="card_element" -->.");
+ return (-1);
+ };
+ //]]>
+ </script>
+ <script type="text/javascript">
+ //<![CDATA[
+ $(document).ready(function() {
+ $("#edit").empty();
+ $("#delete").empty();
+ <!-- TMPL_IF NAME="print" -->
+ $("#xport").empty();
+ <!-- /TMPL_IF -->
+ buildButtons();
+ });
+
+ function buildButtons() {
+ var editButton = new YAHOO.widget.Button({
+ type: "link",
+ onclick: {fn: Edit},
+ label: _("Edit"),
+ id: "edit",
+ container: "edit"
+ });
+ var deleteButton = new YAHOO.widget.Button({
+ type: "link",
+ onclick: {fn: DeleteConfirm},
+ label: _("Delete"),
+ id: "delete",
+ container: "delete",
+ });
+ <!-- TMPL_IF NAME="print" -->
+ var xportButton = new YAHOO.widget.Button({
+ type: "link",
+ onclick: {fn: Xport},
+ label: _("Export"),
+ id: "xport",
+ container: "xport",
+ });
+ <!-- /TMPL_IF -->
+ };
+ </script>
+</head>
+<body>
+ <!-- TMPL_INCLUDE NAME="header.inc" -->
+ <!-- TMPL_INCLUDE NAME="cat-search.inc" -->
+ <div id="breadcrumbs">
+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
+ <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> ›
+ <a href="/cgi-bin/koha/patroncards/home.pl">Patroncards Home</a> ›
+ Manage Card <!-- TMPL_VAR NAME="card_element_title" -->
+ </div>
+ <div id="doc3" class="yui-t2">
+ <div id="bd">
+ <div id="yui-main">
+ <div class="yui-b">
+ <!-- TMPL_INCLUDE NAME="patroncards-toolbar.inc" -->
+ <!-- TMPL_INCLUDE NAME="error-messages.inc" -->
+ <div class="yui-gc">
+ <div class="yui-u first" id="manage-patroncards-layouts">
+ <div class="hint">Current Branch: <!-- TMPL_VAR NAME="LoginBranchname" --></div>
+ <!-- TMPL_IF NAME="table_loop" -->
+ <form name="layouts" action="/cgi-bin/koha/manage.pl?card_element=<!-- TMPL_VAR NAME="card_element" -->">
+ <h2>Currently Available <!-- TMPL_VAR NAME="card_element_title" --></h2>
+ <table>
+ <!-- TMPL_LOOP NAME="table_loop" -->
+ <!-- TMPL_IF NAME="header_fields" -->
+ <tr>
+ <!-- TMPL_LOOP NAME="header_fields" -->
+ <th><!-- TMPL_VAR NAME="field_label" --></th>
+ <!-- /TMPL_LOOP -->
+ </tr>
+ <!-- TMPL_ELSE -->
+ <tr>
+ <!-- TMPL_LOOP NAME="text_fields" -->
+ <!-- TMPL_IF NAME="select_field" -->
+ <td align="center"><input type="checkbox" name="action" value="<!-- TMPL_VAR NAME="field_value" -->" /></td>
+ <!-- TMPL_ELSIF NAME="field_value" -->
+ <td><!-- TMPL_VAR NAME="field_value" --></td>
+ <!-- TMPL_ELSE -->
+ <td> </td>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ </tr>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ </table>
+ <fieldset class="action">
+ <span id="edit"><input type="button" id="edit" onclick="Edit()" value="Edit" /></span>
+ <span id="delete"><input type="button" id="delete" onclick="DeleteConfirm()" value="Delete" /></span>
+ <!-- TMPL_IF NAME="print" --><span id="xport"><input type="button" id="print" onclick="Xport()" value="Export" /></span><!-- /TMPL_IF -->
+ </fieldset>
+ </form>
+ <!-- TMPL_ELSE -->
+ <div class="dialog message">
+ <h4>There Are No <!-- TMPL_VAR NAME="card_element_title" --> Currently Available.</h4>
+ <p>Use the toolbar above to create a new <!-- TMPL_VAR NAME="card_element" -->.</p></div>
+ <!-- /TMPL_IF -->
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="yui-b">
+ <!-- TMPL_INCLUDE NAME="patroncards-menu.inc" -->
+ </div>
+ </div>
+ <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
--- /dev/null
+#!/usr/bin/perl
+#
+# Copyright 2006 Katipo Communications.
+# Parts Copyright 2009 Foundations Bible College.
+#
+# 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.
+#
+# 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.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use warnings;
+use vars qw($debug);
+
+use CGI;
+use autouse 'Data::Dumper' => qw(Dumper);
+
+use C4::Auth qw(get_template_and_user);
+use C4::Output qw(output_html_with_http_headers);
+use autouse 'C4::Branch' => qw(get_branch_code_from_name);
+use C4::Creators::Lib 1.000000 qw(get_all_templates get_all_layouts get_all_profiles get_batch_summary html_table);
+use C4::Patroncards::Layout 1.000000;
+use C4::Patroncards::Template 1.000000;
+use C4::Patroncards::Profile 1.000000;
+use C4::Labels::Batch 1.000000;
+
+my $cgi = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "patroncards/manage.tmpl",
+ query => $cgi,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { catalogue => 1 },
+ debug => 1,
+ }
+);
+
+my $op = $cgi->param('op') || 'none';
+my $card_element = $cgi->param('card_element') || 'template'; # default to template managment
+my $element_id = $cgi->param('element_id') || 0; # there should never be an element with a id of 0 so this is a safe default
+
+my $db_rows = {};
+my $display_columns = { layout => [ # db column => {col label is link?
+ {layout_id => {label => 'Layout ID', link_field => 0}},
+ {layout_name => {label => 'Layout', link_field => 0}},
+ #{layout_xml => {label => 'Layout XML', link_field => 0}},
+ {select => {label => 'Select', value => 'layout_id'}},
+ ],
+ template => [ {template_id => {label => 'Template ID', link_field => 0}},
+ {template_code => {label => 'Template Name', link_field => 0}},
+ {template_desc => {label => 'Description', link_field => 0}},
+ {select => {label => 'Select', value => 'template_id'}},
+ ],
+ profile => [ {profile_id => {label => 'Profile ID', link_field => 0}},
+ {printer_name => {label => 'Printer Name', link_field => 0}},
+ {paper_bin => {label => 'Paper Bin', link_field => 0}},
+ {_template_code => {label => 'Template Name', link_field => 0}}, # this display column does not have a corrisponding db column in the profile table, hence the underscore
+ {select => {label => 'Select', value => 'profile_id'}},
+ ],
+ batch => [ {batch_id => {label => 'Batch ID', link_field => 0}},
+ {_item_count => {label => 'Item Count', link_field => 0}},
+ {select => {label => 'Select', value => 'batch_id'}},
+ ],
+};
+
+my $errstr = ($cgi->param('error') ? $cgi->param('error') : '');
+my $branch_code = ($card_element eq 'batch' ? get_branch_code_from_name($template->param('LoginBranchname')) : '');
+
+if ($op eq 'delete') {
+ my $err = 0;
+ if ($card_element eq 'layout') {$err = C4::Patroncards::Layout::delete(layout_id => $element_id);}
+ elsif ($card_element eq 'template') {$err = C4::Patroncards::Template::delete(template_id => $element_id);}
+ elsif ($card_element eq 'profile') {$err = C4::Patroncards::Profile::delete(profile_id => $element_id);}
+ elsif ($card_element eq 'batch') {$err = C4::Labels::Batch::delete(batch_id => $element_id, branch_code => $branch_code);}
+ else {warn sprintf("Unknown card element passed in for delete operation: %s.",$card_element); $errstr = 202;}
+ print $cgi->redirect("manage.pl?card_element=$card_element" . ($err ? "&error=102" : ''));
+ exit;
+}
+elsif ($op eq 'none') {
+ if ($card_element eq 'layout') {$db_rows = get_all_layouts(table_name => 'creator_layouts', filter => 'creator=\'Patroncards\'');}
+ elsif ($card_element eq 'template') {$db_rows = get_all_templates(table_name => 'creator_templates', filter => 'creator=\'Patroncards\'');}
+ elsif ($card_element eq 'profile') {$db_rows = get_all_profiles(table_name => 'printers_profile', filter => 'creator=\'Patroncards\'');}
+ elsif ($card_element eq 'batch') {$db_rows = get_batch_summary(filter => "branch_code=\'$branch_code\' OR branch_code=\'NB\'", creator => 'Patroncards');}
+ else {warn sprintf("Unknown card element passed in: %s.",$card_element); $errstr = 202;}
+}
+else { # trap unsupported operations here
+ warn sprintf('Manage interface called an unsupported operation: %s',$op);
+ print $cgi->redirect("manage.pl?card_element=$card_element&error=201");
+ exit;
+}
+
+my $table = html_table($display_columns->{$card_element}, $db_rows);
+
+$template->param(print => 1) if ($card_element eq 'batch');
+$template->param(
+ error => ($errstr ? 1 : 0),
+ $errstr => 1,
+);
+$template->param(
+ op => $op,
+ element_id => $element_id,
+ table_loop => $table,
+ card_element => $card_element,
+ card_element_title => ($card_element eq 'layout' ? 'Layouts' :
+ $card_element eq 'template' ? 'Templates' :
+ $card_element eq 'profile' ? 'Profiles' :
+ $card_element eq 'batch' ? 'Batches' :
+ ''
+ ),
+);
+
+output_html_with_http_headers $cgi, $cookie, $template->output;