From 34cc347d5bf9e61050d692123c60c413d40681c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Oct 2004 02:01:06 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20La=20cr=E9ation=20d'une=20action=20met?= =?UTF-8?q?=20une=20entr=E9e=20dans=20webcalendar.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/action/fiche.php | 119 +++++++++++++++++++++++------------ htdocs/comm/fiche.php | 18 ++++-- 2 files changed, 90 insertions(+), 47 deletions(-) diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index bcc1ddcc4b6..a0ade0ee56d 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -29,13 +29,16 @@ require("./pre.inc.php"); -$langs->load("company"); -$langs->load("commercial"); - require("../../contact.class.php"); -require("../../lib/webcal.class.php"); require("../../cactioncomm.class.php"); require("../../actioncomm.class.php"); +if ($conf->webcal->enabled) { + require("../../lib/webcal.class.php"); +} + +$langs->load("companies"); +$langs->load("commercial"); +$langs->load("other"); /* @@ -87,31 +90,54 @@ if ($_POST["action"] == 'add_action') $actioncomm->societe = isset($_POST["socid"])?$_POST["socid"]:0; $actioncomm->contact = isset($_POST["contactid"])?$_POST["contactid"]:0; $actioncomm->note = $_POST["note"]; - - $actioncomm->add($user); - if ($conf->webcal && $todo_webcal == 'on') - { - $webcal = new Webcal(); + // On definit la ressource webcal si le module webcal est actif + $webcal=0; + if ($conf->webcal->enabled && $_POST["todo_webcal"] == 'on') + { + $webcal = new Webcal(); - $webcal->heure = $heurehour . $heuremin . '00'; - $webcal->duree = ($dureehour * 60) + $dureemin; - - if ($_POST["actionid"] == 5) - { - $libelle = "Rendez-vous avec ".$contact->fullname; - $libelle .= "\n" . $actioncomm->libelle; - } - else - { - $libelle = $actioncomm->libelle; - } - - $webcal->add($user, $actioncomm->date, $societe->nom, $libelle); - } + 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; + } + else + { + $webcal->heure = $heurehour . $heuremin . '00'; + $webcal->duree = ($dureehour * 60) + $dureemin; + + if ($_POST["actionid"] == 5) + { + $libelle = "Rendez-vous avec ".$contact->fullname; + $libelle .= "\n" . $actioncomm->libelle; + } + else + { + $libelle = $actioncomm->libelle; + } + + $webcal->date=$actioncomm->date; + $webcal->texte=$societe->nom; + $webcal->desc=$libelle; + } + } - Header("Location: ".$_POST["from"]); + // On crée l'action (avec ajout eventuel dans webcal si défini) + $idaction=$actioncomm->add($user, $webcal); + if ($idaction > 0) { + if ($webcal >= 0) { + // Si pas de module webcal ou si pas d'erreur avec + Header("Location: ".$_POST["from"]); + } + else { + // Si erreur dans module webcal + $_GET["id"]=$idaction; + } + } else { + dolibarr_print_error($db); + } } else { print "Le type d'action n'a pas été choisi"; @@ -224,6 +250,13 @@ if ($_GET["action"] == 'create') print_duree_select("duree"); print ''; + // Lien avec calendrier si module activé + if ($conf->webcal->enabled) + { + $langs->load("other"); + print ''.$langs->trans("AddCalendarEntry").''; + } + print ''.$langs->trans("Comment").''; print ''; print ''; @@ -292,29 +325,29 @@ if ($_GET["action"] == 'create') // Date print ''.$langs->trans("Date").''; if ($_GET["afaire"] == 1) - { - print $html->select_date('','ac'); - print ''.$langs->trans("Hour").''; + { + $html->select_date('','ac'); + print ''.$langs->trans("Hour").''; print_heure_select("heure",8,20); print ''; } - else if ($_GET["afaire"] == 2) + else if ($_GET["afaire"] == 2) { - print $html->select_date('','ac',1,1); - print ''.$langs->trans("Hour").''; - print_heure_select("heure",8,20); - print ''; + $html->select_date('','ac',1,1); + print ''.$langs->trans("Hour").''; + print_heure_select("heure",8,20); + print ''; } - else - { - print $html->select_date('','ac',1,1); - print ''.$langs->trans("Hour").''; - print_heure_select("heure",8,20); - print ''; + else + { + $html->select_date('','ac',1,1); + print ''.$langs->trans("Hour").''; + print_heure_select("heure",8,20); + print ''; } print ''; - // Lien avec celendrier si module activé + // Lien avec calendrier si module activé if ($conf->webcal->enabled) { $langs->load("other"); @@ -341,6 +374,10 @@ if ($_GET["action"] == 'create') */ if ($_GET["id"]) { + if ($error) { + print ''.$error.'

'; + } + $act = new ActionComm($db); $act->fetch($_GET["id"]); @@ -369,7 +406,7 @@ if ($_GET["id"]) } if ($_GET["action"] == 'edit') - { + { // Fiche action en mode edition print '
'; print ''; diff --git a/htdocs/comm/fiche.php b/htdocs/comm/fiche.php index 57315874b66..e73d1b41dad 100644 --- a/htdocs/comm/fiche.php +++ b/htdocs/comm/fiche.php @@ -20,9 +20,16 @@ * $Source$ * */ + +/*! + \file htdocs/comm/fiche.php + \ingroup commercial + \brief Page de la fiche commercial + \version $Revision$ +*/ + require("./pre.inc.php"); require("../contact.class.php"); -require("../lib/webcal.class.php"); require("../cactioncomm.class.php"); require("../actioncomm.class.php"); @@ -412,7 +419,7 @@ if ($_socid > 0) * Liste des contacts * */ - print ''; + print '
'; print ''; print ''; @@ -463,11 +470,10 @@ if ($_socid > 0) print "

"; /* - * * Listes des actions a faire * */ - print '

'.$langs->trans("Firstname").' '.$langs->trans("LastName").''.$langs->trans("Poste").''.$langs->trans("Tel").'
'; + print '
'; print ''; print ''; print '
'.$langs->trans("ActionsToDo").' '.$langs->trans("AddActionToDo").'
'; @@ -480,7 +486,7 @@ if ($_socid > 0) $sql .= " ORDER BY a.datea DESC, a.id DESC"; if ( $db->query($sql) ) { - print "\n"; + print "
\n"; $i = 0 ; $num = $db->num_rows(); while ($i < $num) { @@ -503,7 +509,7 @@ if ($_socid > 0) if ($oldmonth == strftime("%Y%b",$obj->da) ) { //print ''; - print "\n"; + print "\n"; } else {
|" .strftime("%Y",$obj->da)."" .strftime("%b",$obj->da)."