dolibarr  7.0.0-beta
dbtable.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5  * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
27 require '../../main.inc.php';
28 
29 $langs->load("admin");
30 
31 if (! $user->admin)
33 
34 $table=GETPOST('table','alpha');
35 
36 
37 /*
38  * View
39  */
40 
41 llxHeader();
42 
43 
44 print load_fiche_titre($langs->trans("Table") . " ".$table,'','title_setup');
45 
46 // Define request to get table description
47 $base=0;
48 if (preg_match('/mysql/i',$conf->db->type))
49 {
50  $sql = "SHOW TABLE STATUS LIKE '".$db->escape($table)."'";
51  $base=1;
52 }
53 else if ($conf->db->type == 'pgsql')
54 {
55  $sql = "SELECT conname,contype FROM pg_constraint";
56  $base=2;
57 }
58 
59 if (! $base)
60 {
61  print $langs->trans("FeatureNotAvailableWithThisDatabaseDriver");
62 }
63 else
64 {
65  $resql = $db->query($sql);
66  if ($resql)
67  {
68  $num = $db->num_rows($resql);
69  $var=True;
70  $i=0;
71  while ($i < $num)
72  {
73  $row = $db->fetch_row($resql);
74  $i++;
75  }
76  }
77 
78  if ($base == 1)
79  {
80  $link=array();
81  $cons = explode(";", $row[14]);
82  if (! empty($cons))
83  {
84  foreach($cons as $cc)
85  {
86  $cx = preg_replace("/\)\sREFER/", "", $cc);
87  $cx = preg_replace("/\(`/", "", $cx);
88  $cx = preg_replace("/`\)/", "", $cx);
89  $cx = preg_replace("/`\s/", "", $cx);
90 
91  $val = explode("`",$cx);
92 
93  $link[trim($val[0])][0] = (isset($val[1])?$val[1]:'');
94  $link[trim($val[0])][1] = (isset($val[2])?$val[2]:'');
95  }
96  }
97 
98  // var_dump($link);
99 
100  print '<table>';
101  print '<tr class="liste_titre"><td>'.$langs->trans("Fields").'</td><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Index").'</td>';
102  print '<td>'.$langs->trans("FieldsLinked").'</td></tr>';
103 
104  $sql = "DESCRIBE ".$table;
105  $resql = $db->query($sql);
106  if ($resql)
107  {
108  $num = $db->num_rows($resql);
109  $i=0;
110  while ($i < $num)
111  {
112  $row = $db->fetch_row($resql);
113  print '<tr class="oddeven">';
114  print "<td>$row[0]</td>";
115  print "<td>$row[1]</td>";
116  print "<td>$row[3]</td>";
117  print "<td>".(isset($link[$row[0]][0])?$link[$row[0]][0]:'').".";
118  print (isset($link[$row[0]][1])?$link[$row[0]][1]:'')."</td>";
119 
120  print '</tr>';
121  $i++;
122  }
123  }
124  print '</table>';
125  }
126 }
127 
128 llxFooter();
129 
130 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013