Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / inc / enterprise.class.php @ b67d8923

Historique | Voir | Annoter | Télécharger (8,77 ko)

1
<?php
2
/*
3
 * @version $Id: enterprise.class.php 7875 2009-01-23 15:16:47Z 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

    
42
class Enterprise extends CommonDBTM {
43

    
44
        /**
45
         * Constructor
46
        **/
47
        function Enterprise () {
48
                $this->table="glpi_enterprises";
49
                $this->type=ENTERPRISE_TYPE;
50
                $this->entity_assign=true;
51
                $this->may_be_recursive=true;
52
        }
53

    
54

    
55
        function cleanDBonPurge($ID) {
56

    
57
                global $DB;
58

    
59
                $job=new Job;
60

    
61
                // Delete all enterprises associations from infocoms and contract
62
                $query3 = "DELETE FROM glpi_contract_enterprise WHERE (FK_enterprise = '$ID')";
63
                $result3 = $DB->query($query3);
64

    
65
                // Delete all contact enterprise associations
66
                $query2 = "DELETE FROM glpi_contact_enterprise WHERE (FK_enterprise = '$ID')";
67
                $result2 = $DB->query($query2);
68

    
69
                /// TODO : UPDATE ALL FK_manufacturer to NULL
70
        }
71

    
72
        function defineOnglets($withtemplate){
73
                global $LANG,$CFG_GLPI;
74

    
75
                if(haveRight("contact_enterprise","r")){
76
                        $ong[1] = $LANG["title"][26];
77
                }
78
                if (haveRight("contract_infocom","r")){
79
                        $ong[4] = $LANG["Menu"][26];
80
                }
81
                $ong[15] = $LANG["financial"][104];
82
                if (haveRight("document","r")){
83
                        $ong[5] = $LANG["Menu"][27];
84
                }
85
                if (haveRight("show_all_ticket","1")){
86
                        $ong[6] = $LANG["title"][28];
87
                }
88
                if (haveRight("link","r")){
89
                        $ong[7] = $LANG["title"][34];
90
                }
91
                if (haveRight("notes","r")){
92
                        $ong[10] = $LANG["title"][37];
93
                }
94

    
95
                return $ong;
96
        }
97

    
98

    
99
        // SPECIFIC FUNCTION
100

    
101
/*
102
        // NOT_USED
103
        function countContacts() {
104
                global $DB;
105
                $query = "SELECT * FROM glpi_contact_enterprise WHERE (FK_enterprise = '".$this->fields["ID"]."')";
106
                if ($result = $DB->query($query)) {
107
                        $number = $DB->numrows($result);
108
                        return $number;
109
                } else {
110
                        return false;
111
                }
112
        }
113
*/
114
        /**
115
         * Print the enterprise form
116
         *
117
         *@param $target form target
118
         *@param $ID Integer : Id of the computer or the template to print
119
         *@param $withtemplate='' boolean : template or basic computer
120
         *
121
         *@return Nothing (display)
122
         **/
