From 8d46ae1d358ec112dab296935c6c44e9499ec7ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Nov 2011 15:12:18 +0100 Subject: [PATCH] Qual: Better error managment on numbering setup --- htdocs/admin/agenda.php | 5 ++-- htdocs/admin/commande.php | 3 ++- htdocs/admin/contract.php | 3 ++- htdocs/admin/expedition.php | 7 ++--- htdocs/admin/facture.php | 25 +++++++++--------- htdocs/admin/fichinter.php | 3 ++- htdocs/admin/fournisseur.php | 15 +++++------ htdocs/admin/livraison.php | 7 ++--- htdocs/admin/prelevement.php | 1 + htdocs/admin/project.php | 9 ++++--- htdocs/admin/propale.php | 3 ++- htdocs/admin/security.php | 3 ++- htdocs/comm/propal/class/propal.class.php | 26 ++++++++++++------- htdocs/core/class/notify.class.php | 25 +++++++++--------- .../modules/facture/mod_facture_mercure.php | 2 +- .../modules/propale/mod_propale_saphir.php | 2 +- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 2 +- 18 files changed, 74 insertions(+), 69 deletions(-) diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index 3d175a27d86..0274080510c 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -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(); diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index d5e71e6ade8..e84980069d3 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -276,7 +276,8 @@ foreach ($conf->file->dol_document_root as $dirroot) // Show example of numbering module print ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index a4ac55ac3e8..b6222c5b9fe 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -132,7 +132,8 @@ if (is_resource($handle)) // Show example of numbering module print ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 471b48f5226..5da12051d7e 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -384,11 +384,8 @@ foreach ($conf->file->dol_document_root as $dirroot) // Show example of numbering module print ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) - { - $langs->load('errors'); - print $langs->trans($tmp); - } + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index c2af5df07fc..8b0a87d06b3 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -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 ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 6ee36a8434f..42198d5af34 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -276,7 +276,8 @@ foreach ($conf->file->dol_document_root as $dirroot) // Show example of numbering module print ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index f22b81a3697..10fea69ecba 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -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 ''; - $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 '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; print ''."\n"; print ''; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 9577de2db81..33cb3bb057d 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -270,11 +270,8 @@ foreach ($conf->file->dol_document_root as $dirroot) // Show example of numbering module print ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) - { - $langs->load("errors"); - print $langs->trans($tmp); - } + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index aea33be39a3..a402ea2b82b 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -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'"; diff --git a/htdocs/admin/project.php b/htdocs/admin/project.php index 52a9df582ff..cea9e9ebecd 100644 --- a/htdocs/admin/project.php +++ b/htdocs/admin/project.php @@ -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 ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 9dfe9bf979a..c69c2f3f4fe 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -309,7 +309,8 @@ foreach ($conf->file->dol_document_root as $dirroot) // Show example of numbering module print ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 2d50dc77679..29e8533c8d9 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -259,7 +259,8 @@ foreach ($arrayhandler as $key => $module) // Show example of numbering module print ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 13724d1e66f..4a3d30f1bd2 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -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 ""; } } diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 314a6888b2e..18f1b35860a 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -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) { diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index a2402237dac..bfccd595ce6 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -98,7 +98,7 @@ class mod_facture_mercure extends ModeleNumRefFactures if (! $numExample) { - $numExample = $langs->trans('NotConfigured'); + $numExample = 'NotConfigured'; } return $numExample; } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 956827dd523..0376319fe2b 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -91,7 +91,7 @@ class mod_propale_saphir extends ModeleNumRefPropales if (! $numExample) { - $numExample = $langs->trans('NotConfigured'); + $numExample = 'NotConfigured'; } return $numExample; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index caa9541577f..64643feb193 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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 diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 424b3782086..67d6b046e95 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -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