2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>Koha › Tools › Quote editor</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/quotes_[% KOHA_VERSION %].css" />
6 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
9 <body id="tools_quotes" class="tools">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'cat-search.inc' %]
13 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › Quote editor</div>
15 <div id="doc3" class="yui-t2">
19 [% INCLUDE 'quotes-toolbar.inc' %]
21 <div id="instructions">
22 <fieldset id="quote_editor_help" class="rows">
23 <legend>Instructions</legend>
24 <div id="quote_editor_inst">
26 <li>Click on the 'Add quote' button to add a single quote; Press the <Enter> key to save the quote.<br />
27 <b>Note: </b>Both the 'source' and 'text' fields must have content in order for the quote to be saved.</li>
28 <li>Click on any field to edit the contents; Press the <Enter> key to save edit.</li>
29 <li>Click on one or more quote numbers to select entire quotes for deletion; Click the 'Delete quote(s)' button to delete selected quotes.</li>
30 <li>Click the 'Import quotes' button in the toolbar to import a CSV file of quotes.</li>
35 <table id="quotes_editor">
38 <th><span style="cursor: help" id="id_help">ID</span></th>
41 <th>Last displayed</th>
45 <!-- tbody content is generated by DataTables -->
49 <td>Loading data...</td>
54 <fieldset id="footer" class="action">
58 <div class="yui-b noprint">
59 [% INCLUDE 'tools-menu.inc' %]
63 [% MACRO jsinclude BLOCK %]
64 <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu_[% KOHA_VERSION %].js"></script>
65 [% INCLUDE 'datatables.inc' %]
66 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/dataTables.fnReloadAjax_[% KOHA_VERSION %].js"></script>
67 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.jeditable.mini_[% KOHA_VERSION %].js"></script>
68 <script type="text/javascript">
69 var oTable; /* oTable needs to be global */
70 var sEmptyTable = _("No quotes available. Please use the 'Add quote' button to add a quote."); /* override the default message in datatables.inc */
71 $(document).ready(function() {
72 /* NOTE: This is an ajax-source datatable and *not* a server-side sourced datatable. */
73 /* See the datatable docs if you don't understand this difference. */
74 oTable = $("#quotes_editor").dataTable({
78 "sPaginationType" : "full_numbers",
79 "sDom": '<"top pager"iflp>rt<"bottom pager"flp><"clear">',
80 "sAjaxSource" : "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
89 "sFirst": MSG_DT_FIRST,
92 "sPrevious": MSG_DT_PREVIOUS,
94 "sEmptyTable": MSG_DT_EMPTY_TABLE,
96 "sInfoEmpty": MSG_DT_INFO_EMPTY,
97 "sInfoFiltered": MSG_DT_INFO_FILTERED,
98 "sLengthMenu": MSG_DT_LENGTH_MENU,
99 "sLoadingRecords": MSG_DT_LOADING_RECORDS,
100 "sProcessing": MSG_DT_PROCESSING,
101 "sSearch": MSG_DT_SEARCH,
102 "sZeroRecords": MSG_DT_ZERO_RECORDS,
104 "fnPreDrawCallback": function(oSettings) {
107 "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
108 /* do foo on the current row and its child nodes */
109 var noEditFields = [];
110 var quoteID = $('td', nRow)[0].innerHTML;
111 $(nRow).attr("id", quoteID); /* set row ids to quote id */
112 $('td:eq(0)', nRow).click(function() {$(this.parentNode).toggleClass('selected',this.clicked);}); /* add row selectors */
113 $('td:eq(0)', nRow).attr("title", _("Click ID to select/deselect quote"));
114 $('td', nRow).attr("id",quoteID); /* FIXME: this is a bit of a hack */
115 if (isNaN(quoteID)) {
116 noEditFields = [0,1,2,3]; /* all fields when adding a quote */
118 noEditFields = [0,3]; /* id, timestamp */
120 /* apply no_edit id to noEditFields */
121 for (i=0; i<noEditFields.length; i++) {
122 $('td', nRow)[noEditFields[i]].setAttribute("id","no_edit");
126 "fnDrawCallback": function(oSettings) {
127 /* Apply the jEditable handlers to the table on all fields w/o the no_edit id */
128 $('#quotes_editor tbody td[id!="no_edit"]').editable( "/cgi-bin/koha/tools/quotes/quotes_ajax.pl", {
129 "submitdata" : function ( value, settings ) {
131 "column" : oTable.fnGetPosition( this )[2],
136 "placeholder" : "Saving data...",
140 $("#add_quote").click(function(){
144 $("#delete_quote").click(function(){
148 $("#id_help").on("click",function(e){
150 alert( _("Click on the quote's id to select or deselect the quote. Multiple quotes may be selected.") );
154 function fnClickAddQuote(e, node) {
156 /* some browsers only give charCode, so this will need to be */
157 /* fixed up to handle that */
158 console.log('charCode: '+e.charCode);
160 if (e.keyCode == 13) {
161 var quoteSource = $('#quoteSource').val();
162 var quoteText = $('#quoteText').val()
163 /* If passed a quote source, add the quote to the db */
164 if (quoteSource && quoteText) {
166 url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
169 "source" : quoteSource,
173 success: function(data){
174 var newQuote = data[0];
175 var aRow = oTable.fnUpdate(
182 oTable.fnPageChange( 'last' );
183 $('.add_quote_button').attr('onclick', 'fnClickAddRow()'); // re-enable add button
187 alert(_("Please supply both the text and source of the quote before saving."));
189 } else if (e.keyCode == 27) {
190 if (confirm(_("Are you sure you want to cancel adding this quote?"))) {
191 oTable.fnDeleteRow(node);
198 function fnClickAddRow() {
199 $('.add_quote_button').removeAttr('onclick'); // disable add button once it has been clicked
200 var aRow = oTable.fnAddData(
202 'NA', // this is hackish to fool the datatable sort routine into placing this row at the end of the list...
203 '<input id="quoteSource" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
204 '<input id="quoteText" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
205 '0000-00-00 00:00:00',
209 oTable.fnPageChange( 'last' );
210 $('#quoteSource').focus();
213 function fnClickDeleteRow() {
214 var idsToDelete = oTable.$('.selected').map(function() {
218 alert(_("Please select a quote(s) by clicking the quote id(s) you desire to delete."));
219 } else if (confirm(_("Are you sure you wish to delete quote(s) %s?").format(idsToDelete))) {
220 oTable.$('.selected').each(function(){
221 var quoteID = $(this).attr('id');
223 url: "/cgi-bin/koha/tools/quotes/quotes_ajax.pl",
229 /* Delete the row from the datatable */
231 oTable.fnDeleteRow(this);
232 oTable.fnReloadAjax(null, null, true);
243 [% INCLUDE 'intranet-bottom.inc' %]