File: enterprise.class.php

package info (click to toggle)
glpi 0.68.2-1etch0.2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 7,476 kB
  • ctags: 9,739
  • sloc: php: 69,695; sql: 3,514; sh: 175; makefile: 61
file content (244 lines) | stat: -rwxr-xr-x 7,779 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
/*
 * @version $Id: enterprise.class.php 3798 2006-08-22 15:12:55Z moyo $
 -------------------------------------------------------------------------
 GLPI - Gestionnaire Libre de Parc Informatique
 Copyright (C) 2003-2006 by the INDEPNET Development Team.

 http://indepnet.net/   http://glpi-project.org
 -------------------------------------------------------------------------

 LICENSE

 This file is part of GLPI.

 GLPI is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 GLPI is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with GLPI; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 --------------------------------------------------------------------------
 */

// ----------------------------------------------------------------------
// Original Author of file: Julien Dombre
// Purpose of file:
// ----------------------------------------------------------------------




class Enterprise extends CommonDBTM {

	function Enterprise () {
		$this->table="glpi_enterprises";
		$this->type=ENTERPRISE_TYPE;
	}


	function cleanDBonPurge($ID) {

		global $db;

		$job=new Job;

		// Delete all enterprises associations from infocoms and contract
		$query3 = "DELETE FROM glpi_contract_enterprise WHERE (FK_enterprise = \"$ID\")";
		$result3 = $db->query($query3);

		// Delete all contact enterprise associations
		$query2 = "DELETE FROM glpi_contact_enterprise WHERE (FK_enterprise = \"$ID\")";
		$result2 = $db->query($query2);

		/// TODO : UPDATE ALL FK_manufacturer to NULL
	}

	function defineOnglets($withtemplate){
		global $lang,$cfg_glpi;

		if(haveRight("contact_enterprise","r"))
			$ong[1] = $lang["title"][26];
		if (haveRight("contract_infocom","r"))	
			$ong[4] = $lang["Menu"][26];
		$ong[15] = $lang["financial"][104];
		if (haveRight("document","r"))
			$ong[5] = $lang["title"][25];
		if (haveRight("show_ticket","1"))	
			$ong[6] = $lang["title"][28];
		if (haveRight("link","r"))
			$ong[7] = $lang["title"][34];
		if (haveRight("notes","r"))
			$ong[10] = $lang["title"][37];

		return $ong;
	}


	// SPECIFIC FUNCTION

	function countContacts() {
		global $db;
		$query = "SELECT * FROM glpi_contact_enterprise WHERE (FK_enterprise = '".$this->fields["ID"]."')";
		if ($result = $db->query($query)) {
			$number = $db->numrows($result);
			return $number;
		} else {
			return false;
		}
	}

	function title(){

		global  $lang,$HTMLRel;

		echo "<div align='center'><table border='0'><tr><td>";
		echo "<img src=\"".$HTMLRel."pics/entreprises.png\" alt='".$lang["financial"][25]."' title='".$lang["financial"][25]."'></td>";
		if (haveRight("contact_enterprise","w")){
			echo "<td><a  class='icon_consol' href=\"enterprise.form.php\"><b>".$lang["financial"][25]."</b></a></td>";
		} else echo "<td><span class='icon_sous_nav'><b>".$lang["Menu"][23]."</b></span></td>";
		echo "</tr></table></div>";
	}




