From a1c7cadf0e1216af066475532d5f4f85f92b05bd Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 21 Jun 2005 15:39:38 +0000 Subject: [PATCH] Nouveau fichier --- .../telephonie.commercial.class.php | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 htdocs/telephonie/telephonie.commercial.class.php diff --git a/htdocs/telephonie/telephonie.commercial.class.php b/htdocs/telephonie/telephonie.commercial.class.php new file mode 100644 index 00000000000..360372ffd0d --- /dev/null +++ b/htdocs/telephonie/telephonie.commercial.class.php @@ -0,0 +1,115 @@ + + * + * 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. + * + * $Id$ + * $Source$ + * + */ + +class CommercialTelephonie { + var $db; + var $id; + + /** + * Créateur + * + * + */ + function CommercialTelephonie($DB, $id=0) + { + $this->db = $DB; + $this->id = $id; + + return 0; + } + /** + * + * + */ + function create() + { + $error = 0; + + if (strlen(trim($this->nom)) == 0) + { + $this->error_string["nom"] = "Valeur manquante"; + $error++; + } + if (strlen(trim($this->prenom)) == 0) + { + $this->error_string["prenom"] = "Valeur manquante"; + $error++; + } + + + if ($error == 0) + { + + $nuser = new User($this->db); + $nuser->nom = $this->nom; + $nuser->prenom = $this->prenom; + $nuser->admin = 0; + $nuser->email = ''; + $nuser->login = substr($this->nom,0,3).substr($this->prenom,0,3); + + $uid = $nuser->create(); + + if ($uid > 0) + { + $nuser->SetInGroup(TELEPHONIE_GROUPE_COMMERCIAUX_ID); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_distributeur_commerciaux "; + $sql .= " (fk_distributeur, fk_user)"; + + $sql .= " VALUES ('".$this->distri."','$uid')"; + + + if ($this->db->query($sql)) + { + + } + else + { + dolibarr_syslog("DistributeurTelephonie::Create"); + $this->error_string["prenom"] = "Erreur SQL : $sql"; + $this->error_string["nom"] = $this->db->error(); + $error++; + } + + } + else + { + $this->error_string["prenom"] = "Erreur création user"; + $this->error_string["nom"] = $user->error(); + $error++; + } + + } + else + { + + } + + return $error; + + } + + + + +} +?>