*** empty log message ***

This commit is contained in:
Rodolphe Quiedeville 2002-12-12 21:04:06 +00:00
parent 5b6a693c5b
commit 65f5046cb4
2 changed files with 104 additions and 74 deletions

View File

@ -25,31 +25,29 @@ require("pre.inc.php3");
llxHeader(); llxHeader();
$db = new Db(); $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') { if ($action == 'add')
{
$soc = new Societe($db); $soc = new Societe($db);
$soc->nom = $nom; $soc->nom = $nom;
$soc->tel = $tel; $soc->adresse = $adresse;
$soc->fax = $fax; $soc->cp = $cp;
$soc->url = $url; $soc->ville = $ville;
$soc->client = 1; $soc->tel = $tel;
$soc->fax = $fax;
$soc->url = $url;
$soc->siren = $siren;
$soc->client = 1;
$soc->fournisseur = $fournisseur;
$socid = $soc->create(); $socid = $soc->create();
} }
if ($action == 'update') { if ($action == 'update')
{
$soc = new Societe($db); $soc = new Societe($db);
$soc->nom = $nom; $soc->nom = $nom;
@ -73,10 +71,12 @@ if ($action == 'update') {
* *
*/ */
if ($action == 'create') { if ($action == 'create')
{
print '<div class="titre">Nouveau client</div><br>'; print '<div class="titre">Nouveau client</div><br>';
print '<form action="soc.php3" method="post">'; print '<form action="soc.php3" method="post">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="fournisseur" value="0">';
print '<table border="1" cellpadding="3" cellspacing="0">'; print '<table border="1" cellpadding="3" cellspacing="0">';
print '<tr><td>Nom</td><td><input type="text" name="nom"></td></tr>'; print '<tr><td>Nom</td><td><input type="text" name="nom"></td></tr>';
@ -101,7 +101,9 @@ if ($action == 'create') {
print '<tr><td colspan="2" align="center"><input type="submit" value="Ajouter"></td></tr>'; print '<tr><td colspan="2" align="center"><input type="submit" value="Ajouter"></td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} elseif ($action == 'edit') { }
elseif ($action == 'edit')
{
print '<div class="titre">Edition de la société</div><br>'; print '<div class="titre">Edition de la société</div><br>';
$soc = new Societe($db); $soc = new Societe($db);
@ -165,16 +167,20 @@ if ($action == 'create') {
$docdir = $GLOBALS["DOCUMENT_ROOT"] . "/document/societe/$socid"; $docdir = $GLOBALS["DOCUMENT_ROOT"] . "/document/societe/$socid";
$url = "/document/societe/$socid"; $url = "/document/societe/$socid";
if (file_exists ($docdir)) { if (file_exists ($docdir))
print "<p>$docdir<p>"; {
print '<a href="'.$url.'">Documents</a>'; print "<p>$docdir<p>";
} else {
mkdir ("$docdir", 2775);
if (file_exists ($docdir)) {
print '<a href="'.$url.'">Documents</a>'; print '<a href="'.$url.'">Documents</a>';
} }
} else
{
mkdir ("$docdir", 2775);
if (file_exists ($docdir))
{
print '<a href="'.$url.'">Documents</a>';
}
}
} }
$db->close(); $db->close();

View File

@ -40,7 +40,7 @@ class Societe {
$this->db = $DB; $this->db = $DB;
$this->id = $id; $this->id = $id;
$this->fournisseur = 0;
return 1; return 1;
} }
/* /*
@ -50,8 +50,10 @@ class Societe {
*/ */
Function create() { Function create() {
print $this->url;
$sql = "INSERT INTO societe (nom, datec, datea, client) "; $sql = "INSERT INTO societe (nom, datec, datea, client) ";
$sql .= " VALUES ('".trim($this->nom)."', now(), now(), $this->client)"; $sql .= " VALUES ('".trim($this->nom)."', now(), now(), $this->client);";
if ($this->db->query($sql) ) { if ($this->db->query($sql) ) {
$id = $this->db->last_insert_id(); $id = $this->db->last_insert_id();
@ -71,9 +73,10 @@ class Societe {
* Force au statut de fournisseur si ce n'est pas un client * Force au statut de fournisseur si ce n'est pas un client
* sinon l'entreprise disparait de toutes les listes * sinon l'entreprise disparait de toutes les listes
*/ */
if ($this->client == 0 ) { if ($this->client == 0 )
$this->fournisseur = 1; {
} $this->fournisseur = 1;
}
$sql = "UPDATE societe "; $sql = "UPDATE societe ";
$sql .= " SET nom = '" . trim($this->nom) ."'"; $sql .= " SET nom = '" . trim($this->nom) ."'";
@ -86,9 +89,12 @@ class Societe {
$sql .= ",siren = '" . trim($this->siren) ."'"; $sql .= ",siren = '" . trim($this->siren) ."'";
$sql .= ",client = " . $this->client ; $sql .= ",client = " . $this->client ;
$sql .= ",fournisseur = " . $this->fournisseur ; $sql .= ",fournisseur = " . $this->fournisseur ;
$sql .= " WHERE idp = " . $id; $sql .= " WHERE idp = " . $id .";";
$this->db->query($sql); if (! $this->db->query($sql))
{
print $this->db->error();
}
} }
/* /*
* *
@ -141,59 +147,77 @@ class Societe {
* *
*/ */
Function attribute_prefix() { Function attribute_prefix()
$sql = "SELECT nom FROM societe WHERE idp = $this->id"; {
if ( $this->db->query( $sql) ) { $sql = "SELECT nom FROM societe WHERE idp = $this->id";
if ( $this->db->num_rows() ) { if ( $this->db->query( $sql) )
$nom = $this->db->result(0,0); {
$this->db->free(); if ( $this->db->num_rows() )
{
$nom = $this->db->result(0,0);
$this->db->free();
$prefix = strtoupper(substr($nom, 0, 2)); $prefix = strtoupper(substr($nom, 0, 2));
$sql = "SELECT count(*) FROM societe WHERE prefix_comm = '$prefix'"; $sql = "SELECT count(*) FROM societe WHERE prefix_comm = '$prefix'";
if ( $this->db->query( $sql) ) { if ( $this->db->query( $sql) )
if ( $this->db->result(0, 0) ) { {
$this->db->free(); if ( $this->db->result(0, 0) )
} else { {
$this->db->free(); $this->db->free();
$sql = "UPDATE societe set prefix_comm='$prefix' WHERE idp=$this->id"; }
else
{
$this->db->free();
if ( $this->db->query( $sql) ) { $sql = "UPDATE societe set prefix_comm='$prefix' WHERE idp=$this->id";
} else { if ( $this->db->query( $sql) )
print $this->db->error(); {
}
}
else
{
print $this->db->error();
}
}
}
else
{
print $this->db->error();
}
}
} }
} else { else
print $this->db->error(); {
} print $this->db->error();
} }
} else { return $prefix;
print $this->db->error();
} }
return $prefix;
}
/* /*
* *
* *
* *
*/ */
Function get_nom($id) { Function get_nom($id)
{
$sql = "SELECT nom FROM societe WHERE idp=$id;"; $sql = "SELECT nom FROM societe WHERE idp=$id;";
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result)
if ($this->db->num_rows()) { {
$obj = $this->db->fetch_object($result , 0); if ($this->db->num_rows())
{
$obj = $this->db->fetch_object($result , 0);
$this->nom = $obj->nom; $this->nom = $obj->nom;
}
$this->db->free();
} }
$this->db->free();
}
} }