Better error management

This commit is contained in:
Laurent Destailleur 2009-09-10 21:47:22 +00:00
parent cb3f178dbc
commit 7d1d9414c6
5 changed files with 35 additions and 9 deletions

View File

@ -512,9 +512,15 @@ class Commande extends CommonObject
// Clean parameters
$this->brouillon = 1; // On positionne en mode brouillon la commande
dol_syslog("Commande::create");
dol_syslog("Commande::create user=".$user->id);
// Check parameters
if (empty($this->ref))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
dol_syslog("Commande::create ".$this->error, LOG_ERR);
return -1;
}
if (! empty($conf->global->COMMANDE_REQUIRE_SOURCE) && $this->source < 0)
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source"));

View File

@ -147,6 +147,14 @@ class Facture extends CommonObject
dol_syslog("Facture::Create user=".$user->id);
// Check parameters
if (empty($this->ref))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
dol_syslog("Facture::create ".$this->error, LOG_ERR);
return -1;
}
$soc = new Societe($this->db);
$soc->fetch($this->socid);

View File

@ -518,13 +518,22 @@ class Propal extends CommonObject
{
global $langs,$conf,$mysoc;
// on verifie si la ref n'est pas utilisee
$soc = new Societe($this->db);
$soc->fetch($this->socid);
$this->verifyNumRef($soc);
// Clean parameters
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
dol_syslog("Propal::Create");
// Check parameters
if (empty($this->ref))
{
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Ref"));
dol_syslog("Facture::create ".$this->error, LOG_ERR);
return -1;
}
$soc = new Societe($this->db);
$soc->fetch($this->socid);
$this->verifyNumRef($soc); // Check ref is not yet used
$this->db->begin();

View File

@ -469,9 +469,9 @@ class User extends CommonObject
/**
\brief Charge dans l'objet user, la liste des permissions auxquelles l'utilisateur a droit
\param moduletag nom du module dont il faut recuperer les droits ('' par defaut signifie tous les droits)
*/
* \brief Charge dans l'objet user, la liste des permissions auxquelles l'utilisateur a droit
* \param moduletag nom du module dont il faut recuperer les droits ('' par defaut signifie tous les droits)
*/
function getrights($moduletag='')
{
global $conf;

View File

@ -11,3 +11,6 @@
delete from llx_facture where facnumber = '(PROV)';
delete from llx_commande where ref = '(PROV)';
delete from llx_propal where ref = '(PROV)';
delete from llx_facture where facnumber = '';
delete from llx_commande where ref = '';
delete from llx_propal where ref = '';