Fix: Amlioration gestion erreur cration action (avec ou sans lien webcal)
This commit is contained in:
parent
29ded029b4
commit
6b10605068
@ -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 '<font class="error">'.$error.'</font><br><br>';
|
||||
print '<div class="error">'.$error.'</div><br>';
|
||||
}
|
||||
|
||||
$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 '<br>';
|
||||
}
|
||||
|
||||
if ($_GET["action"] == 'edit')
|
||||
|
||||
@ -506,34 +506,35 @@ if ($_socid > 0)
|
||||
if ($conf->propal->enabled && $user->rights->propale->creer)
|
||||
{
|
||||
$langs->load("propal");
|
||||
print '<a class="tabAction" href="addpropal.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddProp").'</a>';
|
||||
print '<a class="butAction" href="addpropal.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddProp").'</a>';
|
||||
}
|
||||
|
||||
if ($conf->commande->enabled && $user->rights->commande->creer)
|
||||
{
|
||||
$langs->load("orders");
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddOrder").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/commande/fiche.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddOrder").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->contrat->creer)
|
||||
{
|
||||
$langs->load("contracts");
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?socid='.$objsoc->id.'&action=create">'.$langs->trans("AddContract").'</a>';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contrat/fiche.php?socid='.$objsoc->id.'&action=create">'.$langs->trans("AddContract").'</a>';
|
||||
}
|
||||
|
||||
if ($conf->fichinter->enabled)
|
||||
{
|
||||
$langs->load("fichinter");
|
||||
print '<a class="tabAction" href="../fichinter/fiche.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddIntervention").'</a>';
|
||||
print '<a class="butAction" href="../fichinter/fiche.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddIntervention").'</a>';
|
||||
}
|
||||
|
||||
if ($conf->projet->enabled && $user->rights->projet->creer)
|
||||
{
|
||||
print '<a class="tabAction" href="../projet/fiche.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||
print '<a class="butAction" href="../projet/fiche.php?socidp='.$objsoc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
|
||||
}
|
||||
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$objsoc->id.'&action=create">'.$langs->trans("AddContact").'</a>';
|
||||
|
||||
print '<a class="tabAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$objsoc->id.'&action=create">'.$langs->trans("AddContact").'</a>';
|
||||
print '<a class="butAction" href="action/fiche.php?action=create&socid='.$objsoc->id.'">'.$langs->trans("AddAction").'</a>';
|
||||
|
||||
print '</div>';
|
||||
print '<br>';
|
||||
@ -637,7 +638,7 @@ if ($_socid > 0)
|
||||
*
|
||||
*/
|
||||
print '<table width="100%" class="noborder">';
|
||||
print '<tr class="liste_titre"><td colspan="7"><a href="action/index.php?socid='.$objsoc->id.'">'.$langs->trans("ActionsToDo").'</a></td><td align="right"> <a href="action/fiche.php?action=create&socid='.$objsoc->id.'&afaire=1">'.$langs->trans("AddActionToDo").'</a></td></tr>';
|
||||
print '<tr class="liste_titre"><td colspan="7"><a href="action/index.php?socid='.$objsoc->id.'">'.$langs->trans("ActionsToDo").'</a></td><td align="right"> </td></tr>';
|
||||
|
||||
$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 '<td><a href="propal.php?propalid='.$obj->propalrowid.'">'.img_object($langs->trans("ShowTask"),"task");
|
||||
print '<td><a href="propal.php?propalid='.$obj->propalrowid.'">'.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 '<td><a href="action/fiche.php?id='.$obj->id.'">'.img_object($langs->trans("ShowTask"),"task");
|
||||
print '<td><a href="action/fiche.php?id='.$obj->id.'">'.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 '<td><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$obj->propalrowid.'">'.img_object($langs->trans("ShowTask"),"task");
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$obj->propalrowid.'">'.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 '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$obj->id.'">'.img_object($langs->trans("ShowTask"),"task");
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$obj->id.'">'.img_object($langs->trans("ShowAction"),"task");
|
||||
$transcode=$langs->trans("Action".$obj->acode);
|
||||
$libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle);
|
||||
print $libelle;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user