Massive update

This commit is contained in:
Rodolphe Quiedeville 2002-04-30 10:51:35 +00:00
parent 6c4baadf7a
commit c83142f484
6 changed files with 550 additions and 0 deletions

82
htdocs/contact.class.php3 Normal file
View File

@ -0,0 +1,82 @@
<?PHP
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
* Classe Company
*
* 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.
*
*/
class Contact {
var $bs;
var $db;
var $id;
var $fullname;
var $nom;
var $prenom;
var $code;
var $email;
Function Contact($DB, $id=0) {
$this->db = $DB;
$this->id = $id;
return 1;
}
/*
*
*
*
*/
Function fetch($id) {
$sql = "SELECT c.idp, c.idp, c.name, c.firstname";
$sql .= " FROM socpeople as c";
$sql .= " WHERE c.idp = $id";
$result = $this->db->query($sql);
if ($result) {
if ($this->db->num_rows()) {
$obj = $this->db->fetch_object($result , 0);
$this->id = $obj->idp;
$this->nom = $obj->name;
$this->prenom = $obj->firstname;
$this->fullname = $this->prenom . ' ' . $this->nom;
$this->code = $obj->code;
$this->email = $obj->email;
}
$this->db->free();
} else {
print $this->db->error();
}
}
}
/*
* $Id$
* $Source$
*/
?>

41
htdocs/info.php3 Normal file
View File

@ -0,0 +1,41 @@
<?PHP
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
*
* 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.
*
*/
require("./pre.inc.php3");
llxHeader();
print '<table border="1" cellpadding="3" cellspacing="0">';
print '<tr><td colspan="2">Database</td></tr>';
print '<tr><td>host</td><td>' . $conf->db->host . '</td></tr>';
print '<tr><td>user</td><td>' . $conf->db->user . '</td></tr>';
print '<tr><td>pass</td><td>' . $conf->db->pass . '</td></tr>';
print '<tr><td>Database name</td><td>' . $conf->db->name . '</td></tr>';
print '</table>';
$db = new Db();
llxFooter();
?>

23
htdocs/phpinfo.php3 Normal file
View File

@ -0,0 +1,23 @@
<?PHP
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
*
* 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.
*
*/
phpinfo();
?>

164
htdocs/soc.php3 Normal file
View File

