diff --git a/htdocs/admin/webcalendar.php b/htdocs/admin/webcalendar.php
index fa4bf7ad1c0..61192bcad37 100644
--- a/htdocs/admin/webcalendar.php
+++ b/htdocs/admin/webcalendar.php
@@ -25,193 +25,246 @@
/**
\file htdocs/admin/webcalendar.php
- \ingroup webcal
+ \ingroup webcalendar
\brief Page de configuration du module webcalendar
\version $Revision$
*/
require("./pre.inc.php");
+require_once(DOL_DOCUMENT_ROOT.'/lib/webcal.class.php');
+
if (!$user->admin)
accessforbidden();
+
$langs->load("admin");
$langs->load("other");
-llxHeader();
-
-print_titre($langs->trans("WebCalSetup"));
-print '
';
-
$def = array();
-
-$phpwebcalendar_url=trim($_POST["phpwebcalendar_url"]);
-$phpwebcalendar_host=trim($_POST["phpwebcalendar_host"]);
-$phpwebcalendar_dbname=trim($_POST["phpwebcalendar_dbname"]);
-$phpwebcalendar_user=trim($_POST["phpwebcalendar_user"]);
-$phpwebcalendar_pass=trim($_POST["phpwebcalendar_pass"]);
-$phpwebcalendar_pass2=trim($_POST["phpwebcalendar_pass2"]);
-$phpwebcalendar_syncro=trim($_POST["phpwebcalendar_syncro"]);
$actiontest=$_POST["test"];
$actionsave=$_POST["save"];
// Test saisie mot de passe
-if ($phpwebcalendar_pass != $phpwebcalendar_pass2)
+if ($_POST["phpwebcalendar_pass"] != $_POST["phpwebcalendar_pass2"])
{
- $ok="
".$langs->trans("ErrorPasswordDiffers")."
";
+ $mesg="".$langs->trans("ErrorPasswordDiffers")."
";
}
// Positionne la variable pour le test d'affichage de l'icone
elseif ($actionsave)
{
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_URL';";
- $db->query($sql);
-
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_URL','".$phpwebcalendar_url."',0);";
- $result=$db->query($sql);
-
- $sql1 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_HOST';";
- $db->query($sql1);
-
- $sql1 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_HOST','".$phpwebcalendar_host."',0);";
- $result1=$db->query($sql1);
-
- $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_DBNAME';";
- $db->query($sql2);
-
- $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_DBNAME','".$phpwebcalendar_dbname."',0);";
- $result2=$db->query($sql2);
-
- $sql3 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_USER' ;";
- $db->query($sql3);
-
- $sql3 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_USER','".$phpwebcalendar_user."',0);";
- $result3=$db->query($sql3);
-
- $sql4 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_PASS';";
- $db->query($sql4);
-
- $sql4 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_PASS','".$phpwebcalendar_pass."',0);";
- $result4=$db->query($sql4);
+ $i=0;
- $sql5 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_SYNCRO';";
- $db->query($sql5);
-
- $sql5 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_SYNCRO','".$phpwebcalendar_syncro."',0);";
- $result5=$db->query($sql5);
+ $db->begin();
+
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_URL',trim($_POST["phpwebcalendar_url"]),'',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_HOST',trim($_POST["phpwebcalendar_host"]),'',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_DBNAME',trim($_POST["phpwebcalendar_dbname"]),'',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_USER',trim($_POST["phpwebcalendar_user"]),'',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_PASS',trim($_POST["phpwebcalendar_pass"]),'',0);
- if ($result && $result1 && $result2 && $result3 && $result4 && $result5)
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_SYNCRO',trim($_POST["phpwebcalendar_syncro"]),'',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_COMPANYCREATE',trim($_POST["phpwebcalendar_companycreate"]),'',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_CONTRACTSTATUS',trim($_POST["phpwebcalendar_contractstatus"]),'',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_BILLSTATUS',trim($_POST["phpwebcalendar_billstatus"]),'',0);
+
+ if ($i >= 9)
{
- $ok = "".$langs->trans("WebCalSetupSaved")."";
+ $db->commit();
+ header("Location: webcalendar.php");
+ exit;
+ }
+ else
+ {
+ $db->rollback();
+ $mesg = "".$langs->trans("WebCalSetupSaved")."";
}
}
-
-if (! $actiontest && ! $actionsave)
+elseif ($actiontest)
{
- if (! $phpwebcalendar_url) { $phpwebcalendar_url=PHPWEBCALENDAR_URL; }
- if (! $phpwebcalendar_host) { $phpwebcalendar_host=PHPWEBCALENDAR_HOST; }
- if (! $phpwebcalendar_dbname) { $phpwebcalendar_dbname=PHPWEBCALENDAR_DBNAME; }
- if (! $phpwebcalendar_user) { $phpwebcalendar_user=PHPWEBCALENDAR_USER; }
- if (! $phpwebcalendar_pass) { $phpwebcalendar_pass=PHPWEBCALENDAR_PASS; }
- if (! $phpwebcalendar_pass2) { $phpwebcalendar_pass2=PHPWEBCALENDAR_PASS; }
- if (! $phpwebcalendar_syncro) { $phpwebcalendar_syncro=PHPWEBCALENDAR_SYNCRO; }
+ //$resql=$db->query("select count(*) from llx_const");
+ //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error().">
\n";
+
+ // Test de la connection a la database webcalendar
+ $conf->webcal->db->type=$dolibarr_main_db_type;
+ $conf->webcal->db->host=$_POST["phpwebcalendar_host"];
+ $conf->webcal->db->user=$_POST["phpwebcalendar_user"];
+ $conf->webcal->db->pass=$_POST["phpwebcalendar_pass"];
+ $conf->webcal->db->name=$_POST["phpwebcalendar_dbname"];
+
+ $webcal=new WebCal();
+
+ //print "D ".$db." - ".$db->db."
\n";
+ //print "W ".$webcal->localdb." - ".$webcal->localdb->db."
\n";
+
+ if ($webcal->localdb->connected == 1 && $webcal->localdb->database_selected == 1)
+ {
+ // Vérifie si bonne base
+ $sql="SELECT cal_value FROM webcal_config WHERE cal_setting='application_name'";
+ $resql=$webcal->localdb->query($sql);
+ if ($resql) {
+ $mesg ="".$langs->trans("WebCalTestOk",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_dbname"],$_POST["phpwebcalendar_user"]);
+ $mesg.="
";
+ }
+ else {
+ $mesg ="".$langs->trans("ErrorConnectOkButWrongDatabase");
+ $mesg.="
";
+ }
+
+ //$webcal->localdb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique
+ }
+ elseif ($webcal->connected == 1 && $webcal->database_selected != 1)
+ {
+ $mesg ="".$langs->trans("WebCalTestKo1",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_dbname"]);
+ $mesg.="
".$webcal->localdb->error();
+ $mesg.="
";
+ //$webcal->localdb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique
+ }
+ else
+ {
+ $mesg ="".$langs->trans("WebCalTestKo2",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_user"]);
+ $mesg.="
".$webcal->localdb->error();
+ $mesg.="
";
+ }
+
+ //$resql=$db->query("select count(*) from llx_const");
+ //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error().">
\n";
}
/**
* Affichage du formulaire de saisie
*/
-print '\n";
clearstatcache();
-if ($ok) print "
$ok
";
+if ($mesg) print "
$mesg
";
print "
";
-// Test de la connection a la database webcalendar
-if ($actiontest && ($phpwebcalendar_pass == $phpwebcalendar_pass2))
-{
- // Test connexion
- $webcal = new DoliDb('',$phpwebcalendar_host,$phpwebcalendar_user,$phpwebcalendar_pass,$phpwebcalendar_dbname);
-
- if ($webcal->connected == 1 && $webcal->database_selected == 1)
- {
- // Vérifie si bonne base
- $sql="SELECT cal_value FROM webcal_config WHERE cal_setting='application_name'";
- $resql=$webcal->query($sql);
- if ($resql) {
- $mesg ="".$langs->trans("WebCalTestOk",$phpwebcalendar_host,$phpwebcalendar_dbname,$phpwebcalendar_user);
- $mesg.="
";
- }
- else {
- $mesg ="".$langs->trans("ErrorConnectOkButWrongDatabase");
- $mesg.=$webcal->error;
- $mesg.="
";
- }
-
- $webcal->close();
- }
- elseif ($webcal->connected == 1 && $webcal->database_selected != 1)
- {
- $mesg ="".$langs->trans("WebCalTestKo1",$phpwebcalendar_host,$phpwebcalendar_dbname);
- $mesg.="
".$webcal->error;
- $mesg.="
";
- $webcal->close();
- }
- else
- {
- $mesg ="".$langs->trans("WebCalTestKo2",$phpwebcalendar_host,$phpwebcalendar_user);
- $mesg.="
".$webcal->error;
- $mesg.="
";
- }
-
- print $mesg;
-}
-
+$db->close();
llxFooter('$Date$ - $Revision$');
?>
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index 9fea0aef300..babaa6cdc0c 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -185,6 +185,9 @@ Permission233=Delete supplier invoices
Permission300=Read bar codes
Permission301=Create/modify bar codes
Permission302=Delete bar codes
+Permission331=Read bookmarks
+Permission332=Create/modify bookmarks
+Permission333=Delete bookmarks
Permission700=Read donations
Permission701=Create/modify donations
Permission702=Delete donations
@@ -272,7 +275,7 @@ CustomerCodeChecker=Module for checking customer's code
AccountCodeManager=Module for managing accountancy code
##### Webcal setup #####
WebCalSetup=Webcalendar link setup
-WebCalSyncro=Add Dolibarr Event to WebCalendar
+WebCalSyncro=Add Dolibarr events to WebCalendar
WebCalAllways=Always, no asking
WebCalYesByDefault=On demand (yes by default)
WebCalNoByDefault=On demand (no by default)
@@ -285,6 +288,10 @@ WebCalSetupSaved=Webcalendar setup saved successfully.
WebCalTestOk=Connection to server '%s' on database '%s' with user '%s' successfull.
WebCalTestKo1=Connection to server '%s' succeed but database '%s' could not be reached.
WebCalTestKo2=Connection to server '%s' with user '%s' failed.
+WebCalAddEventOnCreateActions=Add calendar event on actions create
+WebCalAddEventOnCreateCompany=Add calendar event on companies create
+WebCalAddEventOnStatusContract=Add calendar event on contract status change
+WebCalAddEventOnStatusBill=Add calendar event on bill status change
ErrorConnectOkButWrongDatabase=Connection succeeded but database doesn't look to be a Webcalendar database.
##### Bills #####
BillsSetup=Invoices module setup
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 8028611280d..2cd259fc175 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -185,6 +185,9 @@ Permission233=Supprimer les factures fournisseurs
Permission300=Consulter les codes barres
Permission301=Créer/modifier les codes barres
Permission302=Supprimer les codes barres
+Permission331=Lire les bookmarks
+Permission332=Créer/modifier les bookmarks
+Permission333=Supprimer les bookmarks
Permission700=Consulter les dons
Permission701=Créer/modifier les dons
Permission702=Supprimer les dons
@@ -278,13 +281,17 @@ WebCalYesByDefault=Sur demande (oui par d
WebCalNoByDefault=Sur demande (non par défaut)
WebCalNever=Jamais
WebCalURL=Adresse (URL) d'accès au calendrier
-WebCalServer=Serveur où la base du calendrier est hébergée
+WebCalServer=Serveur de la base de donnée du calendrier
WebCalDatabaseName=Nom de la base de données
WebCalUser=Identifiant d'accès à la base
WebCalSetupSaved=Les identifiants Webcalendar ont été correctement sauvegardés.
WebCalTestOk=La connexion au serveur '%s' sur la base '%s' par l'utilisateur '%s' a réussi.
WebCalTestKo1=La connexion au serveur '%s' a réussi mais la base '%s' n'a pu être atteinte.
WebCalTestKo2=La connexion au serveur '%s' par l'utilisateur '%s' à échoué.
+WebCalAddEventOnCreateActions=Ajouter évênement dans calendrier sur création d'actions
+WebCalAddEventOnCreateCompany=Ajouter évênement dans calendrier sur création de sociétés
+WebCalAddEventOnStatusContract=Ajouter évênement dans calendrier sur changement statut contrats
+WebCalAddEventOnStatusBill=Ajouter évênement dans calendrier sur changement statut factures
ErrorConnectOkButWrongDatabase=La connexion a réussie mais la base ne semble pas etre une base webcalendar.
##### Bills #####
BillsSetup=Configuration du module Factures
diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php
index 5e3f5590b32..3f491b4dcdc 100644
--- a/htdocs/lib/functions.inc.php
+++ b/htdocs/lib/functions.inc.php
@@ -177,36 +177,36 @@ function dolibarr_syslog($message, $level=LOG_ERR)
*/
function dolibarr_fiche_head($links, $active=0, $title='')
{
- print "\n";
+ print "
\n";
- print "
\n
\n";
+ print "
\n";
+ print "
\n
\n";
}
/**
@@ -218,18 +218,18 @@ function dolibarr_fiche_head($links, $active=0, $title='')
*/
function dolibarr_get_const($db, $name)
{
- $value='';
-
- $sql ="SELECT value";
- $sql.=" FROM llx_const";
- $sql.=" WHERE name = '$name';";
- $resql=$db->query($sql);
- if ($resql)
- {
- $obj=$db->fetch_object($resql);
- $value=stripslashes($obj->value);
- }
- return $value;
+ $value='';
+
+ $sql ="SELECT value";
+ $sql.=" FROM llx_const";
+ $sql.=" WHERE name = '$name';";
+ $resql=$db->query($sql);
+ if ($resql)
+ {
+ $obj=$db->fetch_object($resql);
+ $value=stripslashes($obj->value);
+ }
+ return $value;
}
@@ -274,37 +274,37 @@ function dolibarr_set_php_lang($code_lang)
*/
function dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='')
{
- global $conf;
-
- $db->begin();
-
- //dolibarr_syslog("dolibarr_set_const name=$name, value=$value");
- $sql = "DELETE FROM llx_const WHERE name = '$name';";
- $resql=$db->query($sql);
-
- $sql = "INSERT INTO llx_const(name,value,type,visible,note)";
- $sql.= " VALUES ('$name','".addslashes($value)."','$type',$visible,'".addslashes($note)."');";
- $resql=$db->query($sql);
+ global $conf;
+
+ $db->begin();
+
+ //dolibarr_syslog("dolibarr_set_const name=$name, value=$value");
+ $sql = "DELETE FROM llx_const WHERE name = '$name';";
+ $resql=$db->query($sql);
+
+ $sql = "INSERT INTO llx_const(name,value,type,visible,note)";
+ $sql.= " VALUES ('$name','".addslashes($value)."','$type',$visible,'".addslashes($note)."');";
+ $resql=$db->query($sql);
- if ($resql)
- {
- $db->commit();
- $conf->global->$name=$value;
- return 1;
- }
- else
- {
- $db->rollback();
- return -1;
- }
+ if ($resql)
+ {
+ $db->commit();
+ $conf->global->$name=$value;
+ return 1;
+ }
+ else
+ {
+ $db->rollback();
+ return -1;
+ }
}
/**
\brief Effacement d'une constante dans la base de données
\see dolibarr_get_const, dolibarr_sel_const
- \param db handler d'accès base
- \param name nom ou rowid de la constante
- \return int 0 si KO, 1 si OK
+ \param db Handler d'accès base
+ \param name Nom ou rowid de la constante
+ \return int <0 si ko, >0 si ok
*/
function dolibarr_del_const($db, $name)
{
@@ -317,7 +317,7 @@ function dolibarr_del_const($db, $name)
}
else
{
- return 0;
+ return -1;
}
}
diff --git a/htdocs/lib/webcal.class.php b/htdocs/lib/webcal.class.php
index ea31cfef89c..d05c4d86023 100644
--- a/htdocs/lib/webcal.class.php
+++ b/htdocs/lib/webcal.class.php
@@ -53,15 +53,19 @@ class Webcal {
function Webcal()
{
global $conf;
-
+ global $dolibarr_main_db_type,$dolibarr_main_db_host,$dolibarr_main_db_user;
+ global $dolibarr_main_db_pass,$dolibarr_main_db_name;
+
+ // Défini parametres webcal (avec substitution eventuelle)
+ $webcaltype=eregi_replace('__dolibarr_main_db_type__',$dolibarr_main_db_type,$conf->webcal->db->type);
+ $webcalhost=eregi_replace('__dolibarr_main_db_host__',$dolibarr_main_db_host,$conf->webcal->db->host);
+ $webcaluser=eregi_replace('__dolibarr_main_db_user__',$dolibarr_main_db_user,$conf->webcal->db->user);
+ $webcalpass=eregi_replace('__dolibarr_main_db_pass__',$dolibarr_main_db_pass,$conf->webcal->db->pass);
+ $webcalname=eregi_replace('__dolibarr_main_db_name__',$dolibarr_main_db_name,$conf->webcal->db->name);
+
// On initie la connexion à la base Webcalendar
- require_once (DOL_DOCUMENT_ROOT ."/lib/".$conf->webcal->db->type.".lib.php");
- $this->localdb = new DoliDb(
- $conf->webcal->db->type,
- $conf->webcal->db->host,
- $conf->webcal->db->user,
- $conf->webcal->db->pass,
- $conf->webcal->db->name);
+ require_once (DOL_DOCUMENT_ROOT ."/lib/".$webcaltype.".lib.php");
+ $this->localdb = new DoliDb($webcaltype,$webcalhost,$webcaluser,$webcalpass,$webcalname);
}