123
        function showForm ($target,$ID,$withtemplate='') {
124
                // Show Enterprise or blank form
125

    
126
                global $CFG_GLPI,$LANG;
127

    
128
                if (!haveRight("contact_enterprise","r")) return false;
129

    
130
                $spotted=false;
131
                $use_cache=true;
132

    
133

    
134
                if ($ID>0) {
135
                        if($this->can($ID,'r')) {
136
                                $spotted = true;        
137
                        }
138
                } else {
139
                        $use_cache=false;
140
                        if ($this->can(-1,'w')){
141
                                $spotted = true;        
142
                        }
143
                } 
144

    
145
                if ($spotted){
146
                        $canedit=$this->can($ID,'w');
147
                        
148
                        $this->showOnglets($ID, $withtemplate,$_SESSION['glpi_onglet']);
149
                        if ($canedit) {
150
                                echo "<form method='post' action=\"$target\"><div class='center'>";
151
                                if (empty($ID)||$ID<0){
152
                                        echo "<input type='hidden' name='FK_entities' value='".$_SESSION["glpiactive_entity"]."'>";
153
                                }
154
                        }
155

    
156
                        echo "<table class='tab_cadre_fixe'>";
157
                        echo "<tr><th colspan='2'>";
158
                        if ($ID<0) {
159
                                echo $LANG["financial"][25];
160
                        } else {
161
                                echo $LANG["common"][2]." ".$this->fields["ID"];
162
                        }                
163
                        if (isMultiEntitiesMode()){
164
                                echo "&nbsp;(".getDropdownName("glpi_entities",$this->fields["FK_entities"]).")";
165
                        }
166

    
167
                        echo "</th>";
168

    
169
                        echo "<th colspan='2'>";
170
                        if (isMultiEntitiesMode()){
171
                                echo $LANG["entity"][9].":&nbsp;";
172
                        
173
                                if ($this->can($ID,'recursive')) {
174
                                        dropdownYesNo("recursive",$this->fields["recursive"]);                                        
175
                                } else {
176
                                        echo getYesNo($this->fields["recursive"]);
177
                                }
178
                        } else {
179
                                echo "&nbsp;";
180
                        }
181
                        echo "</th>";
182

    
183
                        echo "</tr>";
184
                        if (!$use_cache||!($CFG_GLPI["cache"]->start($ID."_".$_SESSION["glpilanguage"],"GLPI_".$this->type))) {
185
                                echo "<tr class='tab_bg_1'><td>".$LANG["common"][16].":                </td>";
186
                                echo "<td>";
187
                                autocompletionTextField("name","glpi_enterprises","name",$this->fields["name"],25,$this->fields["FK_entities"]);
188
                                echo "</td>";
189
        
190
                                echo "<td>".$LANG["financial"][79].":                </td><td>";
191
                                dropdownValue("glpi_dropdown_enttype", "type", $this->fields["type"]);
192
                                echo "</td></tr>";
193
        
194
                                echo "<tr class='tab_bg_1'><td>".$LANG["help"][35].":                </td>";
195
                                echo "<td>";
196
                                autocompletionTextField("phonenumber","glpi_enterprises","phonenumber",$this->fields["phonenumber"],25,$this->fields["FK_entities"]);        
197
                                echo "</td>";
198
        
199
                                echo "<td valign='top' rowspan='4'>";
200
                                echo $LANG["common"][25].":        </td>";
201
                                echo "<td align='center'  rowspan='4'><textarea cols='35' rows='4' name='comments' >".$this->fields["comments"]."</textarea>";
202
                                echo "</td></tr>";
203

    
204
        
205
                                echo "<tr class='tab_bg_1'>";
206
                                echo "<td>".$LANG["financial"][30].":                </td><td>";
207
                                autocompletionTextField("fax","glpi_enterprises","fax",$this->fields["fax"],25,$this->fields["FK_entities"]);
208
                                echo "</td>";
209
                                echo "</tr>";
210

    
211
                                echo "<tr class='tab_bg_1'><td>".$LANG["financial"][45].":                </td>";
212
                                echo "<td>";
213
                                autocompletionTextField("website","glpi_enterprises","website",$this->fields["website"],25,$this->fields["FK_entities"]);        
214
                                echo "</td></tr>";
215
        
216
                                echo "<tr class='tab_bg_1'>";
217
                                echo "<td>".$LANG["setup"][14].":                </td><td>";
218
                                autocompletionTextField("email","glpi_enterprises","email",$this->fields["email"],25,$this->fields["FK_entities"]);
219
                                echo "</td></tr>";
220
        
221
        
222
                                echo "<tr class='tab_bg_1'><td  rowspan='4'>".$LANG["financial"][44].":                </td>";
223
                                echo "<td align='center' rowspan='4'><textarea cols='35' rows='4' name='address' >".$this->fields["address"]."</textarea>";
224
                                echo "<td>".$LANG["financial"][100]."</td>";
225
                                echo "<td>";
226
                                autocompletionTextField("postcode","glpi_enterprises","postcode",$this->fields["postcode"],25,$this->fields["FK_entities"]);
227
                                echo "</td>";
228
                                echo "</tr>";
229
        
230
                                echo "<tr class='tab_bg_1'>";
231
                                echo "<td>".$LANG["financial"][101].":                </td><td>";
232
                                autocompletionTextField("town","glpi_enterprises","town",$this->fields["town"],25,$this->fields["FK_entities"]);
233
                                echo "</td></tr>";
234
        
235
                                echo "<tr class='tab_bg_1'>";
236
                                echo "<td>".$LANG["financial"][102].":                </td><td>";
237
                                autocompletionTextField("state","glpi_enterprises","state",$this->fields["state"],25,$this->fields["FK_entities"]);
238
                                echo "</td></tr>";
239
        
240
                                echo "<tr class='tab_bg_1'>";
241
                                echo "<td>".$LANG["financial"][103].":                </td><td>";
242
                                autocompletionTextField("country","glpi_enterprises","country",$this->fields["country"],25,$this->fields["FK_entities"]);
243
                                echo "</td></tr>";
244
                
245
                                if ($use_cache){
246
                                        $CFG_GLPI["cache"]->end();
247
                                }
248
                        }
249

    
250
                        if ($canedit) {
251
                                        echo "<tr>";
252

    
253
                                if ($ID>0) {
254

    
255
                                        echo "<td class='tab_bg_2' valign='top' colspan='2'>";
256
                                        echo "<input type='hidden' name='ID' value=\"$ID\">\n";
257
                                        echo "<div class='center'><input type='submit' name='update' value=\"".$LANG["buttons"][7]."\" class='submit'></div>";
258
                                        echo "</td>\n\n";
259
                                        echo "<td class='tab_bg_2' valign='top' colspan='2'>\n";
260
                                        echo "<input type='hidden' name='ID' value=\"$ID\">\n";
261
                                        if (!$this->fields["deleted"])
262
                                                echo "<div class='center'><input type='submit' name='delete' value=\"".$LANG["buttons"][6]."\" class='submit'></div>";
263
                                        else {
264
                                                echo "<div class='center'><input type='submit' name='restore' value=\"".$LANG["buttons"][21]."\" class='submit'>";
265

    
266
                                                echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='submit' name='purge' value=\"".$LANG["buttons"][22]."\" class='submit'></div>";
267
                                        }
268

    
269
                                        echo "</td>";
270
                                        echo "</tr>";
271

    
272
                                } else {
273
                                        echo "<td class='tab_bg_2' valign='top' colspan='4'>";
274
                                        echo "<div class='center'><input type='submit' name='add' value=\"".$LANG["buttons"][8]."\" class='submit'></div>";
275
                                        echo "</td>";
276
                                        echo "</tr>";
277

    
278
                                }
279
                                echo "</table></div></form>";
280
                        } else { // canedit
281
                                echo "</table></div>";                                
282
                        }
283

    
284

    
285
                } else {
286
                        echo "<div class='center'><strong>".$LANG["common"][54]."</strong></div>";
287
                        return false;
288
                }
289

    
290
                return true;
291

    
292
        }
293

    
294

    
295

    
296
}
297

    
298
?>
Redmine Appliance - Powered by TurnKey Linux