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"]; $action=$_POST["action"];
// Load array of all events supported by triggers // Get list of triggers available
// TODO add function
$sql = "SELECT a.rowid, a.code, a.label, a.elementtype"; $sql = "SELECT a.rowid, a.code, a.label, a.elementtype";
$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
$sql.= " ORDER BY a.rang ASC"; $sql.= " ORDER BY a.rang ASC";

View File

@ -276,7 +276,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $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; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";

View File

@ -132,7 +132,8 @@ if (is_resource($handle))
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $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; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";

View File

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

View File

@ -355,7 +355,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $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; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";

View File

@ -276,7 +276,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $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; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";

View File

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

View File

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

View File

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

View File

@ -227,7 +227,8 @@ if (is_resource($handle))
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $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; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";

View File

@ -309,7 +309,8 @@ foreach ($conf->file->dol_document_root as $dirroot)
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $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; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";

View File

@ -259,7 +259,8 @@ foreach ($arrayhandler as $key => $module)
// Show example of numbering module // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $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; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";

View File

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

View File

@ -46,20 +46,20 @@ class Notify
/** /**
* Constructor * 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 * Return message that say how many notification will occurs on requested event.
* un evenement pour affichage dans texte de confirmation evenement * This is to show confirmation messages before event is done.
* *
* @param action Id of action in llx_c_action_trigger * @param string $action Id of action in llx_c_action_trigger
* @param socid Id of third party * @param int $socid Id of third party
* @return string Message * @return string Message
*/ */
function confirmMessage($action,$socid) function confirmMessage($action,$socid)
@ -75,10 +75,11 @@ class Notify
} }
/** /**
* \brief Return number of notifications activated for action code and third party * 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 * @param string $action Code of action in llx_c_action_trigger (new usage) or Id of action in llx_c_action_trigger (old usage)
* \return int <0 si ko, sinon nombre de notifications definies * @param int $socid Id of third party
* @return int <0 if KO, nb of notifications sent if OK
*/ */
function countDefinedNotifications($action,$socid) function countDefinedNotifications($action,$socid)
{ {

View File

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

View File

@ -91,7 +91,7 @@ class mod_propale_saphir extends ModeleNumRefPropales
if (! $numExample) if (! $numExample)
{ {
$numExample = $langs->trans('NotConfigured'); $numExample = 'NotConfigured';
} }
return $numExample; 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 DetailPosition=Sort number to define menu position
PersonalizedMenusNotSupported=Personalized menus not supported PersonalizedMenusNotSupported=Personalized menus not supported
AllMenus=All AllMenus=All
NotConfigured=Not configured NotConfigured=Numbering module not configured
Setup=Setup Setup=Setup
Activation=Activation Activation=Activation
Active=Active 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 DetailPosition= Numéro d'ordre déterminant la position du menu
PersonalizedMenusNotSupported= Menus personnalisés non gérés PersonalizedMenusNotSupported= Menus personnalisés non gérés
AllMenus= Tous AllMenus= Tous
NotConfigured= Non configuré NotConfigured=Module numérotation non configuré
Setup= Configuration Setup= Configuration
Activation= Activation Activation= Activation
Active= Actif Active= Actif