dolibarr/htdocs/contact.class.php

123 lines
2.5 KiB
PHP
Raw Normal View History

2002-04-30 12:51:35 +02:00
<?PHP
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
2002-12-12 16:09:51 +01:00
* $Id$
* $Source$
*
2002-04-30 12:51:35 +02:00
*/
2002-12-12 17:11:54 +01:00
class Contact
{
2002-04-30 12:51:35 +02:00
var $bs;
var $db;
var $id;
var $fullname;
var $nom;
var $prenom;
var $code;
var $email;
2002-12-12 17:11:54 +01:00
Function Contact($DB, $id=0)
{
2002-04-30 12:51:35 +02:00
2002-12-12 17:11:54 +01:00
$this->db = $DB;
$this->id = $id;
return 1;
}
2002-04-30 12:51:35 +02:00
/*
*
*
*
*/
2003-09-14 14:07:30 +02:00
Function create($user)
{
$sql = "INSERT INTO llx_socpeople (datec, fk_soc,name) ";
$sql .= " VALUES (now(),$this->socid,'$this->nom')";
if ($this->db->query($sql) ) {
$id = $this->db->last_insert_id();
return $id;
}
}
2002-04-30 12:51:35 +02:00
2002-12-12 17:11:54 +01:00
Function fetch($id)
{
2003-08-12 15:28:56 +02:00
$sql = "SELECT c.idp, c.fk_soc, c.name, c.firstname, c.email";
2003-05-25 18:23:14 +02:00
$sql .= " FROM llx_socpeople as c";
2002-12-12 17:11:54 +01:00
$sql .= " WHERE c.idp = $id";
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object($result , 0);
2002-04-30 12:51:35 +02:00
2002-12-12 17:11:54 +01:00
$this->id = $obj->idp;
$this->nom = $obj->name;
$this->prenom = $obj->firstname;
2003-08-12 15:28:56 +02:00
$this->societeid = $obj->fk_soc;
2002-12-12 17:11:54 +01:00
$this->fullname = $this->prenom . ' ' . $this->nom;
$this->code = $obj->code;
$this->email = $obj->email;
2003-08-12 15:28:56 +02:00
$this->mail = $obj->email;
2002-12-12 17:11:54 +01:00
}
2002-04-30 12:51:35 +02:00
2002-12-12 17:11:54 +01:00
$this->db->free();
}
else
{
print $this->db->error();
}
}
2003-05-25 18:23:14 +02:00
/*
*
*
*/
2002-12-12 17:11:54 +01:00
Function update($id)
{
2002-04-30 12:51:35 +02:00
2002-12-12 17:11:54 +01:00
$this->email = trim($this->email);
2002-04-30 12:51:35 +02:00
2003-05-25 18:23:14 +02:00
$sql = "UPDATE llx_socpeople set name='$this->name', firstname='$this->firstname', poste='$this->poste', phone='$this->phone',fax='$this->fax',email='$this->email', note='$this->note'";
2002-12-12 17:11:54 +01:00
$sql .= " WHERE idp=$id";
2002-04-30 12:51:35 +02:00
2002-12-12 17:11:54 +01:00
$result = $this->db->query($sql);
2002-04-30 12:51:35 +02:00
2002-12-12 17:11:54 +01:00
if (!$result)
{
print $this->db->error();
}
return $result;
2002-04-30 12:51:35 +02:00
}
2002-12-12 17:11:54 +01:00
2002-04-30 12:51:35 +02:00
}
2002-05-10 14:28:10 +02:00
2002-04-30 12:51:35 +02:00
?>