*** empty log message ***
This commit is contained in:
parent
5b6a693c5b
commit
65f5046cb4
@ -25,31 +25,29 @@ require("pre.inc.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') {
|
||||
if ($action == 'add')
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
$soc->nom = $nom;
|
||||
|
||||
$soc->tel = $tel;
|
||||
$soc->fax = $fax;
|
||||
$soc->url = $url;
|
||||
$soc->adresse = $adresse;
|
||||
$soc->cp = $cp;
|
||||
$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();
|
||||
}
|
||||
|
||||
if ($action == 'update') {
|
||||
if ($action == 'update')
|
||||
{
|
||||
$soc = new Societe($db);
|
||||
|
||||
$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 '<form action="soc.php3" method="post">';
|
||||
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 '<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 '</table>';
|
||||
print '</form>';
|
||||
} elseif ($action == 'edit') {
|
||||
}
|
||||
elseif ($action == 'edit')
|
||||
{
|
||||
print '<div class="titre">Edition de la société</div><br>';
|
||||
|
||||
$soc = new Societe($db);
|
||||
@ -165,16 +167,20 @@ if ($action == 'create') {
|
||||
$docdir = $GLOBALS["DOCUMENT_ROOT"] . "/document/societe/$socid";
|
||||
$url = "/document/societe/$socid";
|
||||
|
||||
if (file_exists ($docdir)) {
|
||||
print "<p>$docdir<p>";
|
||||
print '<a href="'.$url.'">Documents</a>';
|
||||
} else {
|
||||
|
||||
mkdir ("$docdir", 2775);
|
||||
if (file_exists ($docdir)) {
|
||||
if (file_exists ($docdir))
|
||||
{
|
||||
print "<p>$docdir<p>";
|
||||
print '<a href="'.$url.'">Documents</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
mkdir ("$docdir", 2775);
|
||||
if (file_exists ($docdir))
|
||||
{
|
||||
print '<a href="'.$url.'">Documents</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -40,7 +40,7 @@ class Societe {
|
||||
|
||||
$this->db = $DB;
|
||||
$this->id = $id;
|
||||
|
||||
$this->fournisseur = 0;
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
@ -50,8 +50,10 @@ class Societe {
|
||||
*/
|
||||
Function create() {
|
||||
|
||||
print $this->url;
|
||||
|
||||
$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) ) {
|
||||
$id = $this->db->last_insert_id();
|
||||
@ -71,9 +73,10 @@ class Societe {
|
||||
* Force au statut de fournisseur si ce n'est pas un client
|
||||
* sinon l'entreprise disparait de toutes les listes
|
||||
*/
|
||||
if ($this->client == 0 ) {
|
||||
$this->fournisseur = 1;
|
||||
}
|
||||
if ($this->client == 0 )
|
||||
{
|
||||
$this->fournisseur = 1;
|
||||
}
|
||||
|
||||
$sql = "UPDATE societe ";
|
||||
$sql .= " SET nom = '" . trim($this->nom) ."'";
|
||||
@ -86,9 +89,12 @@ class Societe {
|
||||
$sql .= ",siren = '" . trim($this->siren) ."'";
|
||||
$sql .= ",client = " . $this->client ;
|
||||
$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() {
|
||||
$sql = "SELECT nom FROM societe WHERE idp = $this->id";
|
||||
if ( $this->db->query( $sql) ) {
|
||||
if ( $this->db->num_rows() ) {
|
||||
$nom = $this->db->result(0,0);
|
||||
$this->db->free();
|
||||
Function attribute_prefix()
|
||||
{
|
||||
$sql = "SELECT nom FROM societe WHERE idp = $this->id";
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
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'";
|
||||
if ( $this->db->query( $sql) ) {
|
||||
if ( $this->db->result(0, 0) ) {
|
||||
$this->db->free();
|
||||
} else {
|
||||
$this->db->free();
|
||||
$sql = "UPDATE societe set prefix_comm='$prefix' WHERE idp=$this->id";
|
||||
|
||||
if ( $this->db->query( $sql) ) {
|
||||
|
||||
} else {
|
||||
print $this->db->error();
|
||||
}
|
||||
$sql = "SELECT count(*) FROM societe WHERE prefix_comm = '$prefix'";
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
if ( $this->db->result(0, 0) )
|
||||
{
|
||||
$this->db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->free();
|
||||
|
||||
$sql = "UPDATE societe set prefix_comm='$prefix' WHERE idp=$this->id";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print $this->db->error();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print $this->db->error();
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
}
|
||||
return $prefix;
|
||||
}
|
||||
return $prefix;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
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;
|
||||
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();
|
||||
}
|
||||
$this->db->free();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user