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");