ryxeo-glpi-git / inc / entity.class.php @ b67d8923
Historique | Voir | Annoter | Télécharger (6,91 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
* @version $Id: entity.class.php 7763 2009-01-06 18:44:50Z moyo $
|
4 |
-------------------------------------------------------------------------
|
5 |
GLPI - Gestionnaire Libre de Parc Informatique
|
6 |
Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
7 |
|
8 |
http://indepnet.net/ http://glpi-project.org
|
9 |
-------------------------------------------------------------------------
|
10 |
|
11 |
LICENSE
|
12 |
|
13 |
This file is part of GLPI.
|
14 |
|
15 |
GLPI is free software; you can redistribute it and/or modify
|
16 |
it under the terms of the GNU General Public License as published by
|
17 |
the Free Software Foundation; either version 2 of the License, or
|
18 |
(at your option) any later version.
|
19 |
|
20 |
GLPI is distributed in the hope that it will be useful,
|
21 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
GNU General Public License for more details.
|
24 |
|
25 |
You should have received a copy of the GNU General Public License
|
26 |
along with GLPI; if not, write to the Free Software
|
27 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
28 |
--------------------------------------------------------------------------
|
29 |
*/
|
30 |
|
31 |
// ----------------------------------------------------------------------
|
32 |
// Original Author of file: Julien Dombre
|
33 |
// Purpose of file:
|
34 |
// ----------------------------------------------------------------------
|
35 |
|
36 |
if (!defined('GLPI_ROOT')){ |
37 |
die("Sorry. You can't access directly to this file"); |
38 |
} |
39 |
|
40 |
|
41 |
/// Entity Data class
|
42 |
class EntityData extends CommonDBTM{ |
43 |
|
44 |
/**
|
45 |
* Constructor
|
46 |
**/
|
47 |
function EntityData () { |
48 |
$this->table="glpi_entities_data"; |
49 |
$this->type=-1; |
50 |
} |
51 |
function getIndexName(){ |
52 |
return "FK_entities"; |
53 |
} |
54 |
|
55 |
} |
56 |
|
57 |
|
58 |
/// Entity class
|
59 |
class Entity extends CommonDBTM{ |
60 |
|
61 |
/**
|
62 |
* Constructor
|
63 |
**/
|
64 |
function Entity () { |
65 |
$this->table="glpi_entities"; |
66 |
$this->type=ENTITY_TYPE; |
67 |
} |
68 |
|
69 |
function defineOnglets($withtemplate){ |
70 |
global $LANG; |
71 |
|
72 |
$ong[1]=$LANG["title"][26]; |
73 |
$ong[2]=$LANG["Menu"][14]; |
74 |
$ong[3]=$LANG["rulesengine"][17]; |
75 |
|
76 |
return $ong; |
77 |
} |
78 |
|
79 |
/**
|
80 |
* Print a good title for entity pages
|
81 |
*
|
82 |
*@return nothing (display)
|
83 |
**/
|
84 |
function title(){ |
85 |
global $LANG,$CFG_GLPI; |
86 |
|
87 |
$buttons=array(); |
88 |
$title=$LANG["Menu"][37]; |
89 |
if (haveRight("entity","w")){ |
90 |
$buttons["entity.tree.php"]=$LANG["entity"][1]; |
91 |
$title=""; |
92 |
} |
93 |
$buttons["entity.form.php?ID=0"]=$LANG["entity"][2]; |
94 |
|
95 |
displayTitle($CFG_GLPI["root_doc"]."/pics/groupes.png",$LANG["Menu"][37],$title,$buttons); |
96 |
} |
97 |
|
98 |
/**
|
99 |
* Print the entity form
|
100 |
*
|
101 |
*
|
102 |
* Print entity form
|
103 |
*
|
104 |
*@param $target filename : where to go when done.
|
105 |
*@param $ID Integer : Id of the contact to print
|
106 |
*@param $withtemplate='' boolean : template or basic item
|
107 |
*
|
108 |
*
|
109 |
*@return Nothing (display)
|
110 |
*
|
111 |
**/
|
112 |
function showForm ($target,$ID,$withtemplate='') { |
113 |
|
114 |
global $CFG_GLPI, $LANG; |
115 |
|
116 |
if (!haveRight("entity","r")) return false; |
117 |
|
118 |
$con_spotted=false; |
119 |
|
120 |
if (empty($ID)&&$ID!=0) { |
121 |
if($this->getEmpty()) $con_spotted = true; |
122 |
} else {
|
123 |
if ($ID==0) { |
124 |
$con_spotted=true; |
125 |
$this->fields["name"]=$LANG["entity"][2]; |
126 |
$this->fields["completename"]=""; |
127 |
} |
128 |
else if($this->getFromDB($ID)) $con_spotted = true; |
129 |
} |
130 |
|
131 |
|
132 |
// Get data
|
133 |
$entdata=new EntityData(); |
134 |
if (!$entdata->getFromDB($ID)){ |
135 |
$entdata->add(array("FK_entities"=>$ID)); |
136 |
if (!$entdata->getFromDB($ID)){ |
137 |
$con_spotted=false; |
138 |
} |
139 |
} |
140 |
|
141 |
|
142 |
if ($con_spotted){ |
143 |
|
144 |
$this->showOnglets($ID, $withtemplate,$_SESSION['glpi_onglet']); |
145 |
|
146 |
echo "<form method='post' name=form action=\"$target\"><div class='center'>"; |
147 |
|
148 |
echo "<table class='tab_cadre_fixe' cellpadding='2' >"; |
149 |
echo "<tr><th colspan='4'>"; |
150 |
echo $LANG["entity"][0]." ID $ID:"; |
151 |
|
152 |
echo "</th></tr>"; |
153 |
|
154 |
echo "<tr class='tab_bg_1'>"; |
155 |
|
156 |
echo "<td valign='top'>".$LANG["common"][16].": </td>"; |
157 |
echo "<td valign='top'>"; |
158 |
echo $this->fields["name"]; |
159 |
if ($ID!=0) echo " (".$this->fields["completename"].")"; |
160 |
echo "</td>"; |
161 |
if (isset($this->fields["comments"])){ |
162 |
echo "<td valign='top'>"; |
163 |
echo $LANG["common"][25].": </td>"; |
164 |
echo "<td align='center' valign='top'>".nl2br($this->fields["comments"]); |
165 |
echo "</td>"; |
166 |
} else {
|
167 |
echo "<td colspan='2'> </td>"; |
168 |
} |
169 |
echo "</tr>"; |
170 |
|
171 |
echo "<tr class='tab_bg_1'><td>".$LANG["help"][35].": </td>"; |
172 |
echo "<td>"; |
173 |
autocompletionTextField("phonenumber","glpi_entities_data","phonenumber",$entdata->fields["phonenumber"],25); |
174 |
echo "</td>"; |
175 |
echo "<td>".$LANG["financial"][30].": </td><td>"; |
176 |
autocompletionTextField("fax","glpi_entities_data","fax",$entdata->fields["fax"],25); |
177 |
echo "</td></tr>"; |
178 |
|
179 |
echo "<tr class='tab_bg_1'><td>".$LANG["financial"][45].": </td>"; |
180 |
echo "<td>"; |
181 |
autocompletionTextField("website","glpi_entities_data","website",$entdata->fields["website"],25); |
182 |
echo "</td>"; |
183 |
|
184 |
echo "<td>".$LANG["setup"][14].": </td><td>"; |
185 |
autocompletionTextField("email","glpi_entities_data","email",$entdata->fields["email"],25); |
186 |
echo "</td></tr>"; |
187 |
|
188 |
|
189 |
echo "<tr class='tab_bg_1'><td rowspan='4'>".$LANG["financial"][44].": </td>"; |
190 |
echo "<td align='center' rowspan='4'><textarea cols='35' rows='4' name='address' >".$entdata->fields["address"]."</textarea>"; |
191 |
echo "<td>".$LANG["financial"][100]."</td>"; |
192 |
echo "<td>"; |
193 |
autocompletionTextField("postcode","glpi_entities_data","postcode",$entdata->fields["postcode"],25); |
194 |
echo "</td>"; |
195 |
echo "</tr>"; |
196 |
|
197 |
echo "<tr class='tab_bg_1'>"; |
198 |
echo "<td>".$LANG["financial"][101].": </td><td>"; |
199 |
autocompletionTextField("town","glpi_entities_data","town",$entdata->fields["town"],25); |
200 |
echo "</td></tr>"; |
201 |
|
202 |
echo "<tr class='tab_bg_1'>"; |
203 |
echo "<td>".$LANG["financial"][102].": </td><td>"; |
204 |
autocompletionTextField("state","glpi_entities_data","state",$entdata->fields["state"],25); |
205 |
echo "</td></tr>"; |
206 |
|
207 |
echo "<tr class='tab_bg_1'>"; |
208 |
echo "<td>".$LANG["financial"][103].": </td><td>"; |
209 |
autocompletionTextField("country","glpi_entities_data","country",$entdata->fields["country"],25); |
210 |
echo "</td></tr>"; |
211 |
|
212 |
echo "<tr class='tab_bg_1'>"; |
213 |
echo "<td>".$LANG["setup"][203].": </td><td colspan='3'>"; |
214 |
autocompletionTextField("admin_email","glpi_entities_data","admin_email",$entdata->fields["admin_email"],50); |
215 |
echo "</td></tr>"; |
216 |
|
217 |
echo "<tr class='tab_bg_1'>"; |
218 |
echo "<td>".$LANG["setup"][207].": </td><td colspan='3'>"; |
219 |
autocompletionTextField("admin_reply","glpi_entities_data","admin_reply",$entdata->fields["admin_reply"],50); |
220 |
echo "</td></tr>"; |
221 |
|
222 |
|
223 |
if (haveRight("entity","w")) { |
224 |
echo "<tr>"; |
225 |
echo "<td class='tab_bg_2' colspan='4' valign='top' align='center'>"; |
226 |
echo "<input type='hidden' name='FK_entities' value=\"$ID\">\n"; |
227 |
echo "<input type='hidden' name='ID' value=\"".$entdata->fields["ID"]."\">\n"; |
228 |
echo "<input type='submit' name='update' value=\"".$LANG["buttons"][7]."\" class='submit' >"; |
229 |
echo "</td>\n\n"; |
230 |
echo "</tr>"; |
231 |
|
232 |
} |
233 |
|
234 |
echo "</table></div></form>"; |
235 |
|
236 |
} else {
|
237 |
echo "<div class='center'><strong>".$LANG["common"][54]."</strong></div>"; |
238 |
return false; |
239 |
|
240 |
} |
241 |
return true; |
242 |
} |
243 |
|
244 |
|
245 |
} |
246 |
|
247 |
?>
|