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"); // prepare statemet if ($ccid != '0') { $_stm = $_dbc->prepare("SELECT id, img, ccode, identity, summary, operator, `timestamp` FROM items WHERE ccode = ?"); $_stm->bind_param("s", $ccid); } else { $_stm = $_dbc->prepare("SELECT id, img, ccode, identity, summary, operator, `timestamp` FROM items"); } $_stm->execute(); // execute query $_stm->store_result(); // store result if ($_stm->num_rows) { $_stm->bind_result($id, $imgfile, $ccode, $idnt, $sum, $opr, $tm); // bind result variables while ($_stm->fetch()) { $it_id = explode('.', $idnt); $items[] = array( 'id' => $id, 'ccode' => $ccode, 'img' => ( (strlen($imgfile) > 9) ? ("/". UPLOAD_DIR . intdiv($id,FOLDER_CPC) ."/pi". $imgfile) : "" ), 'identity' => $idnt, 'itemid' => end($it_id), 'totalitems' => $totals[$ccode], 'summary' => $sum, 'operator' => $opr, 'timestamp' => local_dt($tm) ); } } $_stm->close(); // close statement $_dbc->close(); // close connection } // 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) ?>