Skip to content

Instantly share code, notes, and snippets.

@fraktik
Created August 27, 2019 09:58
Show Gist options
  • Save fraktik/918781d46bdeadac116bc3d927737a79 to your computer and use it in GitHub Desktop.
Save fraktik/918781d46bdeadac116bc3d927737a79 to your computer and use it in GitHub Desktop.
ýměnný soubor - SQL Report (třeba odkazovat v IntranetUserJS) - tisk sestavy v KOHA
if (!window.location.getParameter ) {
window.location.getParameter = function(key) {
function parseParams() {
var params = {},
e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1);
while (e = r.exec(q))
params[d(e[1])] = d(e[2]);
return params;
}
if (!this.queryStringParams)
this.queryStringParams = parseParams();
return this.queryStringParams[key];
};
}
$(document).ready(function() {
$("#rep_guided_reports_start table").append("<thead></thead>");
$("#rep_guided_reports_start table thead").append($("#rep_guided_reports_start table tbody tr:nth-child(1)"));
/* ........... */
collectionId = window.location.getParameter("colId");
if (typeof collectionId != 'undefined') {
$('<div class="btn-group"><a id="printrcoll" class="btn btn-sm btn-default" href="/cgi-bin/koha/reports/guided_reports.pl?phase=Run+this+report&reports=3&limit=200&sql_params=' + collectionId + '"><i class="fa fa-print"></i> Vytisknout</a></div>').insertAfter("#rcoll_addItems div[class='btn-group']:nth-child(2)");
}
function indicators_generate() {
for (field in indicators) {
for(ind in indicators[field]) {
$("input[name^='tag_" + field + "_indicator" + ind + "']").each(function () {
$(this).autocomplete({
minLength: 0,
source: indicators[field][ind]
});
$(this).focus(function () {
$(this).autocomplete("search","");
});
$(this).click(function () {
$(this).autocomplete("search","");
});
$(this).css("background-color","#FFFF44");
});
}
}
}
indicators_generate();
$(".buttonPlus").click(indicators_generate);
});
SELECT "<script>window.print();</script><h4><i>Knihovna:</i></h4>"AS "Prirustkove cislo", CONCAT_WS("", "<h4>", b.branchname, "</h4>") AS "Signatura","<h4><i>Soubor:</i></h4>" AS "Autor", CONCAT_WS("", "<h4>", c.colTitle, "</h4>") AS "Nazev", "" AS "Cena"
FROM collections c
JOIN branches b ON c.colBranchcode = b.branchcode
JOIN (SELECT @IdSouboru:=<<Id souboru>>) var
WHERE c.colId = @IdSouboru
UNION
SELECT "", "", "", "<h4>Naučná pro dospělé:</h4>", ""
UNION
SELECT i.stocknumber AS "Prirustkove cislo", i.itemcallnumber AS "Signatura", b.author AS "Autor", b.title AS "Nazev", i.price AS "Cena"
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode = "5"
UNION
SELECT "<i>Počet za tématiku:", CONCAT_WS("", "<b>",COUNT(*), "</b>"), "", "<i>Cena za tématiku:</i>", CONCAT_WS("", "<b>", SUM(i.price), "</b>")
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode = "5"
UNION
SELECT "", "", "", "<h4>Beletrie pro dospělé:</h4>", ""
UNION
SELECT i.stocknumber AS "Prirustkove cislo", i.itemcallnumber AS "Signatura", b.author AS "Autor", b.title AS "Nazev", i.price AS "Cena"
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode = "6"
UNION
SELECT "<i>Počet za tématiku:", CONCAT_WS("", "<b>",COUNT(*), "</b>"), "", "<i>Cena za tématiku:</i>", CONCAT_WS("", "<b>", SUM(i.price), "</b>")
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode = "6"
UNION
SELECT "", "", "", "<h4>Naučná pro mládež:</h4>", ""
UNION
SELECT i.stocknumber AS "Prirustkove cislo", i.itemcallnumber AS "Signatura", b.author AS "Autor", b.title AS "Nazev", i.price AS "Cena"
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode = "7"
UNION
SELECT "<i>Počet za tématiku:", CONCAT_WS("", "<b>",COUNT(*), "</b>"), "", "<i>Cena za tématiku:</i>", CONCAT_WS("", "<b>", SUM(i.price), "</b>")
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode = "7"
UNION
SELECT "", "", "", "<h4>Beletrie pro mládež:</h4>", ""
UNION
SELECT i.stocknumber AS "Prirustkove cislo", i.itemcallnumber AS "Signatura", b.author AS "Autor", b.title AS "Nazev", i.price AS "Cena"
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode = "8"
UNION
SELECT "<i>Počet za tématiku:", CONCAT_WS("", "<b>",COUNT(*), "</b>"), "", "<i>Cena za tématiku:</i>", CONCAT_WS("", "<b>", SUM(i.price), "</b>")
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode = "8"
UNION
SELECT "", "", "", "<h4>Bez tematiky:</h4>", ""
UNION ALL
SELECT i.barcode AS "Prirustkove cislo", i.itemcallnumber AS "Signatura", b.author AS "Autor", b.title AS "Nazev", i.price AS "Cena"
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode IS NULL
UNION
SELECT "<i>Počet za tématiku:", CONCAT_WS("", "<b>",COUNT(*), "</b>"), "", "<i>Cena za tématiku:</i>", CONCAT_WS("", "<b>", SUM(i.price), "</b>")
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru AND i.ccode IS NULL
UNION
SELECT "<i>Celkový počet:</i>", CONCAT_WS("", "<b>", COUNT(*), "</b>"), "", "<i>Celková cena:</i>", CONCAT_WS("", "<b>", SUM(i.price), "</b>")
FROM collections c
JOIN collections_tracking ct ON c.colId = ct.colId
JOIN items i ON ct.itemnumber = i.itemnumber
JOIN biblio b ON i.biblionumber = b.biblionumber
WHERE c.colId = @IdSouboru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment