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