'/', 'msg' => ERR_NEED_ID); // include ("includes/show-error.php"); } // 01. GET DATA NEEDED --------------------------------------------------------- // * Load Parametres, Session and Functions; // * Check User Permitions // * Check Script Call //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // get totals of categories // --------------------------------------------------------------------------- $totals = get_totals(); // read fields options (json format) // --------------------------------------------------------------------------- $formARRAY = json_decode(FORMJSON); // get item record // --------------------------------------------------------------------------- // 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 $_stm = $_dbc->prepare("SELECT identity, operator, `timestamp`, record FROM items WHERE id = ?"); $_stm->bind_param("d", $item_id); // bind values $_stm->execute(); // execute query $_stm->store_result(); // store result if ($_stm->num_rows) { $_stm->bind_result($idnt, $opr, $tm, $serREC); // bind result variables $_stm->fetch(); // fetch FIRST record values // unserialize main record to variable $record = unserialize($serREC); // edit record $record['id'] = $item_id; $record['identity'] = $idnt; $record['operator'] = $opr; $record['itemid'] = end(explode('.', $idnt)); $record['totalitems'] = $totals[$record['ccode']]; date_default_timezone_set('Europe/Athens'); setlocale(LC_ALL, 'el_GR.UTF-8', 'grc'); $record['timestamp'] = local_dt($tm); } else { return array('success' => false, 'data' => "No items found"); // return error(s) } $_stm->close(); // close statement $_dbc->close(); // close connection // 02. RENDER HTML and DATA ---------------------------------------------------- // * Draw fileds from Json Array per section // * Prepare JS needed // * Put data from Record // * Generate JS (prepared + static) // --- // Script is based on on ui-new-item.php // More information about the script workflow can be found there. //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // 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) // --- depricated (added static into js) : $addJSreadonly = ""; // js to add readonly fields and their values to port-object ?> <?=PROJECT?> : Επεξεργασία Εγγραφής <?=$idnt?>

Επεξεργασία Εγγραφής

$section) : ?> >
childs as $kk => $field) : ?> atr); // attributes array $ak = in_array('append-key', $atrs) ? true : false; // append key (for selects) $rq = in_array('required', $atrs) ? 'required' : ''; // required $class = (isset($field->len)) ? ' col-md-'.$field->len : 'col-md-12'; // column class (for width) ?>
typ) { case 'select': // exclude CCODE from default select behaviour // because CCODE SHALL NOT CHANGE if ($field->nam == 'ccode') { $fdata = parse_any($field->nam, $record['ccode']); // parse field + current value $txt = $fdata['multi'] ? implode(", ", $fdata['value']) : $fdata['value']; // if array of values, implode values echo ''; $checkFilledJS .= " values.ccode = '". $record['ccode'] ."'; "; } else { // if MULTIPLE select // ( deferantiate class for multi or single this will allow the { allowClear: true } option ) // ( see: https://select2.org/placeholders ) if (in_array('multiple', $atrs)) { // MULTIPLE control: set name and multiple attribute $name_n_multi = 'name="'. $field->nam .'[]" multiple="multiple">'; // prepare initialization of select2 (multiple) $initSelectsJS .= " var ". $field->nam ." = $('#". $field->nam ."'); ". $field->nam .".select2({ width: '100%' }); "; // depricated: ". $field->nam .".select2({ placeholder: '". $field->lab ."', width: '100%' }); // and set init value if ($record[$field->nam] !="") { $initSelectsJS .= " ". $field->nam .".val( ['". str_replace(",", "','", $record[$field->nam]) ."'] ); ". $field->nam .".trigger('change'); "; } // prepare check if empty field $checkFilledJS .= " if (getValues(".$field->nam.") =='') { empty += '". $section->label .": ". $field->lab . (($rq == '') ? "" : " **") ."
'; ". (($rq == '') ? "" : "needit.push('". $section->label .":". $field->lab ."');") ." } values.". $field->nam ." = getValues(".$field->nam."); "; } else { // is SINGLE control: only name needed $name_n_multi = 'name="'. $field->nam .'"'; // prepare initialization of select2 (single) $initSelectsJS .= " var ". $field->nam ." = $('#". $field->nam ."'); ". $field->nam .".select2({ placeholder: ' ', allowClear: true }); "; // depricated: ". $field->nam .".select2({ placeholder: '". $field->lab ."', allowClear: true }); // and set init value if ($record[$field->nam] !="") { $initSelectsJS .= " ". $field->nam .".val( ['". str_replace(",", "','", $record[$field->nam]) ."'] ); ". $field->nam .".trigger('change'); "; } // prepare check if empty field $checkFilledJS .= " if (getValues(".$field->nam.") =='') { empty += '". $section->label .": ". $field->lab . (($rq == '') ? "" : " **") ."
'; ". (($rq == '') ? "" : "needit.push('". $section->label .":". $field->lab ."');") ." } values.". $field->nam ." = getValues(".$field->nam."); "; } ?> nam ."]').val() =='') { empty += '". $section->label .": ". $field->lab . (($rq == '') ? "" : " **") ."
'; ". (($rq == '') ? "" : "needit.push('". $section->label .":". $field->lab ."');") ." } values.". $field->nam ." = $('input[name=". $field->nam ."]').val(); "; ?> > nam ."]').val() =='') { empty += '". $section->label .": ". $field->lab . (($rq == '') ? "" : " **") ."
'; ". (($rq == '') ? "" : "needit.push('". $section->label .":". $field->lab ."');") ." } values.". $field->nam ." = $('input[name=". $field->nam ."]').val(); "; ?> > nam ."]').val() =='') { empty += '". $section->label .": ". $field->lab . (($rq == '') ? "" : " **") ."
'; ". (($rq == '') ? "" : "needit.push('". $section->label .":". $field->lab ."');") ." } values.". $field->nam ." = $('input[name=". $field->nam ."]').val(); "; ?> > nam ."]').val() =='') { empty += '". $section->label .": ". $field->lab . (($rq == '') ? "" : " **") ."
'; ". (($rq == '') ? "" : "needit.push('". $section->label .":". $field->lab ."');") ." } values.". $field->nam ." = $('textarea[name=". $field->nam ."]').val(); "; ?> nam?> (lab?>) : UNKNOWN TYPE

Δεν έχουν συμπληρωθεί:

nam, $record['note']); // parse field + current value $txt = $fdata['value']; // if array of values, implode values ?> Γενικά:Συμπληρωματική Πληροφορία
'; } values.note = $('textarea[name=note]').val(); "; ?>