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 '
'; +print ""; +print ""; +print ""; +print ""; +print ""; +print ""; +$var=!$var; +print ""; +print ""; +print ""; +print ""; +print ""; +$var=!$var; +print ""; +print ""; +print ""; +print ""; +print ""; +$var=!$var; +print ""; +print ""; +print ""; +print ""; +print ""; +$var=!$var; +print ""; +print ""; +print ""; +print ''; +print ""; +$var=!$var; +print ""; +print ""; +print ""; +print ''; +print ""; +print "
".$langs->trans("Parameter")."".$langs->trans("Value")."".$langs->trans("Examples")."
".$langs->trans("OSCOmmerceServer")."global->OSC_DB_HOST) . "\" size=\"30\">localhost"; +//print "
__dolibarr_main_db_host__ (".$dolibarr_main_db_host.")" +print "
".$langs->trans("OSCOmmerceDatabaseName")."global->OSC_DB_NAME) . "\" size=\"30\">oscommerce"; +//print "
__dolibarr_main_db_name__ (".$dolibarr_main_db_name.")"; +print "
".$langs->trans("OSCOmmerceUser")."global->OSC_DB_USER) . "\" size=\"30\">oscommerceuser"; +//print "
__dolibarr_main_db_user__ (".$dolibarr_main_db_user.")"; +print "
".$langs->trans("Password")."global->OSC_DB_PASS) . "\" size=\"30\">'; +//if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ ('.eregi_replace('.','*',$dolibarr_main_db_pass).')'; +print ' 
".$langs->trans("PasswordRetype")."global->OSC_DB_PASS) ."\" size=\"30\">'; +//if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ ('.eregi_replace('.','*',$dolibarr_main_db_pass).')'; +print ' 
"; + + +print '
'; +print "trans("TestConnection")."\">"; +print "   "; +print "trans("Save")."\">"; +print "
"; + +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 '
'; +print ''; print ""; print ""; print ""; @@ -250,6 +250,8 @@ if ($conf->facture->enabled) print ''; print '
".$langs->trans("Parameter")."
'; } + + print '
'; print "trans("TestConnection")."\">"; print "   "; diff --git a/htdocs/boutique/index.php b/htdocs/boutique/index.php index 09f09a92440..5f7b5893414 100644 --- a/htdocs/boutique/index.php +++ b/htdocs/boutique/index.php @@ -31,6 +31,14 @@ require("./pre.inc.php"); $langs->load("boutique"); +$oscommercedb=new DoliDB($conf->global->OSC_DB_TYPE,$conf->global->OSC_DB_HOST,$conf->global->OSC_DB_USER,$conf->global->OSC_DB_PASS,$conf->global->OSC_DB_NAME); +if (! $oscommercedb->connected) +{ + dolibarr_print_error($oscommercedb,"Failed to connect to OSCommerce with ".$conf->global->OSC_DB_TYPE.",".$conf->global->OSC_DB_HOST.",".$conf->global->OSC_DB_USER.",".$conf->global->OSC_DB_PASS.",".$conf->global->OSC_DB_NAME); + exit; +} + + llxHeader("",$langs->trans("OSCommerceShop"),""); @@ -53,8 +61,8 @@ print ''.$langs->trans("Description").''; print ''.$langs->trans("Total").''; $sql = "SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois"; -$sql .= " FROM ".OSC_DB_NAME.".orders_total as t"; -$sql .= " JOIN ".OSC_DB_NAME.".orders as o ON o.orders_id = t.orders_id"; +$sql .= " FROM ".$oscommercedb->database_name.".orders_total as t"; +$sql .= " JOIN ".$oscommercedb->database_name.".orders as o ON o.orders_id = t.orders_id"; $sql .= " WHERE t.class = 'ot_subtotal' AND YEAR(o.date_purchased) = YEAR(now()) "; $sql .= " GROUP BY mois ORDER BY mois"; @@ -127,30 +135,30 @@ from orders_total as t join orders as o on o.orders_id = t.orders_id where t.class = 'ot_subtotal' order by o.date_purchased desc */ $sql = "SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method"; -$sql .= " FROM ".OSC_DB_NAME.".orders_total as t JOIN ".OSC_DB_NAME.".orders as o on o.orders_id = t.orders_id "; +$sql .= " FROM ".$oscommercedb->database_name.".orders_total as t JOIN ".$oscommercedb->database_name.".orders as o on o.orders_id = t.orders_id "; $sql .= " WHERE t.class = 'ot_subtotal' ORDER BY o.date_purchased desc"; if ( $db->query($sql) ) { - $langs->load("orders"); - $num = $db->num_rows(); - if ($num > 0) - { - $i = 0; - print ''; - print ''; - print ''; - - $num = min($num,OSC_MAXNBCOM); - while ($i < $num) + $langs->load("orders"); + $num = $db->num_rows(); + if ($num > 0) { - - $obj = $db->fetch_object(); - print ""; - $i++; + $i = 0; + print '
'.$langs->trans("Dernières commandes").'
$obj->orders_id$obj->customers_name".price($obj->value)."$obj->payment_method
'; + print ''; + print ''; + + $num = min($num,OSC_MAXNBCOM); + while ($i < $num) + { + + $obj = $db->fetch_object(); + print ""; + $i++; + } + print "
'.$langs->trans("Dernières commandes").'
$obj->orders_id$obj->customers_name".price($obj->value)."$obj->payment_method

