/** * * * Display a record in a nice format * */ function display_record($db, $Allfields, $id, $tableinfo, $backbutton = true, $previousid = false, $nextid = false, $viewid = false) { global $PHP_SELF, $md, $USER; if (!$Allfields[1]['recordid']) { echo "<table border=0 align='center'>\n"; echo "<tr>\n<td align='center'><h3>Record not found</h3>\n</td>\n</tr>"; echo "<tr>\n<td align='center'>\n<button onclick='self.close();window.opener.focus();' name='Close' value='close'>Close</button></td></tr>\n"; echo "</table>\n"; exit; } echo " <br>\n"; echo "<table border=0 align='center'>\n"; $count = 0; echo "<tr>\n"; // if viewid is defined we will over-ride display record with values from the view settings if ($viewid) { $r = $db->Execute("SELECT columnid FROM tableviews WHERE viewnameid={$viewid} AND viewmode=2"); while ($r && !$r->EOF) { $viewlist[] = $r->fields[0]; $r->MoveNext(); } } //print_r($Allfields); foreach ($Allfields as $nowfield) { // decide whether this field will be shown unset($thisfield); // if we have a viewid, check the list if ($viewlist) { $thisfield = in_array($nowfield['columnid'], $viewlist); } else { //Only show the entry when display_record is set $thisfield = $nowfield['display_record'] === 'Y'; } if ($thisfield && is_array($nowfield)) { // explode nested table links to the current world: if (isset($nowfield['nested'])) { $nowfield['text'] = $nowfield['nested']['text']; $nowfield['values'] = $nowfield['nested']['values']; $nowfield['datatype'] = $nowfield['nested']['datatype']; $nowfield['fileids'] = $nowfield['nested']['fileids']; } // display the fields in two columns if ($count && !($count % 2)) { echo "</tr>\n<tr>\n"; } if ($nowfield['datatype'] == 'textlong') { $textlarge = nl2br(htmlentities($nowfield['values'])); echo "<th>{$nowfield['label']}</th><td colspan=2>{$textlarge}</td>\n"; } elseif ($nowfield['datatype'] == 'file' || $nowfield['datatype'] == 'image') { // if this came through a associated table: if ($nowfield['nested']['nested_tbname'] && $nowfield['nested']['nested_columnid']) { $files = get_files($db, $nowfield['nested']['nested_tbname'], $nowfield['nested']['nested_id'], $nowfield['nested']['nested_columnid'], 0, 'big'); } else { $files = get_files($db, $tableinfo->name, $id, $nowfield['columnid'], 0, 'big'); } if ($files) { echo "<th>{$nowfield['label']}:</th>\n<td colspan=5>"; for ($i = 0; $i < sizeof($files); $i++) { echo $files[$i]['link'] . " (<i>" . $files[$i]['name'] . "</i>, " . $files[$i]['type']; echo " file, " . $files[$i]['size'] . ")<br>\n"; } echo "<td>\n"; } else { $count--; } } else { echo "<th>{$nowfield['label']}</th>\n"; if ($nowfield['link']) { echo "<td colspan=2>{$nowfield['link']}</td>\n"; } else { echo "<td colspan=2>{$nowfield['text']}</td>\n"; } } $count++; } } echo "</tr>\n"; make_link($id, $tableinfo->name); show_reports($db, $tableinfo, $id, $viewid); if (function_exists("plugin_display_show")) { plugin_display_show($db, $Allfields, $id); return $Allfields; } echo "</table>\n"; echo "<form method='post' name='g_form' action='{$PHP_SELF}?tablename=" . $tableinfo->name . "&" . SID . "'>\n"; echo "<input type='hidden' name='md' value='{$md}'>\n"; echo "<input type='hidden' name='showid' value='{$id}'>\n"; //echo "<input type='hidden' name='jsnewwindow' value='false'>\n"; // for organizational purpose, define buttons here: // next and previous buttons if ($previousid) { $previousbutton = "<input type=\"button\" name=\"view_" . $previousid . "\" value=\"Previous\" onClick='MyWindow=window.open(\"general.php?tablename={$tableinfo->name}&showid={$previousid}&jsnewwindow=true&viewid={$viewid}\",\"view\",\"scrollbars,resizable,toolbar,width=600,height=400\")'>\n"; } if ($nextid) { $nextbutton = "<input type=\"button\" name=\"view_" . $nextid . "\" value=\"Next\" onClick='MyWindow=window.open(\"general.php?tablename={$tableinfo->name}&showid={$nextid}&jsnewwindow=true&viewid={$viewid}\",\"view\",\"scrollbars,resizable,toolbar,width=600,height=400\")'>\n"; } // closebutton $closebutton = "<input type=\"button\" onclick='self.close();window.opener.focus();' name='Close' value='Close'>\n"; if ($backbutton) { $backbutton = "<input type='submit' name='submit' value='Back'>\n"; } // modify button if (may_write($db, $tableinfo->id, $id, $USER)) { $modifybutton = "<input type=\"submit\" name=\"mod_" . $id . "\" value=\"Modify\">\n"; } // viewmenu: $viewmenu = viewmenu($db, $tableinfo, $viewid, false); // and now display the buttons echo "<table border=0 align='center' width='100%'>\n"; if ($backbutton) { echo "<tr>\n<td align='left'>"; echo " {$previousbutton}</td><td align='center'>{$modifybutton} {$backbutton} {$viewmenu}</td><td align='right'>{$nextbutton} </td>\n</tr>\n"; } else { echo "<tr><td align='left'>{$previousbutton} </td><td align='center'> {$modifybutton} {$closebutton} </td><td>{$viewmenu}</td><td align='right'>{$nextbutton} </td></tr>\n"; } echo "</table>\n\n"; echo "</form>\n"; }
$modetext .= "edit'>(to edit mode)</a>\n"; } } // write the first line shown in table view if ($may_write) { if ($md == 'edit') { echo "<td align='center'><a href='{$PHP_SELF}?add=Add&tablename={$tableinfo->name}&md=edit&" . SID . "'>Add Record</a></td>\n"; } else { //echo "<td align='center'><a href='$PHP_SELF?add=Add&tablename=$tableinfo->name&".SID."' target='_blank'>Add Record</a></td>\n"; echo "<td align='center'><a href='{$PHP_SELF}?add=Add&tablename={$tableinfo->name}&" . SID . "'>Add Record</a></td>\n"; } } else { echo "<td> </td>\n"; } echo "<td align='center'>{$tabletext} <B>{$tableinfo->label}</B> {$modetext}</td>"; echo "<td align='center'>" . viewmenu($db, $tableinfo, $viewid, false) . "</td>\n"; if ($may_write) { echo "<td align='center'><a href='import.php?tableid={$tableinfo->id}'>Import Data</a></td>\n"; } echo "</tr>\n</table>\n"; next_previous_buttons($rp, true, $num_p_r, $numrows, ${$pagename}, $db, $tableinfo, $viewid); // get a list with ids we may see, $listb has all the ids we may see if ($db_type == 'mysql') { $lista = make_SQL_csf($r, false, 'id', $nr_records); if (!$lista) { $lista = "-1"; } $lista = " id IN ({$lista}) "; } else { make_temp_table($db, 'tempa', $r); $lista = " ({$tableinfo->realname}.id=tempa.uniqueid) ";