Qual: Better error managment on numbering setup

This commit is contained in:
Laurent Destailleur 2011-11-06 15:12:18 +01:00
parent c4e9e9d17a
commit 8d46ae1d35
18 changed files with 74 additions and 69 deletions

View File

@ -35,8 +35,7 @@ $langs->load("other");
$action=$_POST["action"];
// Load array of all events supported by triggers
// TODO add function
// Get list of triggers available
$sql = "SELECT a.rowid, a.code, a.label, a.elementtype";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql.= " ORDER BY a.rang ASC";
@ -81,7 +80,7 @@ if ($action == "save" && empty($_POST["cancel"]))
else $res = dolibarr_del_const($db,$param,$conf->entity);
if (! $res > 0) $error++;
}
if (! $error)
{
$db->commit();

View File

@ -276,7 +276,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp);
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -132,7 +132,8 @@ if (is_resource($handle))
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp);
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -384,11 +384,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp))
{
$langs->load('errors');
print $langs->trans($tmp);
}
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -50,7 +50,7 @@ if ($action == 'updateMask')
$maskcredit=GETPOST("maskcredit");
if ($maskconstinvoice) $res = dolibarr_set_const($db,$maskconstinvoice,$maskinvoice,'chaine',0,'',$conf->entity);
if ($maskconstcredit) $res = dolibarr_set_const($db,$maskconstcredit,$maskcredit,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
@ -127,7 +127,7 @@ if ($action == 'set')
{
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$type='invoice';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
@ -158,7 +158,7 @@ if ($action == 'setdoc')
{
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$db->begin();
if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
@ -206,10 +206,10 @@ if ($action == 'setribchq')
{
$rib = GETPOST("rib");
$chq = GETPOST("chq");
$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$rib,'chaine',0,'',$conf->entity);
$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$chq,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
@ -225,9 +225,9 @@ if ($action == 'setribchq')
if ($action == 'set_FACTURE_DRAFT_WATERMARK')
{
$draft = GETPOST("FACTURE_DRAFT_WATERMARK");
$res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
@ -243,9 +243,9 @@ if ($action == 'set_FACTURE_DRAFT_WATERMARK')
if ($action == 'set_FACTURE_FREE_TEXT')
{
$free = GETPOST("FACTURE_FREE_TEXT");
$res = dolibarr_set_const($db, "FACTURE_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
@ -261,9 +261,9 @@ if ($action == 'set_FACTURE_FREE_TEXT')
if ($action == 'setforcedate')
{
$forcedate = GETPOST("forcedate");
$res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION",$forcedate,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
@ -355,7 +355,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp);
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -276,7 +276,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp);
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -55,7 +55,7 @@ if ($action == 'updateMask')
$maskconstorder=$_POST['maskconstorder'];
$maskorder=$_POST['maskorder'];
if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
@ -226,7 +226,7 @@ if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
{
$free = GETPOST("SUPPLIER_INVOICE_FREE_TEXT");
$res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
@ -301,13 +301,10 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp))
{
$langs->load("errors");
print $langs->trans($tmp);
}
else print $tmp;
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";
print '<td align="center">';

View File

@ -270,11 +270,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp))
{
$langs->load("errors");
print $langs->trans($tmp);
}
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -190,6 +190,7 @@ if ($conf->global->MAIN_MODULE_NOTIFICATION)
$db->free($resql);
}
// Get list of triggers for module withdraw
$sql = "SELECT rowid, code, label";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
$sql.= " WHERE elementtype = 'withdraw'";

View File

@ -48,7 +48,7 @@ if ($action == 'updateMask')
$maskconstproject=GETPOST("maskconstproject");
$maskproject=GETPOST("maskproject");
if ($maskconstproject) $res = dolibarr_set_const($db,$maskconstproject,$maskproject,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
@ -100,7 +100,7 @@ if ($action == 'set')
{
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$type='project';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
@ -127,7 +127,7 @@ if ($action == 'setdoc')
{
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$db->begin();
if (dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
@ -227,7 +227,8 @@ if (is_resource($handle))
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp);
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -309,7 +309,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp);
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -259,7 +259,8 @@ foreach ($arrayhandler as $key => $module)
// Show example of numbering module
print '<td nowrap="nowrap">';
$tmp=$module->getExample();
if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp);
if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>'."\n";

View File

@ -1139,9 +1139,10 @@ class Propal extends CommonObject
}
/**
* \brief Passe au statut valider une propale
* \param user Objet utilisateur qui valide
* \return int <0 si ko, >=0 si ok
* Set status to validated
*
* @param User $user Object user that validate
* @return int <0 if KO, >=0 if OK
*/
function valid($user, $notrigger=0)
{
@ -1157,6 +1158,7 @@ class Propal extends CommonObject
$sql.= " SET fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
dol_syslog(get_class($this).'::valid sql='.$sql);
if ($this->db->query($sql))
{
if (! $notrigger)
@ -1194,10 +1196,11 @@ class Propal extends CommonObject
/**
* \brief Define proposal date
* \param user Object user that modify
* \param date Date
* \return int <0 if KO, >0 if OK
* Define proposal date
*
* @param User $user Object user that modify
* @param timestamp $date Date
* @return int <0 if KO, >0 if OK
*/
function set_date($user, $date)
{
@ -1205,6 +1208,8 @@ class Propal extends CommonObject
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = ".$this->db->idate($date);
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
dol_syslog(get_class($this)."::set_date sql=".$sql);
if ($this->db->query($sql) )
{
$this->date = $date;
@ -1213,8 +1218,8 @@ class Propal extends CommonObject
}
else
{
$this->error=$this->db->error();
dol_syslog("Propal::set_date Erreur SQL".$this->error, LOG_ERR);
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::set_date ".$this->error, LOG_ERR);
return -1;
}
}
@ -2298,7 +2303,8 @@ class Propal extends CommonObject
}
else
{
print $langs->trans("Error")." ".$langs->trans("Error_PROPALE_ADDON_NotDefined");
$langs->load("errors");
print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete");
return "";
}
}

View File

@ -46,21 +46,21 @@ class Notify
/**
* Constructor
*
* @param DoliDB $DB Database handler
* @param DoliDB $db Database handler
*/
function Notify($DB)
function Notify($db)
{
$this->db = $DB ;
$this->db = $db;
}
/**
* Renvoie le message signalant les notifications qui auront lieu sur
* un evenement pour affichage dans texte de confirmation evenement
* Return message that say how many notification will occurs on requested event.
* This is to show confirmation messages before event is done.
*
* @param action Id of action in llx_c_action_trigger
* @param socid Id of third party
* @return string Message
* @param string $action Id of action in llx_c_action_trigger
* @param int $socid Id of third party
* @return string Message
*/
function confirmMessage($action,$socid)
{
@ -75,10 +75,11 @@ class Notify
}
/**
* \brief Return number of notifications activated for action code and third party
* \param action Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* \param socid Id of third party
* \return int <0 si ko, sinon nombre de notifications definies
* Return number of notifications activated for action code and third party
*
* @param string $action Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* @param int $socid Id of third party
* @return int <0 if KO, nb of notifications sent if OK
*/
function countDefinedNotifications($action,$socid)
{

View File

@ -98,7 +98,7 @@ class mod_facture_mercure extends ModeleNumRefFactures
if (! $numExample)
{
$numExample = $langs->trans('NotConfigured');
$numExample = 'NotConfigured';
}
return $numExample;
}

View File

@ -91,7 +91,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
if (! $numExample)
{
$numExample = $langs->trans('NotConfigured');
$numExample = 'NotConfigured';
}
return $numExample;
}

View File

@ -82,7 +82,7 @@ DetailMenuIdParent=ID of parent menu (0 for a top menu)
DetailPosition=Sort number to define menu position
PersonalizedMenusNotSupported=Personalized menus not supported
AllMenus=All
NotConfigured=Not configured
NotConfigured=Numbering module not configured
Setup=Setup
Activation=Activation
Active=Active

View File

@ -83,7 +83,7 @@ DetailMenuIdParent= Id du menu parent (0 pour un menu du haut)
DetailPosition= Numéro d'ordre déterminant la position du menu
PersonalizedMenusNotSupported= Menus personnalisés non gérés
AllMenus= Tous
NotConfigured= Non configuré
NotConfigured=Module numérotation non configuré
Setup= Configuration
Activation= Activation
Active= Actif