Optimisation du code

This commit is contained in:
Rodolphe Quiedeville 2005-04-04 10:40:21 +00:00
parent 3a36d707df
commit 479639c9e3
2 changed files with 22 additions and 15 deletions

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2004-2005 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
@ -60,51 +60,61 @@ class ComptaCompte
{
if (strlen(trim($this->numero)) && strlen(trim($this->intitule)))
{
$sql = "SELECT count(*)";
$sql .= " FROM ".MAIN_DB_PREFIX."compta_compte_generaux ";
$sql .= " WHERE numero = '" .trim($this->numero)."'";
$result = $this->db->query($sql) ;
$resql = $this->db->query($sql) ;
if ( $result )
if ( $resql )
{
$row = $this->db->fetch_array();
$row = $this->db->fetch_array($resql);
if ($row[0] == 0)
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."compta_compte_generaux (date_creation, fk_user_author, numero,intitule)";
$sql .= " VALUES (now(),".$user->id.",'".$this->numero."','".$this->intitule."')";
$result = $this->db->query($sql);
if ( $result )
$resql = $this->db->query($sql);
if ( $resql )
{
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."compta_compte_generaux");
if ($id > 0)
{
$this->id = $id;
return 0;
$result = 0;
}
else
{
return -2;
$result = -2;
dolibarr_syslog("ComptaCompte::Create Erreur $result lecture ID");
}
}
else
{
return -1;
$result = -1;
dolibarr_syslog("ComptaCompte::Create Erreur $result INSERT Mysql");
}
}
else
{
return -3;
$result = -3;
dolibarr_syslog("ComptaCompte::Create Erreur $result SELECT Mysql");
}
}
else
{
$result = -5;
dolibarr_syslog("ComptaCompte::Create Erreur $result SELECT Mysql");
}
}
else
{
return -4;
$result = -4;
dolibarr_syslog("ComptaCompte::Create Erreur $result Valeur Manquante");
}
return $result;
}
}
?>

View File

@ -32,11 +32,8 @@
require("./pre.inc.php");
$langs->load("products");
$mesg = '';
if ($_POST["action"] == 'add' && $user->rights->compta->ventilation->parametrer)
{
$compte = new ComptaCompte($db);