ccode [ certain id: ##.## --or-- 0 = any id ] //////////////////////////////////////////////////////////////////////////////// $doSearch = false; // shall not do a search (if no search arguments passes) $totals = get_totals(); // get totals of categories if ((isset($_GET['id'])) && (mb_strlen($_GET['id']) < 6)) { $ccid = $_GET['id']; // category id passed $doSearch = true; } // get records // ----------------------------------------------------------------------------- if ($doSearch) { $items = array(); // init database connection $_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"); if ($ccid != '0') { $_stm = $_dbc->prepare("SELECT id, img, img2, ccode, identity, summary, operator, `timestamp`, record FROM items WHERE ccode = ?"); $_stm->bind_param("s", $ccid); } else { $_stm = $_dbc->prepare("SELECT id, img, img2, ccode, identity, summary, operator, `timestamp`, record FROM items"); } $_stm->execute(); // execute query $_stm->store_result(); // store result if ($_stm->num_rows) { $_stm->bind_result($id, $imgfile, $imgfile2, $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,FOLDER_CPC) ."/". $imgfile) : "" ); $record['img2'] = ( (strlen($imgfile2) > 9) ? ("/". UPLOAD_DIR . intdiv($id,FOLDER_CPC) ."/". $imgfile2) : "" ); $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); /* // unserialize main record to variable $record = unserialize($serREC); $it_id = explode('.', $idnt); // calculate record $record['id'] = $id; $record['identity'] = $idnt; $record['operator'] = $opr; $record['itemid'] = end($it_id); $record['totalitems'] = $totals[$ccode]; date_default_timezone_set('Europe/Athens'); setlocale(LC_ALL, 'el_GR.UTF-8', 'grc'); $record['timestamp'] = local_dt($tm); $record['img'] = ( (strlen($imgfile) > 9) ? ("/". UPLOAD_DIR . intdiv($id,FOLDER_CPC) ."/". $imgfile) : "" ); $record['img2'] = ( (strlen($imgfile2) > 9) ? ("/". UPLOAD_DIR . intdiv($id,FOLDER_CPC) ."/". $imgfile2) : "" ); $items[] = array( 'id' => $id, 'ccode' => $ccode, 'summary' => $sum, 'record' => $record, ); */ } } $_stm->close(); // close statement $_dbc->close(); // close connection // 03. Prepare PDF to print ---------------------------------------------------- // include printing php script //////////////////////////////////////////////////////////////////////////////// define("PRINT_MODE", 'book'); define("RENDER_COVER", true ); define("RENDER_HF", true); // render header + footer $formARRAY = json_decode(FORMJSON); include("do-pdf.php"); } // Script Workflow: // --------------------------------------------------------------------------- // 1. read fields options // 2. generate HTML // 3. generate JS needed // the UI // --------------------------------------------------------------------------- // Fields are grouped in sections // These sections presented in tabs (or accordion if mobile device) // Two (2) sections incduded to inform the user of empty fields or errors // Libraries and FrameWorks used // --------------------------------------------------------------------------- // Bootstrap 4.3 is used for easy responsive HTML code // JQuery 3.3 is used to handle user interation // Select2 is used to make select-boxes (single or multiple) easier to use // read fields options (json format) ///////////////////////////////////////// // --------------------------------------------------------------------------- // --- depricated: $formJSON = file_get_contents('config/kallassa.json'); // --- $formJSON has been readed already on functions.php and being a global constant $formARRAY = json_decode(FORMJSON); // Init strigns for JS generator (needed to handle everything) /////////////// // --------------------------------------------------------------------------- $checkFilledJS = ""; // JS for checking empty fields $ref2Select2JS = ""; // references to Select2-controls Javascript $initSelectsJS = ""; // js to initialize select fields (single or multiple) ?>