	function showForm ($target,$ID) {
		// Show Enterprise or blank form

		global $cfg_glpi,$lang;

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

		$spotted=false;
		if (!$ID) {

			if($this->getEmpty()) $spotted = true;
		} else {
			if($this->getfromDB($ID)) $spotted = true;
		}
		if ($spotted){
			echo "<form method='post' action=\"$target\"><div align='center'>";
			echo "<table class='tab_cadre_fixe'>";
			echo "<tr><th colspan='4'><b>";
			if (!$ID) {
				echo $lang["financial"][25].":";
			} else {
				echo $lang["financial"][26]." ID $ID:";
			}		
			echo "</b></th></tr>";

			echo "<tr class='tab_bg_1'><td>".$lang["common"][16].":		</td>";
			echo "<td>";
			autocompletionTextField("name","glpi_enterprises","name",$this->fields["name"],25);
			echo "</td>";

			echo "<td>".$lang["financial"][79].":		</td><td>";
			dropdownValue("glpi_dropdown_enttype", "type", $this->fields["type"]);
			echo "</td></tr>";

			echo "<tr class='tab_bg_1'><td>".$lang["financial"][29].":		</td>";
			echo "<td>";
			autocompletionTextField("phonenumber","glpi_enterprises","phonenumber",$this->fields["phonenumber"],25);	
			echo "</td>";

			echo "<td valign='top' rowspan='4'>";
			echo $lang["common"][25].":	</td>";
			echo "<td align='center'  rowspan='4'><textarea cols='35' rows='4' name='comments' >".$this->fields["comments"]."</textarea>";
			echo "</td></tr>";


			echo "<tr class='tab_bg_1'>";
			echo "<td>".$lang["financial"][30].":		</td><td>";
			autocompletionTextField("fax","glpi_enterprises","fax",$this->fields["fax"],25);	
			echo "</td></tr>";

			echo "<tr class='tab_bg_1'><td>".$lang["financial"][45].":		</td>";
			echo "<td>";
			autocompletionTextField("website","glpi_enterprises","website",$this->fields["website"],25);	
			echo "</td></tr>";

			echo "<tr class='tab_bg_1'>";
			echo "<td>".$lang["financial"][31].":		</td><td>";
			autocompletionTextField("email","glpi_enterprises","email",$this->fields["email"],25);		
			echo "</td></tr>";


			echo "<tr class='tab_bg_1'><td  rowspan='4'>".$lang["financial"][44].":		</td>";
			echo "<td align='center' rowspan='4'><textarea cols='35' rows='4' name='address' >".$this->fields["address"]."</textarea>";
			echo "<td>".$lang["financial"][100]."</td>";
			echo "<td>";
			autocompletionTextField("postcode","glpi_enterprises","postcode",$this->fields["postcode"],25);		
			echo "</td>";
			echo "</tr>";

			echo "<tr class='tab_bg_1'>";
			echo "<td>".$lang["financial"][101].":		</td><td>";
			autocompletionTextField("town","glpi_enterprises","town",$this->fields["town"],25);		
			echo "</td></tr>";

			echo "<tr class='tab_bg_1'>";
			echo "<td>".$lang["financial"][102].":		</td><td>";
			autocompletionTextField("state","glpi_enterprises","state",$this->fields["state"],25);		
			echo "</td></tr>";

			echo "<tr class='tab_bg_1'>";
			echo "<td>".$lang["financial"][103].":		</td><td>";
			autocompletionTextField("country","glpi_enterprises","country",$this->fields["country"],25);		
			echo "</td></tr>";

			if (haveRight("contact_enterprise","w"))
				if (!$ID) {

					echo "<tr>";
					echo "<td class='tab_bg_2' valign='top' colspan='4'>";
					echo "<div align='center'><input type='submit' name='add' value=\"".$lang["buttons"][8]."\" class='submit'></div>";
					echo "</td>";
					echo "</tr>";

				} else {

					echo "<tr>";
					echo "<td class='tab_bg_2'></td>";
					echo "<td class='tab_bg_2' valign='top'>";
					echo "<input type='hidden' name='ID' value=\"$ID\">\n";
					echo "<div align='center'><input type='submit' name='update' value=\"".$lang["buttons"][7]."\" class='submit'></div>";
					echo "</td>\n\n";
					echo "<td class='tab_bg_2'>&nbsp;</td><td class='tab_bg_2' valign='top'>\n";
					echo "<input type='hidden' name='ID' value=\"$ID\">\n";
					if ($this->fields["deleted"]=='N')
						echo "<div align='center'><input type='submit' name='delete' value=\"".$lang["buttons"][6]."\" class='submit'></div>";
					else {
						echo "<div align='center'><input type='submit' name='restore' value=\"".$lang["buttons"][21]."\" class='submit'>";

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

					echo "</td>";
					echo "</tr>";
				}

			echo "</table></div></form>";


		} else {
			echo "<div align='center'><b>".$lang["financial"][39]."</b></div>";
			return false;
		}

		return true;

	}



}

?>