Optimisation du code
This commit is contained in:
parent
3a36d707df
commit
479639c9e3
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?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
|
* 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
|
* 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)))
|
if (strlen(trim($this->numero)) && strlen(trim($this->intitule)))
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "SELECT count(*)";
|
$sql = "SELECT count(*)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."compta_compte_generaux ";
|
$sql .= " FROM ".MAIN_DB_PREFIX."compta_compte_generaux ";
|
||||||
$sql .= " WHERE numero = '" .trim($this->numero)."'";
|
$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)
|
if ($row[0] == 0)
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."compta_compte_generaux (date_creation, fk_user_author, numero,intitule)";
|
$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."')";
|
$sql .= " VALUES (now(),".$user->id.",'".$this->numero."','".$this->intitule."')";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ( $result )
|
if ( $resql )
|
||||||
{
|
{
|
||||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."compta_compte_generaux");
|
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."compta_compte_generaux");
|
||||||
|
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
return 0;
|
$result = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -2;
|
$result = -2;
|
||||||
|
dolibarr_syslog("ComptaCompte::Create Erreur $result lecture ID");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -1;
|
$result = -1;
|
||||||
|
dolibarr_syslog("ComptaCompte::Create Erreur $result INSERT Mysql");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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
|
else
|
||||||
{
|
{
|
||||||
return -4;
|
$result = -4;
|
||||||
|
dolibarr_syslog("ComptaCompte::Create Erreur $result Valeur Manquante");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -32,11 +32,8 @@
|
|||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
|
|
||||||
$langs->load("products");
|
|
||||||
|
|
||||||
$mesg = '';
|
$mesg = '';
|
||||||
|
|
||||||
|
|
||||||
if ($_POST["action"] == 'add' && $user->rights->compta->ventilation->parametrer)
|
if ($_POST["action"] == 'add' && $user->rights->compta->ventilation->parametrer)
|
||||||
{
|
{
|
||||||
$compte = new ComptaCompte($db);
|
$compte = new ComptaCompte($db);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user