summaryrefslogtreecommitdiff
path: root/public/xx-catalog.php
diff options
context:
space:
mode:
authorGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2026-07-12 15:51:52 +0300
committerGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2026-07-12 15:51:52 +0300
commit02608271bb2a9f3a65ed536984d306ee14b48e34 (patch)
tree3f23ec48a694ec014e845c4f70d9b5f1c065403c /public/xx-catalog.php
downloadkalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.tar.gz
kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.tar.bz2
kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.zip
initialize repository; add docker config; migrate configuration to new specsHEADmaster
Diffstat (limited to 'public/xx-catalog.php')
-rw-r--r--public/xx-catalog.php110
1 files changed, 110 insertions, 0 deletions
diff --git a/public/xx-catalog.php b/public/xx-catalog.php
new file mode 100644
index 0000000..1e62e3b
--- /dev/null
+++ b/public/xx-catalog.php
@@ -0,0 +1,110 @@
+<?php
+// 01. Initialize --------------------------------------------------------------
+// include paremetres and libraries, init timezome, init variables
+////////////////////////////////////////////////////////////////////////////////
+
+include("config/parametres.php");
+include("includes/sessions.php");
+include("includes/functions.php");
+date_default_timezone_set('Europe/Athens');
+setlocale(LC_ALL, 'el_GR.UTF-8', 'grc');
+
+$totals = get_totals(); // get totals of categories
+$formARRAY = json_decode(FORMJSON); // list of fields
+$items = array(); // items to print
+
+
+
+// 02. Parse arguments and intitialize behaviout flags -------------------------
+// CCODE -> ccode [ certain id: ##.## --or-- 0 = any id ]
+// COVER -> (yes|no) print cover-page (default: no)
+// ID -> record id
+// ---
+// Call options:
+// ? ccode=ac.1 [& cover=no] : call for category; no cover
+// ? ccode=0 & cover=yes : all items; print cover
+// ? id=123 : specific item (no cover / no header)
+////////////////////////////////////////////////////////////////////////////////
+
+if ((isset($_GET['ccode'])) && (mb_strlen($_GET['ccode']) < 6)) {
+ $ccid = $_GET['ccode']; // category id passed
+ $doSearch = true;
+ define("PRINT_MODE", 'book');
+ define("RENDER_COVER", ((isset($_GET['cover'])) && ($_GET['cover'] == 'yes')) ? true : false );
+ define("RENDER_HF", true); // render header + footer
+}
+else if ((isset($_GET['id'])) && (strlen($_GET['id']) < 5)) {
+ $iid = $_GET['id'];
+ define("PRINT_MODE", 'page');
+ define("RENDER_COVER", false); // do not include cover-page
+ define("RENDER_HF", true); // do not render header + footer
+}
+else {
+ echo "Wrong call; Nothing to print"; die();
+}
+
+
+// 03. Get data to print -------------------------------------------------------
+// init database connection, prepare SELECT, fetch data
+////////////////////////////////////////////////////////////////////////////////
+
+$_dbc = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DBMS);
+if ($_dbc->connect_errno) {
+ echo "Database connection failed; Please try in a few minutes. ";
+ if (TESTING) echo $_dbc->connect_error;
+ $_dbc->close(); die();
+}
+$_dbc->set_charset("utf8");
+
+// prepare statemet
+if (isset($iid)) {
+ $_stm = $_dbc->prepare("SELECT id, img, ccode, identity, summary, operator, `timestamp`, record FROM items WHERE id = ?");
+ $_stm->bind_param("d", $iid);
+}
+else if ($ccid != '0') {
+ $_stm = $_dbc->prepare("SELECT id, img, ccode, identity, summary, operator, `timestamp`, record FROM items WHERE ccode = ?");
+ $_stm->bind_param("s", $ccid);
+}
+else if (isset($ccid)) {
+ $_stm = $_dbc->prepare("SELECT id, img, ccode, identity, summary, operator, `timestamp`, record FROM items");
+}
+else {
+ echo "Wrong call; Nothing to print"; die();
+}
+$_stm->execute(); // execute query
+$_stm->store_result(); // store result
+
+if ($_stm->num_rows) {
+
+ $_stm->bind_result($id, $imgfile, $ccode, $idnt, $sum, $opr, $tm, $serREC); // bind result variables
+
+ while ($_stm->fetch()) {
+ $record = unserialize($serREC);
+ $it_id = explode('.', $idnt);
+
+ // calculate record
+ $record['id'] = $id;
+ $record['ccode'] = $ccode;
+ $record['img'] = ( (strlen($imgfile) > 9) ? ("/". UPLOAD_DIR . intdiv($id,500) ."/". $imgfile) : "" );
+ $record['identity'] = $idnt;
+ $record['operator'] = $opr;
+ $record['itemid'] = end($it_id);
+ $record['totalitems'] = $totals[$record['ccode']];
+ $record['timestamp'] = local_dt($tm);
+ $record['summary'] = $sum;
+
+ $items[] = $record;
+ unset($record);
+ }
+}
+
+$_stm->close(); // close statement
+$_dbc->close(); // close connection
+
+// print_r($items); die();
+
+// 03. Prepare PDF to print ----------------------------------------------------
+// include printing php script
+////////////////////////////////////////////////////////////////////////////////
+
+include("print-book.php");