diff --git a/htdocs/admin/boutique.php b/htdocs/admin/boutique.php
index 4a833a9692e..cc8757fb2b7 100644
--- a/htdocs/admin/boutique.php
+++ b/htdocs/admin/boutique.php
@@ -32,23 +32,89 @@
require("./pre.inc.php");
$langs->load("admin");
+$langs->load("oscommerce");
if (!$user->admin)
accessforbidden();
+
/*
* Actions
*/
-if ($action == 'set')
+if ($_POST["save"])
{
- dolibarr_set_const($db,'XXX',$value);
-}
+ $db->begin();
-if ($action == 'reset')
+ $i=0;
+
+ $i+=dolibarr_set_const($db,'OSC_DB_HOST',trim($_POST["oscommerce_dbhost"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'OSC_DB_NAME',trim($_POST["oscommerce_dbname"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'OSC_DB_USER',trim($_POST["oscommerce_dbuser"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'OSC_DB_PASS',trim($_POST["oscommerce_dbpass"]),'chaine',0);
+
+ if ($i >= 4)
+ {
+ $db->commit();
+ $mesg = "".$langs->trans("OSCommerceSetupSaved")."";
+ }
+ else
+ {
+ $db->rollback();
+ header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+}
+elseif ($_POST["test"])
{
- dolibarr_del_const($db,'XXX');
+ //$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->oscommerce->db->type=$dolibarr_main_db_type;
+ $conf->oscommerce->db->host=$_POST["oscommerce_dbhost"];
+ $conf->oscommerce->db->name=$_POST["oscommerce_dbname"];
+ $conf->oscommerce->db->user=$_POST["oscommerce_dbuser"];
+ $conf->oscommerce->db->pass=$_POST["oscommerce_dbpass"];
+
+ $oscommercedb=new DoliDB($conf->oscommerce->db->type,$conf->oscommerce->db->host,$conf->oscommerce->db->user,$conf->oscommerce->db->pass,$conf->oscommerce->db->name);
+
+ //print "D ".$db." - ".$db->db."
\n";
+ //print "W ".$oscommercedb." - ".$oscommercedb->db."
\n";
+
+ if ($oscommercedb->connected == 1 && $oscommercedb->database_selected == 1)
+ {
+ // Vérifie si bonne base par requete sur une table OSCommerce
+ $sql="SELECT xxx FROM zzz WHERE aaa='application_name'";
+ $resql=$oscommercedb->query($sql);
+ if ($resql) {
+ $mesg ="
".$langs->trans("OSCommerceTestOk",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbname"],$_POST["oscommerce_dbuser"]);
+ $mesg.="
";
+ }
+ else {
+ $mesg ="".$langs->trans("ErrorConnectOkButWrongDatabase");
+ $mesg.="
";
+ }
+
+ //$oscommercedb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique
+ }
+ elseif ($oscommercedb->connected == 1 && $oscommercedb->database_selected != 1)
+ {
+ $mesg ="".$langs->trans("OSCommerceTestKo1",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbname"]);
+ $mesg.="
".$oscommercedb->error();
+ $mesg.="
";
+ //$oscommercedb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique
+ }
+ else
+ {
+ $mesg ="".$langs->trans("OSCommerceTestKo2",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbuser"]);
+ $mesg.="
".$oscommercedb->error();
+ $mesg.="
";
+ }
+
+ //$resql=$db->query("select count(*) from llx_const");
+ //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error().">
\n";
}
@@ -62,7 +128,74 @@ llxHeader();
print_titre($langs->trans("OSCommerceSetup"));
-print $langs->trans("ToDo");
+
+print '
';
+
+$var=true;
+print '\n";
+
+
+clearstatcache();
+
+if ($mesg) print "
$mesg
";
+print "
";
+
$db->close();
diff --git a/htdocs/admin/webcalendar.php b/htdocs/admin/webcalendar.php
index aa3280105f3..c51cfdfe512 100644
--- a/htdocs/admin/webcalendar.php
+++ b/htdocs/admin/webcalendar.php
@@ -57,27 +57,27 @@ elseif ($actionsave)
$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);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_URL',trim($_POST["phpwebcalendar_url"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_HOST',trim($_POST["phpwebcalendar_host"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_DBNAME',trim($_POST["phpwebcalendar_dbname"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_USER',trim($_POST["phpwebcalendar_user"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_PASS',trim($_POST["phpwebcalendar_pass"]),'chaine',0);
- $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);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_SYNCRO',trim($_POST["phpwebcalendar_syncro"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_COMPANYCREATE',trim($_POST["phpwebcalendar_companycreate"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_CONTRACTSTATUS',trim($_POST["phpwebcalendar_contractstatus"]),'chaine',0);
+ $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_BILLSTATUS',trim($_POST["phpwebcalendar_billstatus"]),'chaine',0);
if ($i >= 9)
{
$db->commit();
- header("Location: webcalendar.php");
- exit;
+ $mesg = "".$langs->trans("WebCalSetupSaved")."";
}
else
{
$db->rollback();
- $mesg = "".$langs->trans("WebCalSetupSaved")."";
+ header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
}
}
elseif ($actiontest)
@@ -142,7 +142,7 @@ print_titre($langs->trans("WebCalSetup"));
print '
';
-print '