@ -0,0 +1,164 @@
<?PHP
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
*
* 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.
*
*/
require("pre.inc.php3");
require("./societe.class.php3");
llxHeader();
$db = new Db();
if ($sortorder == "") {
$sortfield="lower(s.nom)";
$sortorder="ASC";
}
if ($page == -1) { $page = 0 ; }
$limit = 26;
$offset = $limit * $page ;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($action == 'add') {
$soc = new Societe($db);
$soc->nom = $nom;
$soc->tel = $tel;
$soc->fax = $fax;
$soc->url = $url;
$soc->client = 1;
$socid = $soc->create();
}
if ($action == 'update') {
$soc = new Societe($db);
$soc->nom = $nom;
$soc->tel = $tel;
$soc->fax = $fax;
$soc->url = $url;
$soc->update($socid);
}
/*
*
*
*/
if ($action == 'create') {
print 'Nouvelle societe<br>';
print '<form action="soc.php3" method="post">';
print '<input type="hidden" name="action" value="add">';
print '<table>';
print '<tr><td>Nom</td><td><input type="text" name="nom"></td></tr>';
print '<tr><td>Adresse</td><td><textarea name="adresse" cols="30" rows="3" wrap="soft"></textarea></td></tr>';
print '<tr><td>CP</td><td><input size="6" type="text" name="cp">&nbsp;';
print 'Ville&nbsp;<input type="text" name="ville"></td></tr>';
print '<tr><td>Tel</td><td><input type="text" name="tel"></td></tr>';
print '<tr><td>Fax</td><td><input type="text" name="fax"></td></tr>';
print '<tr><td>Web</td><td><input type="text" name="url"></td></tr>';
print '<tr><td>Siren</td><td><input type="text" name="siren"></td></tr>';
print '<tr><td>Type</td><td><select name="type">';
print '</select>';
print '<tr><td>Effectif</td><td><select name="effectif">';
print '</select>';
print '</td></tr>';
print '<tr><td colspan="2"><input type="submit"></td></tr>';
print '</table>';
print '</form>';
} elseif ($action == 'edit') {
print 'Edition de la société<br>';
$soc = new Societe($db);
$soc->id = $socid;
$soc->fetch();
print '<form action="soc.php3?socid='.$socid.'" method="post">';
print '<input type="hidden" name="action" value="update">';
print '<table>';
print '<tr><td>Nom</td><td><input type="text" name="nom" value="'.$soc->nom.'"></td></tr>';
print '<tr><td>Adresse</td><td><textarea name="adresse" cols="30" rows="3" wrap="soft"></textarea></td></tr>';
print '<tr><td>CP</td><td><input size="6" type="text" name="cp">&nbsp;';
print 'Ville&nbsp;<input type="text" name="ville"></td></tr>';
print '<tr><td>Tel</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td></tr>';
print '<tr><td>Fax</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
print '<tr><td>Web</td><td><input type="text" name="url" value="'.$soc->url.'"></td></tr>';
print '<tr><td>Siren</td><td><input type="text" name="siren"></td></tr>';
print '<tr><td>Type</td><td><select name="type">';
print '</select>';
print '<tr><td>Effectif</td><td><select name="effectif">';
print '</select>';
print '</td></tr>';
print '<tr><td colspan="2"><input type="submit" value="Mettre a jour"></td></tr>';
print '</table>';
print '</form>';
} else {
$soc = new Societe($db);
$soc->id = $socid;
$soc->fetch();
print "[<a href=\"soc.php3?socid=$socid&action=edit\">Editer</a>]";
print '<table>';
print '<tr><td>Nom</td><td>'.$soc->nom.'</td></tr>';
print '<tr><td>Adresse</td><td><textarea name="adresse" cols="30" rows="3" wrap="soft"></textarea></td></tr>';
print '<tr><td>CP</td><td><input size="6" type="text" name="cp">&nbsp;';
print 'Ville&nbsp;<input type="text" name="ville"></td></tr>';
print '<tr><td>Tel</td><td>'.$soc->tel.'</td></tr>';
print '<tr><td>Fax</td><td>'.$soc->fax.'</td></tr>';
print '<tr><td>Web</td><td>'.$soc->url.'</td></tr>';
print '<tr><td>Siren</td><td><input type="text" name="siren"></td></tr>';
print '<tr><td>Type</td><td><select name="type">';
print '</select>';
print '<tr><td>Effectif</td><td><select name="effectif">';
print '</select>';
print '</td></tr>';
print '</table>';
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

153
htdocs/societe.class.php3 Normal file
View File

@ -0,0 +1,153 @@
<?PHP
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
* Classe Company
*
* 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.
*
*/
class Societe {
var $bs;
var $db;
var $id;
var $nom;
var $tel;
var $fax;
var $url;
var $client;
Function Societe($DB, $id=0) {
global $config;
$this->db = $DB;
$this->id = $id;
return 1;
}
Function create() {
$sql = "INSERT INTO societe (nom, datec, datea, client) ";
$sql .= " VALUES ('".trim($this->nom)."', now(), now(), $this->client)";
if ($this->db->query($sql) ) {
$id = $this->db->last_insert_id();
$this->update($id);
return $id;
}
}
/*
*
*
*
*/
Function update($id) {
$sql = "UPDATE societe ";
$sql .= " SET nom = '" . trim($this->nom) ."'";
$sql .= ",cp = '" . trim($this->cp) ."'";
$sql .= ",ville = '" . trim($this->ville) ."'";
$sql .= ",tel = '" . trim($this->tel) ."'";
$sql .= ",fax = '" . trim($this->fax) ."'";
$sql .= ",url = '" . trim($this->url) ."'";
$sql .= ",siren = '" . trim($this->siren) ."'";
$sql .= " WHERE idp = " . $id;
$this->db->query($sql);
}
/*
*
*
*
*/
Function fetch() {
$sql = "SELECT s.idp, s.nom,".$this->db->pdate("s.datec")." as dc,".$this->db->pdate("s.datem")." as dm,".$this->db->pdate("s.datea")." as da, s.intern, s.cjn, ";
$sql .= " s.c_nom, s.c_prenom, s.c_tel, s.c_mail, s.tel, s.fax, s.fplus, s.cjn, s.viewed, st.libelle as stcomm, s.fk_stcomm, s.url,s.cp,s.ville, s.note";
$sql .= " FROM societe as s, c_stcomm as st ";
$sql .= " WHERE s.fk_stcomm = st.id";
$sql .= " AND s.idp = ".$this->id;
$result = $this->db->query($sql);
if ($result) {
if ($this->db->num_rows()) {
$obj = $this->db->fetch_object($result , 0);
$this->nom = $obj->nom;
$this->tel = $obj->tel;
$this->fax = $obj->fax;
$this->url = $obj->url;
$this->cp = $obj->cp;
$this->ville = $obj->ville;
$this->cjn = $obj->cjn;
$this->viewed = $obj->viewed;
$this->stcomm = $obj->stcomm;
$this->c_nom = $obj->c_nom;
$this->c_prenom = $obj->c_prenom;
$this->c_tel = $obj->c_tel;
$this->c_fax = $obj->c_fax;
}
$this->db->free();
}
}
/*
*
*
*
*/
Function get_nom($id) {
$sql = "SELECT nom FROM societe WHERE idp=$id;";
$result = $this->db->query($sql);
if ($result) {
if ($this->db->num_rows()) {
$obj = $this->db->fetch_object($result , 0);
$this->nom = $obj->nom;
}
$this->db->free();
}
}
}
/*
* $Id$
* $Source$
*/
?>

87
htdocs/user.class.php3 Normal file
View File

@ -0,0 +1,87 @@
<?PHP
/* Copyright (c) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* $Id$
* $Source$
*
* 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.
*
*/
class User {
var $bs;
var $db;
var $id;
var $fullname;
var $nom;
var $prenom;
var $code;
var $email;
var $comm;
var $compta;
Function User($DB, $id=0) {
$this->db = $DB;
$this->id = $id;
return 1;
}
/*
*
*
*
*/
Function fetch($login) {
$sql = "SELECT u.rowid, u.name, u.firstname, u.email, u.code, u.module_comm, u.module_compta";
$sql .= " FROM llx_user as u";
$sql .= " WHERE u.login = '$login'";
$result = $this->db->query($sql);
if ($result) {
if ($this->db->num_rows()) {
$obj = $this->db->fetch_object($result , 0);
$this->id = $obj->rowid;
$this->nom = $obj->name;
$this->prenom = $obj->firstname;
$this->fullname = $this->prenom . ' ' . $this->nom;
$this->code = $obj->code;
$this->email = $obj->email;
$this->comm = $obj->module_comm;
$this->compta = $obj->module_compta;
}
$this->db->free();
} else {
print $this->db->error();
}
}
}
/*
* $Id$
* $Source$
*/
?>