Amlioration module OSCommerce1 pour grer un OS Commerce sur autre base que Dolibarr
This commit is contained in:
parent
84006a54f3
commit
89e859a605
@ -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 = "<font class=\"ok\">".$langs->trans("OSCommerceSetupSaved")."</font>";
|
||||
}
|
||||
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()."><br>\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."<br>\n";
|
||||
//print "W ".$oscommercedb." - ".$oscommercedb->db."<br>\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 ="<div class=\"ok\">".$langs->trans("OSCommerceTestOk",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbname"],$_POST["oscommerce_dbuser"]);
|
||||
$mesg.="</div>";
|
||||
}
|
||||
else {
|
||||
$mesg ="<div class=\"error\">".$langs->trans("ErrorConnectOkButWrongDatabase");
|
||||
$mesg.="</div>";
|
||||
}
|
||||
|
||||
//$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 ="<div class=\"error\">".$langs->trans("OSCommerceTestKo1",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbname"]);
|
||||
$mesg.="<br>".$oscommercedb->error();
|
||||
$mesg.="</div>";
|
||||
//$oscommercedb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique
|
||||
}
|
||||
else
|
||||
{
|
||||
$mesg ="<div class=\"error\">".$langs->trans("OSCommerceTestKo2",$_POST["oscommerce_dbhost"],$_POST["oscommerce_dbuser"]);
|
||||
$mesg.="<br>".$oscommercedb->error();
|
||||
$mesg.="</div>";
|
||||
}
|
||||
|
||||
//$resql=$db->query("select count(*) from llx_const");
|
||||
//print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error()."><br>\n";
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +128,74 @@ llxHeader();
|
||||
print_titre($langs->trans("OSCommerceSetup"));
|
||||
|
||||
|
||||
print $langs->trans("ToDo");
|
||||
|
||||
print '<br>';
|
||||
|
||||
$var=true;
|
||||
print '<form name="oscommerceconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
|
||||
print "<td>".$langs->trans("Value")."</td>";
|
||||
print "<td>".$langs->trans("Examples")."</td>";
|
||||
print "</tr>";
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>".$langs->trans("OSCOmmerceServer")."</td>";
|
||||
print "<td><input type=\"text\" class=\"flat\" name=\"oscommerce_dbhost\" value=\"". ($_POST["oscommerce_dbhost"]?$_POST["oscommerce_dbhost"]:$conf->global->OSC_DB_HOST) . "\" size=\"30\"></td>";
|
||||
print "<td>localhost";
|
||||
//print "<br>__dolibarr_main_db_host__ <i>(".$dolibarr_main_db_host.")</i>"
|
||||
print "</td>";
|
||||
print "</tr>";
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>".$langs->trans("OSCOmmerceDatabaseName")."</td>";
|
||||
print "<td><input type=\"text\" class=\"flat\" name=\"oscommerce_dbname\" value=\"". ($_POST["oscommerce_dbname"]?$_POST["oscommerce_dbname"]:$conf->global->OSC_DB_NAME) . "\" size=\"30\"></td>";
|
||||
print "<td>oscommerce";
|
||||
//print "<br>__dolibarr_main_db_name__ <i>(".$dolibarr_main_db_name.")</i>";
|
||||
print "</td>";
|
||||
print "</tr>";
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>".$langs->trans("OSCOmmerceUser")."</td>";
|
||||
print "<td><input type=\"text\" class=\"flat\" name=\"oscommerce_dbuser\" value=\"". ($_POST["oscommerce_dbuser"]?$_POST["oscommerce_dbuser"]:$conf->global->OSC_DB_USER) . "\" size=\"30\"></td>";
|
||||
print "<td>oscommerceuser";
|
||||
//print "<br>__dolibarr_main_db_user__ <i>(".$dolibarr_main_db_user.")</i>";
|
||||
print "</td>";
|
||||
print "</tr>";
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>".$langs->trans("Password")."</td>";
|
||||
print "<td><input type=\"password\" class=\"flat\" name=\"oscommerce_dbpass\" value=\"" . ($_POST["oscommerce_dbpass"]?$_POST["oscommerce_dbpass"]:$conf->global->OSC_DB_PASS) . "\" size=\"30\"></td>";
|
||||
print '<td>';
|
||||
//if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ <i>('.eregi_replace('.','*',$dolibarr_main_db_pass).')</i>';
|
||||
print ' </td>';
|
||||
print "</tr>";
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var].">";
|
||||
print "<td>".$langs->trans("PasswordRetype")."</td>";
|
||||
print "<td><input type=\"password\" class=\"flat\" name=\"oscommerce_dbpass2\" value=\"" . ($_POST["oscommerce_dbpass2"]?$_POST["oscommerce_dbpass2"]:$conf->global->OSC_DB_PASS) ."\" size=\"30\"></td>";
|
||||
print '<td>';
|
||||
//if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ <i>('.eregi_replace('.','*',$dolibarr_main_db_pass).')</i>';
|
||||
print ' </td>';
|
||||
print "</tr>";
|
||||
print "</table>";
|
||||
|
||||
|
||||
print '<br><center>';
|
||||
print "<input type=\"submit\" name=\"test\" class=\"button\" value=\"".$langs->trans("TestConnection")."\">";
|
||||
print " ";
|
||||
print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
|
||||
print "</center>";
|
||||
|
||||
print "</form>\n";
|
||||
|
||||
|
||||
clearstatcache();
|
||||
|
||||
if ($mesg) print "<br>$mesg<br>";
|
||||
print "<br>";
|
||||
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -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 = "<font class=\"ok\">".$langs->trans("WebCalSetupSaved")."</font>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$mesg = "<font class=\"ok\">".$langs->trans("WebCalSetupSaved")."</font>";
|
||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
elseif ($actiontest)
|
||||
@ -142,7 +142,7 @@ print_titre($langs->trans("WebCalSetup"));
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<form name="phpwebcalendarconfig" action="webcalendar.php" method="post">';
|
||||
print '<form name="phpwebcalendarconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td width=\"30%\">".$langs->trans("Parameter")."</td>";
|
||||
@ -250,6 +250,8 @@ if ($conf->facture->enabled)
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
|
||||
print '<br><center>';
|
||||
print "<input type=\"submit\" name=\"test\" class=\"button\" value=\"".$langs->trans("TestConnection")."\">";
|
||||
print " ";
|
||||
|
||||
@ -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 '<tr class="liste_titre"><td>'.$langs->trans("Description").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Total").'</td></tr>';
|
||||
|
||||
$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 '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4">'.$langs->trans("Dernières commandes").'</td></tr>';
|
||||
|
||||
$num = min($num,OSC_MAXNBCOM);
|
||||
while ($i < $num)
|
||||
$langs->load("orders");
|
||||
$num = $db->num_rows();
|
||||
if ($num > 0)
|
||||
{
|
||||
|
||||
$obj = $db->fetch_object();
|
||||
print "<tr><td>$obj->orders_id</td><td>$obj->customers_name</td><td>".price($obj->value)."</td><td>$obj->payment_method</td></tr>";
|
||||
$i++;
|
||||
$i = 0;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4">'.$langs->trans("Dernières commandes").'</td></tr>';
|
||||
|
||||
$num = min($num,OSC_MAXNBCOM);
|
||||
while ($i < $num)
|
||||
{
|
||||
|
||||
$obj = $db->fetch_object();
|
||||
print "<tr><td>$obj->orders_id</td><td>$obj->customers_name</td><td>".price($obj->value)."</td><td>$obj->payment_method</td></tr>";
|
||||
$i++;
|
||||
}
|
||||
print "</table><br>";
|
||||
}
|
||||
print "</table><br>";
|
||||
}
|
||||
}
|
||||
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 '</td></tr><tr>';
|
||||
* 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) )
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user