Patch jean
This commit is contained in:
parent
deadf929f7
commit
45101fcd52
@ -23,6 +23,7 @@ require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
require_once("../includes/configure.php");
|
||||
require_once("../clients/osc_customer.class.php");
|
||||
require_once("../produits/osc_product.class.php");
|
||||
|
||||
llxHeader();
|
||||
|
||||
@ -35,14 +36,22 @@ if ($action == '' && !$cancel) {
|
||||
|
||||
if ( !$result)
|
||||
{
|
||||
$osc_prod = new Osc_Product($db);
|
||||
print '<div class="titre">Fiche commande OSC : '.$osc_order->osc_orderid.'</div><br>';
|
||||
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr></tr><td width="20%">client OSC</td><td width="80%">'.$osc_order->osc_custid.'</td></tr>';
|
||||
print '<tr></tr><td width="20%">Nom client</td><td width="80%">'.$osc_order->osc_custname.'</td></tr>';
|
||||
print '<tr></tr><td width="20%">Montant</td><td width="80%">'.$osc_order->osc_ordertotal.'</td></tr>';
|
||||
print '<tr></tr><td width="20%">Montant</td><td width="80%">'.convert_price($osc_order->osc_ordertotal).'</td></tr>';
|
||||
print '<tr></tr><td width="20%">Date commande</td><td width="80%">'.$osc_order->osc_orderdate.'</td></tr>';
|
||||
print '<tr></tr><td width="20%">Méthode de paiement</td><td width="80%">'.$osc_order->osc_orderpaymet.'</td></tr>';
|
||||
print "</table>";
|
||||
print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
|
||||
// les articles
|
||||
for ($l=0;$l < sizeof($osc_order->osc_lines); $l++)
|
||||
{
|
||||
print '<tr><td>'.$osc_order->osc_lines[$l]["products_id"].'</td><td>'.$osc_prod->get_productid($osc_order->osc_lines[$l]["products_id"]).'</td><td>'.$osc_order->osc_lines[$l]["products_name"].'</td><td>'.convert_price($osc_order->osc_lines[$l]["products_price"]).'</td><td>'.$osc_order->osc_lines[$l]["quantity"].'</td></tr>';
|
||||
}
|
||||
print "</table>";
|
||||
|
||||
/* ************************************************************************** */
|
||||
@ -87,7 +96,8 @@ if ($action == '' && !$cancel) {
|
||||
if ( !$result )
|
||||
{
|
||||
$commande = $osc_order->osc2dolibarr($_GET["orderid"]);
|
||||
}
|
||||
}
|
||||
|
||||
/* utilisation de la table de transco*/
|
||||
if ($osc_order->get_orderid($osc_order->osc_orderid)>0)
|
||||
{
|
||||
@ -141,8 +151,19 @@ if ($action == '' && !$cancel) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$id = $commande->create($user);
|
||||
// vérifier l'existence des produits commandés
|
||||
$osc_product = new Osc_Product($db);
|
||||
$err = 0;
|
||||
|
||||
for ($lig = 0; $lig < sizeof($commande->lines); $lig++)
|
||||
{
|
||||
if (! $commande->lines[$lig]->fk_product) $err ++;
|
||||
}
|
||||
if ($err > 0) {
|
||||
print ("<p> Des produits de la commande sont inexistants</p>");
|
||||
$id =-9;
|
||||
}
|
||||
else $id = $commande->create($user);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
@ -150,7 +171,7 @@ if ($action == '' && !$cancel) {
|
||||
print '<br>création réussie nouvelle commande '.$id;
|
||||
$res = $osc_order->transcode($osc_order->osc_orderid,$id);
|
||||
print 'pour la commande osc : '.$osc_order->osc_orderid.'</p>';
|
||||
print '<a class="tabAction" href="index.php">'.$langs->trans("Retour").'</a>';
|
||||
print '<p><a class="tabAction" href="index.php">'.$langs->trans("Retour").'</a></p>';
|
||||
print "\n</div><br>\n";
|
||||
|
||||
if ($id > 0) exit;
|
||||
@ -182,6 +203,7 @@ if ($action == '' && !$cancel) {
|
||||
}
|
||||
else print '<br>update impossible $id : '.$id.' </br>';
|
||||
}
|
||||
print '<p><a class="tabAction" href="index.php">'.$langs->trans("Retour").'</a></p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,6 +69,7 @@ elseif (!($err = $client->getError()) )
|
||||
print "<td>Date</td>";
|
||||
print "<td>Montant</td>";
|
||||
print '<td align="center">Paiement</td>';
|
||||
print '<td align="center">Statut</td>';
|
||||
print '<TD align="center">Importer</TD>';
|
||||
print "</TR>\n";
|
||||
|
||||
@ -81,9 +82,10 @@ elseif (!($err = $client->getError()) )
|
||||
print '<TD><a href="../../commande/fiche.php?id='.$ordid.'">'.$ordid."</a> </TD>\n";
|
||||
print "<TD>".$result[$i][customers_name]."</TD>\n";
|
||||
print "<TD>".$result[$i][date_purchased]."</TD>\n";
|
||||
print "<TD>".$result[$i][value]."</TD>\n";
|
||||
$tot = convert_price($result[$i][total]) + convert_price($result[$i][port]);
|
||||
print "<TD>".$tot."</TD>\n";
|
||||
print '<TD align="center">'.' '.$result[$i][payment_method]."</TD>\n";
|
||||
// print '<TD align="center">'/*.$result[$i][customers_telephone]*/."</TD>\n";
|
||||
print '<TD align="center">'.$result[$i][statut]."</TD>\n";
|
||||
if ($ordid) $lib = "modifier";
|
||||
else $lib = "<u>importer</u>";
|
||||
print '<TD align="center"><a href="fiche.php?action=import&orderid='.$result[$i][orders_id].'">'.$lib."</a></TD>\n";
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
require("../clients/osc_customer.class.php");
|
||||
require("../produits/osc_product.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php");
|
||||
|
||||
require_once("../includes/configure.php");
|
||||
|
||||
|
||||
/**
|
||||
@ -49,6 +49,7 @@ class Osc_order
|
||||
var $osc_ordertotal;
|
||||
var $osc_orderpaymet;
|
||||
var $osc_orderport;
|
||||
var $osc_orderstatus;
|
||||
|
||||
var $osc_lines = array();
|
||||
|
||||
@ -154,7 +155,8 @@ class Osc_order
|
||||
|
||||
$commande->socid = $clientid;
|
||||
$commande->ref = $this->osc_orderid;
|
||||
$commande->date = $this->orderdate;
|
||||
$commande->date = $this->osc_orderdate;
|
||||
$commande->date_commande = $this->osc_orderdate;
|
||||
/* on force */
|
||||
$commande->statut = 0; //à voir
|
||||
$commande->source = 0; // à vérifier
|
||||
@ -164,19 +166,31 @@ class Osc_order
|
||||
for ($i = 0; $i < sizeof($this->osc_lines);$i++) {
|
||||
$commande->lines[$i]->libelle = $this->osc_lines[$i][products_id];
|
||||
$commande->lines[$i]->desc = $this->osc_lines[$i][products_name];
|
||||
$commande->lines[$i]->price = $this->osc_lines[$i][products_price];
|
||||
$commande->lines[$i]->subprice = $this->osc_lines[$i][products_price];
|
||||
$commande->lines[$i]->price = convert_price($this->osc_lines[$i][products_price]);
|
||||
$commande->lines[$i]->subprice = convert_price($this->osc_lines[$i][products_price]);
|
||||
$commande->lines[$i]->qty = $this->osc_lines[$i][quantity];
|
||||
$commande->lines[$i]->tva_tx = $this->osc_lines[$i][products_tax];
|
||||
$commande->lines[$i]->fk_product = $oscproduct->get_productid($this->osc_lines[$i][products_id]);
|
||||
$commande->lines[$i]->remise_percent = 0; // à calculer avec le finalprice
|
||||
}
|
||||
// les frais de port
|
||||
$fp = sizeof($this->osc_lines);
|
||||
$commande->lines[$fp]->libelle = "Frais de port";
|
||||
$commande->lines[$fp]->desc = "Frais de port";
|
||||
$commande->lines[$fp]->price = convert_price($this->osc_orderport);
|
||||
$commande->lines[$fp]->subprice = convert_price($this->osc_orderport);
|
||||
$commande->lines[$fp]->qty = 1;
|
||||
$commande->lines[$fp]->tva_tx = 0;
|
||||
$commande->lines[$fp]->fk_product = FK_PORT;
|
||||
$commande->lines[$fp]->remise_percent = 0;
|
||||
|
||||
return $commande;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
|
||||
|
||||
/**
|
||||
* \brief Mise à jour de la table de transition
|
||||
* \param oscid Id du produit dans OsC
|
||||
* \param prodid champ référence
|
||||
|
||||
@ -7,12 +7,26 @@
|
||||
----------------------------------------------*/
|
||||
|
||||
//base url des webservices
|
||||
define(OSCWS_DIR,'http://www.tiaris.info/ws_OSC');
|
||||
//define(OSCWS_DIR,'http://www.tiaris.info/ws_OSC');
|
||||
define(OSCWS_DIR,'http://www.tiaris.info/catalog/ws_OSC/');
|
||||
//affichages dans la page d'accueil
|
||||
define(OSC_MAXNBCOM, 5);
|
||||
define(OSC_ORDWAIT,'4'); // code du statut de commande en attente
|
||||
define(OSC_ORDPROCESS,'1'); // code du statut de commande en traitement
|
||||
//
|
||||
define(OSC_ENTREPOT, 1); //l'entrepot lié au stock du site web
|
||||
define(OSC_ENTREPOT, 1); //l'entrepot lié au stock du site web
|
||||
define(TX_CURRENCY, 1); // le taux de conversion monnaie site osc - monnaie dolibarr
|
||||
define(NB_DECIMALS, 0);
|
||||
define(FK_PORT, 0); // l'id du service frais de port défini.
|
||||
|
||||
// fonctions
|
||||
/**
|
||||
* \brief assure la conversion en monnaie de dolibarr
|
||||
* \param oscid Id du produit dans OsC
|
||||
* \param prodid champ référence
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function convert_price($price)
|
||||
{
|
||||
return round($price * TX_CURRENCY, NB_DECIMALS);
|
||||
}
|
||||
?>
|
||||
|
||||
@ -30,6 +30,7 @@
|
||||
require("./pre.inc.php");
|
||||
|
||||
$langs->load("boutique");
|
||||
$langs->load("orders");
|
||||
|
||||
|
||||
llxHeader("",$langs->trans("OSCOmmerceShop"));
|
||||
@ -60,13 +61,15 @@ $client = new soapclient(OSCWS_DIR."ws_orders.php");
|
||||
print_titre($langs->trans('SalesTurnover'));
|
||||
|
||||
print '<table class="noborder" cellspacing="0" cellpadding="3" width="100%">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Description").'</td>';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("année").'</td>';
|
||||
print '<td>'.$langs->trans("mois").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Total").'</td></tr>';
|
||||
|
||||
// Call the WebService and store its result in $result.
|
||||
$result = $client->call("get_CAmensuel",$parameters );
|
||||
if ($client->fault) {
|
||||
dolibarr_print_error('',"Erreur de connection ");
|
||||
print_r($client->faultstring);
|
||||
}
|
||||
elseif (!($err = $client->getError()) )
|
||||
{
|
||||
@ -80,8 +83,9 @@ elseif (!($err = $client->getError()) )
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td align="left">'.$result[$i][mois].'</td>';
|
||||
print '<td align="right">'.price($result[$i][value]).'</td>';
|
||||
print '<td align="left">'.$result[$i][an].'</td>';
|
||||
print '<td align="left">'.$result[$i][mois].'</td>';
|
||||
print '<td align="right">'.convert_price($result[$i][value]).'</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
@ -127,7 +131,7 @@ elseif (!($err = $client->getError()) ) {
|
||||
while ($i < $num) {
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
|
||||
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@ -163,10 +167,10 @@ elseif (!($err = $client->getError()) ) {
|
||||
$num = min($num,OSC_MAXNBCOM);
|
||||
|
||||
while ($i < $num) {
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
|
||||
$i++;
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,7 +205,7 @@ elseif (!($err = $client->getError()) ) {
|
||||
|
||||
while ($i < $num) {
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
|
||||
print '<td>'.$result[$i][orders_id].'</td><td>'.$result[$i][customers_name].'</td><td>'.convert_price($result[$i][value]).'</td><td>'.$result[$i][payment_method].'</td></tr>';
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
@ -240,7 +244,7 @@ elseif (!($err = $client->getError()) ) {
|
||||
|
||||
while ($i < $num) {
|
||||
print "<tr $bc[$var]>";
|
||||
print "<td>".$result[$i][date_purchased]."</td><td>".$result[$i][customers_name]."</td><td>".$result[$i][delivery_country]."</td><td>".price($result[$i][value])."</td><td>".$result[$i][payment_method]."</td><td>".$result[$i][orders_id]."</td><td>".$result[$i][statut]."</td></tr>";
|
||||
print "<td>".$result[$i][date_purchased]."</td><td>".$result[$i][customers_name]."</td><td>".$result[$i][delivery_country]."</td><td>".convert_price($result[$i][value])."</td><td>".$result[$i][payment_method]."</td><td>".$result[$i][orders_id]."</td><td>".$result[$i][statut]."</td></tr>";
|
||||
$i++;
|
||||
$var=!$var;
|
||||
}
|
||||
|
||||
@ -88,17 +88,7 @@ if ($action == '' && !$cancel) {
|
||||
print '<br>erreur 1</br>';
|
||||
// exit;
|
||||
}
|
||||
/* initialisation */
|
||||
$product->ref = $osc_prod->osc_ref;
|
||||
$product->libelle = $osc_prod->osc_name;
|
||||
$product->description = $osc_prod->osc_desc;
|
||||
$product->price = $osc_prod->osc_price;
|
||||
$product->tva_tx = $osc_prod->osc_tva;
|
||||
$product->type = 0;
|
||||
$product->seuil_stock_alerte = 0; /* on force */
|
||||
/* on force */
|
||||
$product->catid = 0; /* à voir avec la gestion des catégories */
|
||||
$product->status = 1; /* en vente */
|
||||
$product = $osc_prod->osc2dolibarr($_GET['id']);
|
||||
}
|
||||
|
||||
/* utilisation de la table de transco*/
|
||||
@ -106,7 +96,8 @@ if ($action == '' && !$cancel) {
|
||||
{
|
||||
print '<p>Ce produit existe déjà</p>';
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
$id = $product->create($user);
|
||||
|
||||
if ($id > 0)
|
||||
@ -129,31 +120,36 @@ if ($action == '' && !$cancel) {
|
||||
$_GET["action"] = "create";
|
||||
$_GET["type"] = $_POST["type"];
|
||||
}
|
||||
if ($id == -2)
|
||||
{
|
||||
/* la référence existe on fait un update */
|
||||
$product_control = new Product($db);
|
||||
if ($_error == 1)
|
||||
{
|
||||
print '<br>erreur 1</br>';
|
||||
exit;
|
||||
}
|
||||
$id = $product_control->fetch($ref = $osc_prod->osc_ref);
|
||||
if ($id == -2)
|
||||
{
|
||||
/* la référence existe on fait un update */
|
||||
$product_control = new Product($db);
|
||||
if ($_error == 1)
|
||||
{
|
||||
print '<br>erreur 1</br>';
|
||||
// exit;
|
||||
}
|
||||
$id = $product_control->fetch($ref = $osc_prod->osc_ref);
|
||||
|
||||
if ($id > 0)
|
||||
{
|
||||
$id = $product->update($id, $user);
|
||||
if ($id > 0) {
|
||||
$id_entrepot = 1;
|
||||
$id = $product->correct_stock($id_entrepot,$osc_prod->osc_stock);
|
||||
if ($id > 0)
|
||||
{
|
||||
$id = $product->update($id, $user);
|
||||
if ($id > 0)
|
||||
{
|
||||
$id_entrepot = 1;
|
||||
$id = $product->correct_stock($user, $id_entrepot,$osc_prod->osc_stock, 0);
|
||||
}
|
||||
else print '<br>Erreur update '.$product->error().'</br>';
|
||||
}
|
||||
else print '<br>Erreur update '.$id.'</br>';
|
||||
else print '<br>update impossible $id : '.$product_control->error().' </br>';
|
||||
}
|
||||
else print '<br>update impossible $id : '.$id.' </br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($id == -1)
|
||||
{
|
||||
print '<p>erreur'.$product->error().'</p>';
|
||||
}
|
||||
print '<p><a class="tabAction" href="index.php">'.$langs->trans("Retour").'</a></p>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
llxFooter('$Date$ - $Revision$');
|
||||
|
||||
@ -116,6 +116,35 @@ class Osc_product
|
||||
return 0;
|
||||
}
|
||||
|
||||
// renvoie un objet commande dolibarr
|
||||
function osc2dolibarr($osc_productid)
|
||||
{
|
||||
|
||||
$result = $this->fetch($osc_productid);
|
||||
if ( !$result )
|
||||
{
|
||||
$product = new Product($this->db);
|
||||
if ($_error == 1)
|
||||
{
|
||||
print '<br>erreur 1</br>';
|
||||
return '';
|
||||
}
|
||||
/* initialisation */
|
||||
$product->ref = $this->osc_ref;
|
||||
$product->libelle = $this->osc_name;
|
||||
$product->description = $this->osc_desc;
|
||||
$product->price = convert_price($this->osc_price);
|
||||
$product->tva_tx = $this->osc_tva;
|
||||
$product->type = 0;
|
||||
$product->seuil_stock_alerte = 0; /* on force */
|
||||
/* on force */
|
||||
$product->catid = 0; /* à voir avec la gestion des catégories */
|
||||
$product->status = 1; /* en vente */
|
||||
|
||||
return $product;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* \brief Mise à jour de la table de transition
|
||||
* \param oscid Id du produit dans OsC
|
||||
@ -157,7 +186,7 @@ class Osc_product
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// converti le client osc en client dolibarr
|
||||
// converti le produit osc en produit dolibarr
|
||||
|
||||
function get_productid($osc_product)
|
||||
{
|
||||
|
||||
@ -7,10 +7,10 @@
|
||||
----------------------------------------------*/
|
||||
|
||||
/* paramètres de connexion à OSC */
|
||||
define("OSC_DB_SERVER","");
|
||||
define("OSC_DB_SERVER_USERNAME", "");
|
||||
define("OSC_DB_SERVER_PASSWORD", "");
|
||||
define("OSC_DB_DATABASE", "");
|
||||
define("DB_SERVER","localhost");
|
||||
define("DB_SERVER_USERNAME", "root");
|
||||
define("DB_SERVER_PASSWORD", "");
|
||||
define("DB_DATABASE", "tahitirimai");
|
||||
|
||||
/* constantes utiles */
|
||||
define("OSC_LANGUAGE_ID",1);
|
||||
|
||||
@ -29,9 +29,10 @@ require_once('./lib/nusoap.php');
|
||||
|
||||
// Create the soap Object
|
||||
$s = new soap_server;
|
||||
$ns='oscommerce';
|
||||
/* $ns='oscommerce';
|
||||
$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns);
|
||||
$s->wsdl->schemaTargetNamespace=$ns;
|
||||
*/
|
||||
|
||||
// Register a method available for clients
|
||||
$s->register('get_article');
|
||||
|
||||
@ -29,9 +29,10 @@ require_once('./includes/configure.php');
|
||||
|
||||
// Create the soap Object
|
||||
$s = new soap_server;
|
||||
$ns='oscommerce';
|
||||
/* $ns='oscommerce';
|
||||
$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns);
|
||||
$s->wsdl->schemaTargetNamespace=$ns;
|
||||
*/
|
||||
|
||||
// Register the methods available for clients
|
||||
$s->register('get_Client');
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/* Copyright (C) 2006 Jean Heimburger <jean@tiaris.info>
|
||||
*
|
||||
*
|
||||
@ -19,24 +19,21 @@
|
||||
* $Source$
|
||||
*
|
||||
*/
|
||||
set_magic_quotes_runtime(0);
|
||||
|
||||
// Soap Server.
|
||||
require_once('./lib/nusoap.php');
|
||||
set_magic_quotes_runtime(0);
|
||||
|
||||
// Soap Server.
|
||||
require_once('./lib/nusoap.php');
|
||||
|
||||
require_once('./includes/configure.php');
|
||||
|
||||
// Create the soap Object
|
||||
$s = new soap_server;
|
||||
$ns='oscommerce';
|
||||
$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns);
|
||||
$s->wsdl->schemaTargetNamespace=$ns;
|
||||
|
||||
// Register the methods available for clients
|
||||
|
||||
// Create the soap Object
|
||||
$s = new soap_server;
|
||||
|
||||
// Register the methods available for clients
|
||||
$s->register('get_CAmensuel');
|
||||
$s->register('get_orders');
|
||||
$s->register('get_lastOrderClients');
|
||||
$s->register('get_Order');
|
||||
$s->register('get_Order');
|
||||
|
||||
/*----------------------------------------------
|
||||
* renvoie un tableau avec le CA mensuel réalisé
|
||||
@ -44,22 +41,23 @@ $s->register('get_Order');
|
||||
function get_CAmensuel() {
|
||||
|
||||
//on se connecte
|
||||
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connection impossible");
|
||||
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connection impossible");
|
||||
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
|
||||
|
||||
//la requête
|
||||
$sql = "SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois";
|
||||
$sql = "SELECT sum(t.value) as value, MONTH(o.date_purchased) as mois, YEAR(o.date_purchased) as an";
|
||||
$sql .= " FROM orders_total as t";
|
||||
$sql .= " JOIN 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";
|
||||
$sql .= " WHERE t.class = 'ot_subtotal' ";
|
||||
//AND YEAR(o.date_purchased) = YEAR(now()) ";
|
||||
$sql .= " GROUP BY an, mois ORDER BY an desc ,mois desc limit 1,12";
|
||||
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
|
||||
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 4", "produit inexistant");
|
||||
break;
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 4", $sql);
|
||||
break;
|
||||
default :
|
||||
$i = 0;
|
||||
while ( $i < $numrows) {
|
||||
@ -76,7 +74,7 @@ return $result;
|
||||
function get_orders($limit='', $status='') {
|
||||
|
||||
//on se connecte
|
||||
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connection impossible");
|
||||
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connection impossible");
|
||||
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
|
||||
|
||||
//on recherche
|
||||
@ -90,10 +88,10 @@ if ($limit > 0) $sql .= " LIMIT ".$limit;
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
|
||||
$result ='';
|
||||
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
//return new soap_fault("Server", "MySQL 4", "produit inexistant");
|
||||
break;
|
||||
break;
|
||||
default :
|
||||
$i = 0;
|
||||
while ( $i < $numrows) {
|
||||
@ -111,23 +109,23 @@ return $result;
|
||||
function get_lastOrderClients($id='',$name='',$limit='') {
|
||||
|
||||
//on se connecte
|
||||
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connection impossible");
|
||||
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connection impossible");
|
||||
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
|
||||
|
||||
//on recherche
|
||||
$sql = "SELECT o.orders_id, o.customers_name, o.delivery_country, o.date_purchased, t.value, s.orders_status_name as statut";
|
||||
$sql .= " FROM orders_total as t JOIN orders as o on o.orders_id = t.orders_id ";
|
||||
$sql .= " JOIN 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";
|
||||
$sql .= " WHERE t.class = 'ot_subtotal' and o.orders_status < 5 order by o.date_purchased desc";
|
||||
if ($limit > 0) $sql .= " LIMIT ".$limit;
|
||||
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
|
||||
$result ='';
|
||||
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 4", "produit inexistant");
|
||||
break;
|
||||
break;
|
||||
default :
|
||||
$i = 0;
|
||||
while ( $i < $numrows) {
|
||||
@ -147,24 +145,31 @@ function get_Order($orderid="0")
|
||||
{
|
||||
|
||||
//on se connecte
|
||||
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connection impossible");
|
||||
if (!($connexion = mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD))) return new soap_fault("Server", "MySQL 1", "connection impossible");
|
||||
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
|
||||
|
||||
//on recherche la commande
|
||||
$sql = "SELECT o.orders_id, o.customers_name, o.customers_id, o.date_purchased, t.value, o.payment_method ";
|
||||
/*$sql = "SELECT o.orders_id, o.customers_name, o.customers_id, o.date_purchased, t.value, o.payment_method ";
|
||||
$sql .= " FROM orders_total as t JOIN orders as o on o.orders_id = t.orders_id ";
|
||||
$sql .= " WHERE t.class = 'ot_subtotal'";
|
||||
if ($orderid > 0) $sql .= " and o.orders_id = ".$orderid;
|
||||
*/
|
||||
$sql = "SELECT o.orders_id, o.customers_name, o.customers_id, o.date_purchased, o.payment_method, t.value as total, sum(p.value) as port, s.orders_status_name as statut ";
|
||||
$sql .= " FROM orders as o ";
|
||||
$sql .= " JOIN orders_total as t on o.orders_id = t.orders_id and t.class = 'ot_subtotal' ";
|
||||
$sql .= " JOIN orders_total as p on o.orders_id = p.orders_id and (p.class = 'ot_shipping' OR p.class = 'ot_fixed_payment_chg') ";
|
||||
$sql .= " JOIN orders_status as s on o.orders_status = s.orders_status_id and s.language_id = 1";
|
||||
$sql .= " WHERE o.orders_status < 5 "; // élimine les commandes annulées, remboursées
|
||||
if ($orderid > 0) $sql .= " AND o.orders_id = ".$orderid;
|
||||
$sql .= " GROUP BY p.orders_id ";
|
||||
$sql .= " ORDER BY o.date_purchased desc";
|
||||
|
||||
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
|
||||
$result ='';
|
||||
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 4", "commande inexistante");
|
||||
break;
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 4", "commande inexistante ".$sql);
|
||||
break;
|
||||
default :
|
||||
$i = 0;
|
||||
while ( $i < $numrows) {
|
||||
@ -185,10 +190,10 @@ if ($orderid > 0)
|
||||
|
||||
if (!($resquer = mysql_query($sql,$connexion))) return new soap_fault("Server", "MySQL 3 ".$sql, mysql_error());
|
||||
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
switch ($numrows = mysql_numrows($resquer)) {
|
||||
case 0 :
|
||||
return new soap_fault("Server", "MySQL 5", "commande sans articles");
|
||||
break;
|
||||
break;
|
||||
default :
|
||||
|
||||
while ( $i < $numrows) {
|
||||
@ -203,8 +208,8 @@ mysql_close($connexion);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// Return the results.
|
||||
|
||||
// Return the results.
|
||||
$s->service($HTTP_RAW_POST_DATA);
|
||||
|
||||
?>
|
||||
|
||||
?>
|
||||
|
||||
@ -1,25 +1,25 @@
|
||||
<?php
|
||||
set_magic_quotes_runtime(0);
|
||||
|
||||
// Soap Server.
|
||||
require_once('./lib/nusoap.php');
|
||||
|
||||
// Create the soap Object
|
||||
$s = new soap_server;
|
||||
<?php
|
||||
set_magic_quotes_runtime(0);
|
||||
|
||||
// Soap Server.
|
||||
require_once('./lib/nusoap.php');
|
||||
|
||||
// Create the soap Object
|
||||
$s = new soap_server;
|
||||
$ns='oscommerce';
|
||||
$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns);
|
||||
$s->wsdl->schemaTargetNamespace=$ns;
|
||||
|
||||
// Register a method available for clients
|
||||
$s->register('hello');
|
||||
|
||||
function hello($name){
|
||||
|
||||
$returnedString = "Hello de Tetiaroa ".$name." !";
|
||||
return $returnedString;
|
||||
|
||||
}
|
||||
|
||||
// Return the results.
|
||||
$s->service($HTTP_RAW_POST_DATA);
|
||||
?>
|
||||
|
||||
// Register a method available for clients
|
||||
$s->register('hello');
|
||||
|
||||
function hello($name){
|
||||
|
||||
$returnedString = "Hello de Tetiaroa ".$name." !";
|
||||
return $returnedString;
|
||||
|
||||
}
|
||||
|
||||
// Return the results.
|
||||
$s->service($HTTP_RAW_POST_DATA);
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user