From 6b10605068e11c0869d3d7540e0581d186dde8bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Jul 2005 22:47:02 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20Am=E9lioration=20gestion=20erreur=20cr?= =?UTF-8?q?=E9ation=20action=20(avec=20ou=20sans=20lien=20webcal)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/action/fiche.php | 36 ++++++++++++++++++++++++------------ htdocs/comm/fiche.php | 23 ++++++++++++----------- htdocs/lib/webcal.class.php | 14 ++++++++------ 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 36784bdd2e0..ea5cb57d8b4 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -41,15 +41,14 @@ $langs->load("commercial"); $langs->load("other"); $langs->load("bills"); - -/* - * Sécurité accés client - */ +// Sécurité accés client if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } +if (isset($_GET["error"])) $error=$_GET["error"]; + /* * Action création de l'action @@ -109,13 +108,15 @@ if ($_POST["action"] == 'add_action') $webcal=0; if ($conf->webcal->enabled && $_POST["todo_webcal"] == 'on') { + // Crée objet webcal et connexion avec params $conf->webcal->db->xxx $webcal = new Webcal(); if (! $webcal->localdb->ok) { // Si la creation de l'objet n'as pu se connecter - $error="Dolibarr n'a pu se connecter à la base Webcalendar avec les identifiants définis (host=".$conf->webcal->db->host." dbname=".$conf->webcal->db->name." user=".$conf->webcal->db->user."). L'option de mise a jour Webcalendar a été ignorée."; - $webcal=-1; + $error ="Dolibarr n'a pu se connecter à la base Webcalendar avec les identifiants définis (host=".$conf->webcal->db->host." dbname=".$conf->webcal->db->name." user=".$conf->webcal->db->user.")."; + $error.=" L'option de mise a jour Webcalendar a été ignorée."; + $webcal->error=$error; } else { @@ -144,15 +145,26 @@ if ($_POST["action"] == 'add_action') } // On crée l'action (avec ajout eventuel dans webcal si défini) - $idaction=$actioncomm->add($user, $webcal); + $idaction=$actioncomm->add($user, ($webcal->localdb->ok?$webcal:0) ); if ($idaction > 0) { if (! $actioncomm->error) { - // Si pas d'erreur - $db->commit(); - Header("Location: ".$_POST["from"]); + // Si pas d'erreur creation action + if (! $webcal->error) + { + // Pas d'erreur webcal + $db->commit(); + Header("Location: ".$_POST["from"]); + return; + } + else + { + // Pas d'erreur action mais erreur webcal + $db->commit(); + $_GET["id"]=$idaction; + } } else { @@ -165,7 +177,6 @@ if ($_POST["action"] == 'add_action') else { $db->rollback(); - $_GET["id"]=$idaction; dolibarr_print_error($db); } } @@ -419,7 +430,7 @@ if ($_GET["action"] == 'create') if ($_GET["id"]) { if ($error) { - print ''.$error.'

'; + print '
'.$error.'

'; } $act = new ActionComm($db); @@ -447,6 +458,7 @@ if ($_GET["id"]) if ($_GET["action"] == 'delete') { $html->form_confirm("fiche.php?id=".$_GET["id"],$langs->trans("DeleteAction"),$langs->trans("ConfirmDeleteAction"),"confirm_delete"); + print '
'; } if ($_GET["action"] == 'edit') diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index d2650b8d2ff..af0b4db44c2 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -506,34 +506,35 @@ if ($_socid > 0) if ($conf->propal->enabled && $user->rights->propale->creer) { $langs->load("propal"); - print ''.$langs->trans("AddProp").''; + print ''.$langs->trans("AddProp").''; } if ($conf->commande->enabled && $user->rights->commande->creer) { $langs->load("orders"); - print ''.$langs->trans("AddOrder").''; + print ''.$langs->trans("AddOrder").''; } if ($user->rights->contrat->creer) { $langs->load("contracts"); - print ''.$langs->trans("AddContract").''; + print ''.$langs->trans("AddContract").''; } if ($conf->fichinter->enabled) { $langs->load("fichinter"); - print ''.$langs->trans("AddIntervention").''; + print ''.$langs->trans("AddIntervention").''; } if ($conf->projet->enabled && $user->rights->projet->creer) { - print ''.$langs->trans("AddProject").''; + print ''.$langs->trans("AddProject").''; } + print ''.$langs->trans("AddContact").''; - print ''.$langs->trans("AddContact").''; + print ''.$langs->trans("AddAction").''; print ''; print '
'; @@ -637,7 +638,7 @@ if ($_socid > 0) * */ print ''; - print ''; + print ''; $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code as acode, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid "; $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u "; @@ -687,7 +688,7 @@ if ($_socid > 0) if ($obj->propalrowid) { - print '
'.$langs->trans("ActionsToDo").' '.$langs->trans("AddActionToDo").'
'.$langs->trans("ActionsToDo").' 
'.img_object($langs->trans("ShowTask"),"task"); + print ''.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; @@ -695,7 +696,7 @@ if ($_socid > 0) } else { - print ''.img_object($langs->trans("ShowTask"),"task"); + print ''.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; @@ -780,7 +781,7 @@ if ($_socid > 0) if ($obj->propalrowid) { - print ''.img_object($langs->trans("ShowTask"),"task"); + print ''.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; @@ -788,7 +789,7 @@ if ($_socid > 0) } else { - print ''.img_object($langs->trans("ShowTask"),"task"); + print ''.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; diff --git a/htdocs/lib/webcal.class.php b/htdocs/lib/webcal.class.php index fa78f3591fb..eb2fbcb2791 100644 --- a/htdocs/lib/webcal.class.php +++ b/htdocs/lib/webcal.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2004-2005 Laurent Destailleur * * 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 @@ -21,7 +21,7 @@ * */ -/*! +/** \file htdocs/lib/webcal.class.php \ingroup webcal \brief Ensemble des fonctions permettant d'acceder a la database webcalendar. @@ -31,12 +31,13 @@ require_once (DOL_DOCUMENT_ROOT ."/lib/".$conf->webcal->db->type.".lib.php"); -/*! +/** \class Webcal \brief Classe permettant d'acceder a la database webcalendar */ class Webcal { + var $localdb; var $heure = -1; var $duree = 0; @@ -45,7 +46,7 @@ class Webcal { var $desc; var $error; -/*! +/** \brief Constructeur de la classe d'interface à Webcalendar */ @@ -63,7 +64,7 @@ class Webcal { } -/*! +/** \brief Ajoute une entree dans le calendrier de l'utilisateur \param[in] user le login de l'utilisateur \param[in] date la date de l'evenement dans le calendrier @@ -135,7 +136,7 @@ class Webcal { } -/*! +/** \brief Obtient l'id suivant dans le webcalendar \return int retourne l'id suivant dans le webcalendar ou -1 si erreur */ @@ -155,5 +156,6 @@ class Webcal { return -1; } } + } ?>