"; } - print "
"; - } } else { @@ -161,7 +169,7 @@ else * 5 dernières commandes en attente */ $sql = "SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method"; -$sql .= " FROM ".OSC_DB_NAME.".orders_total as t JOIN ".OSC_DB_NAME.".orders as o on o.orders_id = t.orders_id "; +$sql .= " FROM ".$oscommercedb->database_name.".orders_total as t JOIN ".$oscommercedb->database_name.".orders as o on o.orders_id = t.orders_id "; $sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status = 5 order by o.date_purchased desc"; if ( $db->query($sql) ) @@ -195,7 +203,7 @@ else * Commandes à traiter */ $sql = "SELECT o.orders_id, o.customers_name, o.date_purchased, t.value, o.payment_method"; -$sql .= " FROM ".OSC_DB_NAME.".orders_total as t JOIN ".OSC_DB_NAME.".orders as o on o.orders_id = t.orders_id "; +$sql .= " FROM ".$oscommercedb->database_name.".orders_total as t JOIN ".$oscommercedb->database_name.".orders as o on o.orders_id = t.orders_id "; $sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status = 2 order by o.date_purchased desc"; if ( $db->query($sql) ) @@ -231,8 +239,8 @@ print ''; * Derniers clients qui ont commandé */ $sql = "SELECT o.orders_id, o.customers_name, o.delivery_country, o.date_purchased, t.value, s.orders_status_name as statut"; -$sql .= " FROM ".OSC_DB_NAME.".orders_total as t JOIN ".OSC_DB_NAME.".orders as o on o.orders_id = t.orders_id "; -$sql .= " JOIN ".OSC_DB_NAME.".orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1"; +$sql .= " FROM ".$oscommercedb->database_name.".orders_total as t JOIN ".$oscommercedb->database_name.".orders as o on o.orders_id = t.orders_id "; +$sql .= " JOIN ".$oscommercedb->database_name.".orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1"; $sql .= " WHERE t.class = 'ot_subtotal' order by o.date_purchased desc"; if ( $db->query($sql) ) diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index e3810b53cd4..e579e03ccf9 100755 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -34,7 +34,6 @@ require_once("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); -if ($conf->webcal->enabled) require_once(DOL_DOCUMENT_ROOT."/lib/webcal.class.php"); $langs->load("companies"); $langs->load("commercial"); diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index d482b0ee01d..36d65e713a9 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -36,7 +36,6 @@ if (! $user->rights->societe->lire) require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); -if ($conf->webcal->enabled) require_once(DOL_DOCUMENT_ROOT."/lib/webcal.class.php"); $langs->load("companies"); diff --git a/htdocs/includes/modules/modBoutique.class.php b/htdocs/includes/modules/modBoutique.class.php index c875283f8ac..7b95860b8bd 100644 --- a/htdocs/includes/modules/modBoutique.class.php +++ b/htdocs/includes/modules/modBoutique.class.php @@ -63,7 +63,8 @@ class modBoutique extends DolibarrModules $this->dirs = array(); // Config pages - $this->config_page_url = array("boutique.php","osc-languages.php"); +// $this->config_page_url = array("boutique.php","osc-languages.php"); + $this->config_page_url = array("boutique.php"); // Dépendances $this->depends = array();