Modularize frontPayment() function in front_payment.php script to allow use with...
[openemr.git] / phpmyadmin / db_printview.php
blob9b53f0cb410a999c2a41b984ac7e4ebb8615ae17
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 */
8 /**
11 require_once './libraries/common.inc.php';
13 /**
14 * Gets the variables sent or posted to this script, then displays headers
16 $print_view = true;
17 require_once './libraries/header.inc.php';
19 PMA_checkParameters(array('db'));
21 /**
22 * Defines the url to return to in case of error in a sql statement
24 $err_url = 'db_sql.php?' . PMA_generate_common_url($db);
26 /**
27 * Settings for relations stuff
29 require_once './libraries/relation.lib.php';
30 $cfgRelation = PMA_getRelationsParam();
32 /**
33 * Gets the list of the table in the current db and informations about these
34 * tables if possible
36 * @todo merge this speedup _optionaly_ into PMA_DBI_get_tables_full()
38 // staybyte: speedup view on locked tables - 11 June 2001
39 // Special speedup for newer MySQL Versions (in 4.0 format changed)
40 if ($cfg['SkipLockedTables'] == true) {
41 $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
42 // Blending out tables in use
43 if ($result != false && PMA_DBI_num_rows($result) > 0) {
44 while ($tmp = PMA_DBI_fetch_row($result)) {
45 // if in use memorize tablename
46 if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
47 $sot_cache[$tmp[0]] = true;
50 PMA_DBI_free_result($result);
52 if (isset($sot_cache)) {
53 $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
54 if ($result != false && PMA_DBI_num_rows($result) > 0) {
55 while ($tmp = PMA_DBI_fetch_row($result)) {
56 if (!isset($sot_cache[$tmp[0]])) {
57 $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
58 $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
59 $tables[] = $sts_tmp;
60 } else { // table in use
61 $tables[] = array('Name' => $tmp[0]);
64 PMA_DBI_free_result($result);
65 $sot_ready = true;
68 unset($tmp, $result);
72 if (! isset($sot_ready)) {
73 $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
74 if (PMA_DBI_num_rows($result) > 0) {
75 while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
76 $tables[] = $sts_tmp;
78 PMA_DBI_free_result($result);
79 unset($res);
84 /**
85 * If there is at least one table, displays the printer friendly view, else
86 * an error message
88 $tables = PMA_DBI_get_tables_full($db);
89 $num_tables = count($tables);
91 echo '<br />';
93 // 1. No table
94 if ($num_tables == 0) {
95 echo $strNoTablesFound;
97 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
98 else {
100 <table>
101 <thead>
102 <tr>
103 <th><?php echo $strTable; ?></th>
104 <th><?php echo $strRecords; ?></th>
105 <th><?php echo $strType; ?></th>
106 <?php
107 if ($cfg['ShowStats']) {
108 echo '<th>' . $strSize . '</th>';
111 <th><?php echo $strComments; ?></th>
112 </tr>
113 </thead>
114 <tbody>
115 <?php
116 $sum_entries = $sum_size = 0;
117 $odd_row = true;
118 foreach ($tables as $sts_data) {
119 if (strtoupper($sts_data['ENGINE']) == 'MRG_MYISAM'
120 || strtoupper($sts_data['ENGINE']) == 'FEDERATED') {
121 $merged_size = true;
122 } else {
123 $merged_size = false;
125 $sum_entries += $sts_data['TABLE_ROWS'];
127 <tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
128 <th>
129 <?php echo htmlspecialchars($sts_data['TABLE_NAME']); ?>
130 </th>
131 <?php
133 if (isset($sts_data['TABLE_ROWS'])) {
135 <td align="right">
136 <?php
137 if ($merged_size) {
138 echo '<i>' . PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . '</i>' . "\n";
139 } else {
140 echo PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . "\n";
143 </td>
144 <td nowrap="nowrap">
145 <?php echo $sts_data['ENGINE']; ?>
146 </td>
147 <?php
148 if ($cfg['ShowStats']) {
149 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
150 $sum_size += $tblsize;
151 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
153 <td align="right" nowrap="nowrap">
154 <?php echo $formated_size . ' ' . $unit; ?>
155 </td>
156 <?php
157 } // end if
158 } else {
160 <td colspan="3" align="center">
161 <?php echo $strInUse; ?>
162 </td>
163 <?php
166 <td>
167 <?php
168 if (! empty($sts_data['Comment'])) {
169 echo htmlspecialchars($sts_data['Comment']);
170 $needs_break = '<br />';
171 } else {
172 $needs_break = '';
175 if (! empty($sts_data['Create_time'])
176 || ! empty($sts_data['Update_time'])
177 || ! empty($sts_data['Check_time'])) {
178 echo $needs_break;
180 <table width="100%">
181 <?php
183 if (! empty($sts_data['Create_time'])) {
185 <tr>
186 <td align="right"><?php echo $strStatCreateTime . ': '; ?></td>
187 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
188 </tr>
189 <?php
192 if (! empty($sts_data['Update_time'])) {
194 <tr>
195 <td align="right"><?php echo $strStatUpdateTime . ': '; ?></td>
196 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
197 </tr>
198 <?php
201 if (! empty($sts_data['Check_time'])) {
203 <tr>
204 <td align="right"><?php echo $strStatCheckTime . ': '; ?></td>
205 <td align="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
206 </tr>
207 <?php
210 </table>
211 <?php
214 </td>
215 </tr>
216 <?php
219 <tr>
220 <th align="center">
221 <?php echo sprintf($strTables, PMA_formatNumber($num_tables, 0)); ?>
222 </th>
223 <th align="right" nowrap="nowrap">
224 <?php echo PMA_formatNumber($sum_entries, 0); ?>
225 </th>
226 <th align="center">
228 </th>
229 <?php
230 if ($cfg['ShowStats']) {
231 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
233 <th align="right" nowrap="nowrap">
234 <?php echo $sum_formated . ' ' . $unit; ?>
235 </th>
236 <?php
239 <th>&nbsp;</th>
240 </tr>
241 </tbody>
242 </table>
243 <?php
247 * Displays the footer
251 <script type="text/javascript">
252 //<![CDATA[
253 function printPage()
255 // Do print the page
256 if (typeof(window.print) != 'undefined') {
257 window.print();
260 //]]>
261 </script>
262 <br /><br />
264 <input type="button" class="print_ignore"
265 id="print" value="<?php echo $strPrint; ?>" onclick="printPage()" />
267 <?php
268 require_once './libraries/footer.inc.php';