Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / inc / contact.function.php @ b67d8923

Historique | Voir | Annoter | Télécharger (6,49 ko)

1
<?php
2
/*
3
 * @version $Id: contact.function.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
// FUNCTIONS contact
41

    
42

    
43
/**
44
 * Print the HTML array for entreprises on contact
45
 *
46
 * Print the HTML array for entreprises on contact for contact $instID
47
 *
48
 *@param $instID array : Contact identifier.
49
 *
50
 *@return Nothing (display)
51
 *
52
 **/
53
function showEnterpriseContact($instID) {
54
        global $DB,$CFG_GLPI, $LANG;
55

    
56
        if (!haveRight("contact_enterprise","r")) return false;
57
        
58
        $contact=new Contact();
59
        $canedit=$contact->can($instID,'w');
60

    
61
        $query = "SELECT glpi_contact_enterprise.ID as ID, glpi_enterprises.ID as entID, glpi_enterprises.name as name, glpi_enterprises.website as website, glpi_enterprises.fax as fax, "
62
                . " glpi_enterprises.phonenumber as phone, glpi_enterprises.type as type, glpi_enterprises.deleted as deleted, glpi_entities.ID AS entity"
63
                . " FROM glpi_contact_enterprise, glpi_enterprises "
64
                . " LEFT JOIN glpi_entities ON (glpi_entities.ID=glpi_enterprises.FK_entities) "
65
                . " WHERE glpi_contact_enterprise.FK_contact = '$instID' AND glpi_contact_enterprise.FK_enterprise = glpi_enterprises.ID"
66
                . getEntitiesRestrictRequest(" AND","glpi_enterprises",'','',true) 
67
                . " ORDER BY glpi_entities.completename,name";
68
        
69
        $result = $DB->query($query);
70
        $number = $DB->numrows($result);
71
        $i = 0;
72

    
73
        echo "<form method='post' action=\"".$CFG_GLPI["root_doc"]."/front/contact.form.php\">";
74
        echo "<br><br><div class='center'><table class='tab_cadre_fixe'>";
75
        echo "<tr><th colspan='7'>".$LANG["financial"][65].":</th></tr>";
76
        echo "<tr><th>".$LANG["financial"][26]."</th>";
77
        echo "<th>".$LANG["entity"][0]."</th>";
78
        echo "<th>".$LANG["financial"][79]."</th>";
79
        echo "<th>".$LANG["help"][35]."</th>";
80
        echo "<th>".$LANG["financial"][30]."</th>";
81
        echo "<th>".$LANG["financial"][45]."</th>";
82
        echo "<th>&nbsp;</th></tr>";
83

    
84
        $used=array();
85
        while ($data= $DB->fetch_array($result)) {
86
                $ID=$data["ID"];
87
                $used[$data["entID"]]=$data["entID"];
88
                $website=$data["website"];
89
                if (!empty($website)){
90
                        $website=$data["website"];
91
                        if (!ereg("https*://",$website)) $website="http://".$website;
92
                        $website="<a target=_blank href='$website'>".$data["website"]."</a>";
93
                }
94
                echo "<tr class='tab_bg_1".($data["deleted"]?"_2":"")."'>";
95
                echo "<td class='center'><a href='".$CFG_GLPI["root_doc"]."/front/enterprise.form.php?ID=".$data["entID"]."'>".getDropdownName("glpi_enterprises",$data["entID"])."</a></td>";
96
                echo "<td class='center'>".getDropdownName("glpi_entities",$data["entity"])."</td>";
97
                echo "<td class='center'>".getDropdownName("glpi_dropdown_enttype",$data["type"])."</td>";
98
                echo "<td align='center'  width='100'>".$data["phone"]."</td>";
99
                echo "<td align='center'  width='100'>".$data["fax"]."</td>";
100
                echo "<td class='center'>".$website."</td>";
101
                echo "<td align='center' class='tab_bg_2'>";
102
                if ($canedit) 
103
                        echo "<a href='".$_SERVER['PHP_SELF']."?deleteenterprise=deleteenterprise&amp;ID=$ID&amp;cID=$instID'><strong>".$LANG["buttons"][6]."</strong></a>";
104
                else echo "&nbsp;";
105
                echo "</td></tr>";
106
        }
107
        if ($canedit){
108
                if ($contact->fields["recursive"]) {
109
                        $nb=countElementsInTableForEntity("glpi_enterprises",getEntitySons($contact->fields["FK_entities"]));                        
110
                } else {
111
                        $nb=countElementsInTableForEntity("glpi_enterprises",$contact->fields["FK_entities"]);
112
                }                
113
                if ($nb>count($used)) {
114
                        echo "<tr class='tab_bg_1'><td>&nbsp;</td><td class='center' colspan='4'>";
115
                        echo "<div class='software-instal'><input type='hidden' name='conID' value='$instID'>";
116
                        if ($contact->fields["recursive"]) {
117
                                dropdown("glpi_enterprises","entID",1,getEntitySons($contact->fields["FK_entities"]),$used);
118
                        } else {
119
                                dropdown("glpi_enterprises","entID",1,$contact->fields["FK_entities"],$used);
120
                        }
121
                        echo "&nbsp;&nbsp;<input type='submit' name='addenterprise' value=\"".$LANG["buttons"][8]."\" class='submit'>";
122
                        echo "</div>";
123
                        echo "</td><td>&nbsp;</td><td>&nbsp;</td>";
124
                        echo "</tr>";
125
                }
126
        }
127

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

    
130
}
131

    
132

    
133
/**
134
 * Generate the Vcard for a specific user
135
 *
136
 *@param $ID ID of the user
137
 *
138
 *@return Nothing (display)
139
 *
140
 **/
141
function generateContactVcard($ID){
142

    
143
        $contact = new Contact;
144
        $contact->getFromDB($ID);
145

    
146
        // build the Vcard
147

    
148
        $vcard = new vCard();
149

    
150

    
151

    
152
        $vcard->setName($contact->fields["name"], $contact->fields["firstname"], "", "");  
153

    
154
        $vcard->setPhoneNumber($contact->fields["phone"], "PREF;WORK;VOICE");
155
        $vcard->setPhoneNumber($contact->fields["phone2"], "HOME;VOICE");
156
        $vcard->setPhoneNumber($contact->fields["mobile"], "WORK;CELL");
157

    
158
        //if ($contact->birthday) $vcard->setBirthday($contact->birthday);
159

    
160
        $addr=$contact->GetAddress();
161
        if (is_array($addr))
162
                $vcard->setAddress($addr["name"], "", $addr["address"], $addr["town"], $addr["state"], $addr["postcode"], $addr["country"],"WORK;POSTAL"); 
163

    
164
        $vcard->setEmail($contact->fields["email"]);
165

    
166
        $vcard->setNote($contact->fields["comments"]);
167

    
168
        $vcard->setURL($contact->GetWebsite(), "WORK");
169

    
170

    
171

    
172
        // send the  VCard 
173

    
174
        $output = $vcard->getVCard();
175

    
176

    
177
        $filename =$vcard->getFileName();      // "xxx xxx.vcf"
178

    
179
        @Header("Content-Disposition: attachment; filename=\"$filename\"");
180
        @Header("Content-Length: ".strlen($output));
181
        @Header("Connection: close");
182
        @Header("content-type: text/x-vcard; charset=UTF-8");
183

    
184
        echo $output;
185

    
186
}
187

    
188

    
189
?>
Redmine Appliance - Powered by TurnKey Linux