Ajout patch Jean

This commit is contained in:
Laurent Destailleur 2007-06-27 20:18:19 +00:00
parent f5f8a498bd
commit 8a05524001
15 changed files with 767 additions and 22 deletions

View File

@ -41,6 +41,7 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/oscommerce_ws/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/", $langs->trans("Products"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/categories.php", $langs->trans("Categories"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/clients/", $langs->trans("Clients"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/commandes/", $langs->trans("Commandes"));

View File

@ -157,7 +157,12 @@ if ($action == '' && !$cancel) {
for ($lig = 0; $lig < sizeof($commande->lines); $lig++)
{
if (! $commande->lines[$lig]->fk_product) $err ++;
// print "<p>traitement de ".$commande->lines[$lig]->fk_product."</p>";
if (! $commande->lines[$lig]->fk_product)
{
print "<p>Article non trouvé ".$commande->lines[$lig]->libelle." : ".$commande->lines[$lig]->desc."</p>";
$err ++;
}
}
if ($err > 0) {
print ("<p> Des produits de la commande sont inexistants</p>");

View File

@ -41,6 +41,7 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/oscommerce_ws/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/", $langs->trans("Products"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/categories.php", $langs->trans("Categories"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/clients/", $langs->trans("Clients"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/commandes/", $langs->trans("Commandes"));

View File

@ -1,22 +1,49 @@
<?php
/*---------------------------------------------
/ Webservices OSC pour dolibarr
/ configuration des clients
/
/ Jean Heimburger juin 2006
----------------------------------------------*/
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Jean Heimburger jean@tiaris.info 2007
*/
/**
\file htdocs/oscommmerce_ws/includes/configure.php
\ingroup oscommerce_ws
\brief Configuration client Webservice
\version $Revision$
*/
//base url des webservices
define(OSCWS_DIR,'http://www.tiaris.info/catalog/ws_OSC/');
define(OSC_URL, 'http://www.tiaris.info/catalog/'); // url du site 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(TX_CURRENCY, 1); // le taux de conversion monnaie site osc - monnaie dolibarr
define(TX_CURRENCY, 119.33); // le taux de conversion monnaie site osc - monnaie dolibarr (1 euro = 119.33 XPF)
define(NB_DECIMALS, 0);
define(FK_PORT, 0); // l'id du service frais de port défini.
define(NB_DECIMALSITE, 2); // nb de décimales sur le site
define(FK_PORT, 159); // l'id du service frais de port défini.
// fonctions
@ -26,8 +53,20 @@ define(FK_PORT, 0); // l'id du service frais de port d
* \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);
}
function convert_price($price)
{
return round($price * TX_CURRENCY, NB_DECIMALS);
}
/**
* \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_backprice($price)
{
return round($price / TX_CURRENCY, NB_DECIMALSITE);
}
?>

View File

@ -40,6 +40,8 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/oscommerce_ws/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/index.php", $langs->trans("Products"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/OSCvente.php", $langs->trans("AddProd"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/categories.php", $langs->trans("Categories"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/clients/index.php", $langs->trans("Clients"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/commandes/index.php", $langs->trans("Commandes"));

View File

@ -0,0 +1,165 @@
<?php
/* Copyright (C) 2006 Jean Heimburger <jean@tiaris.info>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/oscommerce_ws/includes/configure.php");
llxHeader();
$html = new Form($db);
if ($_GET["action"] == 'liste' )
{
// affichage des produits en vente à partir de la tavle de transco
$sql = "SELECT o.doli_prodidp as idp, o.osc_prodid as oscid, o.osc_lastmodif as date ";
$sql .= "FROM ".MAIN_DB_PREFIX."osc_product as o";
if ( $db->query($sql) )
{
$langs->load("products");
$num = $db->num_rows();
if ($num)
{
$i = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("OscProds").'</td></tr>';
$var = True;
while ($i < $num)
{
$var=!$var;
$obj = $db->fetch_object();
print '<tr $bc[$var]><td nowrap><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$obj->idp.'">'.img_object($langs->trans("ShowProduct"),"Product").' '.$obj->idp.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("OscProd"),"Product").' '.$obj->oscid.'</a></td></tr>';
$i++;
}
print "</table><br>";
}
}
}
if ($_GET["action"] == 'vendre' )
{
$product = new Product($db, $_POST["idprod"]);
$oscprod = new Osc_product($db);
$oscid = $oscprod->get_osc_productid($_POST["idprod"]);
if ( $oscid < 0)
{
$prod = array();
$prod['ref'] = $product->ref;
$prod['nom'] = $product->libelle;
$prod['desc'] = $product->description;
$prod['quant'] = $_POST["qty"];
$prod['prix'] = convert_backprice($product->price);
// à gèrer $product->tx_tva
$prod['poids'] = $product->weight;
// gèrer $product->weight_units
$prod['dispo'] = '';
$prod['status'] = '1';
$prod['fourn'] = '';
$prod['url'] = '';
//recherche de l'image
$pdir = get_exdir($product->id,2) . $product->id ."/photos/";
$dir = $conf->produit->dir_output . '/'. $pdir;
$img = $product->liste_photos($dir);
if (sizeof($img) ==0) $prod['image'] = '';
else
{
if ($img[0]['photo_vignette']) $filename=$img[0]['photo_vignette'];
else $filename=$img[0]['photo'];
$prod['image'] = dolibarr_trunc($filename,16);
}
// print_r($prod);
// print '<br/>';
set_magic_quotes_runtime(0);
//WebService Client.
require_once(NUSOAP_PATH."/nusoap.php");
// Création
// Set the parameters to send to the WebService
$parameters = array("prod"=>$prod);
// Set the WebService URL
$client = new soapclient(OSCWS_DIR."ws_articles.php");
// Call the WebService and store its result in $result.
$result = $client->call("create_article",$parameters );
if ($client->fault)
{
$this->error="Fault detected";
return -1;
}
elseif (!($err=$client->getError()) )
{
if ($result > 0)
{
// création de l'enregistrement dans osc_products
$oscprod->transcode($result,$_POST["idprod"]);
print "<p>le produit ".$product->ref." ".$product->libelle.' est en vente en ligne <a href="'.OSC_URL.'product_info.php?products_id='.$result.'">consulter</a></p>';
print "\n";
// print_r($result);
}
}
}
else
{
print "<p>Le produit ".$_POST["idprod"].' est déjà en vente en ligne : <a href="'.OSC_URL.'product_info.php?products_id='.$oscid.'">consulter</a></p>';
print "\n";
}
}
/* choix du produit */
print '<table class="noborder">';
print '<tr><td>'.$langs->trans('ProductsAndServices').'</td>';
print '<td>'.$langs->trans('Qty').'</td>';
print '</tr>';
print '<form action="OSCvente.php?action=vendre" method="POST">';
print '<input type="hidden" name="prod" value="test"/>';
print '<tr><td>';
print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size,$soc->price_level);
print '</td>';
print '<td><input type="text" size="3" name="qty'.$i.'" value="1"></td></tr>';
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans('Oscsell').'"></td></tr>';
print '</form>';
print '</table>';
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
print '<a class="tabAction" href="../index.php">'.$langs->trans("Retour").'</a>';
print '<a class="tabAction" href="OSCvente.php?action=liste">'.$langs->trans("Liste").'</a>';
print "\n</div>\n";
llxFooter('$Date$ - $Revision$');
?>

View File

@ -0,0 +1,174 @@
<?php
/* Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file dev/skeletons/skeleton_page.php
\ingroup core
\brief Example of a php page
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php");
require("osc_categories.class.php");
//require_once(DOL_DOCUMENT_ROOT."/../dev/skeletons/skeleton_class.class.php");
// Load traductions files
$langs->load("companies");
$langs->load("other");
// Load permissions
//$user->getrights("commercial");
//if (!$user->rights->categorie->lire) accessforbidden();
// Get parameters
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
// Protection quand utilisateur externe
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
//if ($socid == '') accessforbidden();
/*******************************************************************
* ACTIONS
*
* Put here all code to do according to value of "action" parameter
********************************************************************/
if ($_REQUEST["action"] == 'maj')
{
$myobject=new Osc_categorie($db);
if ($myobject->fetch_dolicat($_POST["dolicat"]) <0)
{
$mesg = "erreur dans fetch_dolicat";
}
elseif ($myobject->id > 0)
{
$myobject->dolicatid=$_POST["dolicat"];
$myobject->osccatid=$_POST["osccat"];
$result=$myobject->update($user);
if ($result > 0)
{
// Creation OK
$mesg="";
}
else
{
// Creation KO
$mesg=$myobject->error;
}
}
else
{
$myobject->dolicatid=$_POST["dolicat"];
$myobject->osccatid=$_POST["osccat"];
$result=$myobject->create($user);
if ($result > 0)
{
// Creation OK
$mesg="";
}
else
{
// Creation KO
$mesg=$myobject->error;
}
}
}
/***************************************************
* PAGE
*
* Put here all code to build page
****************************************************/
llxHeader();
$html=new Form($db);
if ($mesg) print "<p>".$mesg."</p>";
// Put here content of your page
// ...
if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit;
$offset = $limit * $page ;
$sql = "SELECT c.label, c.rowid dolicatid, oc.osccatid FROM ".MAIN_DB_PREFIX."categorie as c ";
$sql .= "LEFT OUTER JOIN llx_osc_categories as oc ON oc.dolicatid = c.rowid ";
$sql .= "WHERE c.visible = 1";
print_barre_liste("Correspondance des catégories", $page, "categories.php");
dolibarr_syslog("Osc_Categorie.class::get_Osccat sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
//titre
print '<table border="0" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre">';
print '<td>Id</td><td>Label</td><td>Osc_id</td><td>Action</td>';
print '</tr>'."\n";
$var=true;
$oscid = 1;
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($resql);
$var=!$var;
print "\t<tr ".$bc[$var].">\n";
print "\t\t<td><a href='../../categories/viewcat.php?id=".$obj->dolicatid."'>".$obj->dolicatid."</a></td>\n";
print "\t\t<td><a href='../../categories/viewcat.php?id=".$obj->dolicatid."'>".$obj->label."</a></td>\n";
print '<td><form action="categories.php" METHOD="POST"><input type="text" size="5" name="osccat" value="'.$obj->osccatid.'"/></td>'."\n";
print '<input type="hidden" name="action" value="maj"/>';
print '<input type="hidden" name="dolicat" value="'.$obj->dolicatid.'"/>';
print '<td align="center"><input type="submit" class="button" value="'.$langs->trans('maj').'"></td>';
print "\t</tr></form>\n";
$i++;
}
print '</table>';
}
else
{
dolibarr_print_error();
}
// End of page
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -75,6 +75,7 @@ if ($action == '' && !$cancel) {
/* action Import création de l'objet product de dolibarr
*
*/
if (($_GET["action"] == 'import' ) && ( $_GET["id"] != '' ) && $user->rights->produit->creer)
{
$osc_prod = new Osc_product($db, $_GET['id']);
@ -89,7 +90,11 @@ if ($action == '' && !$cancel) {
// exit;
}
$product = $osc_prod->osc2dolibarr($_GET['id']);
}
}
else
{
print "<p>erreur $osc_prod->fetch</p>";
}
/* utilisation de la table de transco*/
if ($osc_prod->get_productid($osc_prod->osc_id)>0)
@ -98,15 +103,22 @@ if ($action == '' && !$cancel) {
}
else
{
$id = $product->create($user);
if ($id > 0)
{
print "\n<div class=\"tabsAction\">\n";
$prod = new Product($db);
$res = $prod->fetch($id);
$prod->add_photo_web($conf->produit->dir_output,$osc_prod->osc_image);
print '<p>création réussie produit '.$id.' référence : '.$product->ref;
$res = $osc_prod->transcode($osc_prod->osc_id,$product->id);
print ' Id osc : '.$osc_prod->osc_id.'</p>';
print '<a class="butAction" href="index.php">'.$langs->trans("Retour").'</a>';
print "\n</div><br>\n";
$id_entrepot = OSC_ENTREPOT;
$id = $product->create_stock($id_entrepot,$osc_prod->osc_stock);
@ -114,6 +126,7 @@ if ($action == '' && !$cancel) {
}
else
{
print "<p>On a une erreur".$id."</p>";
if ($id == -3)
{
$_error = 1;

View File

@ -88,7 +88,7 @@ elseif (!($err = $client->getError()) )
if ($prodid) $lib = "modifier";
else $lib = "<u>importer</u>";
print '<TD align="center"><a href="fiche.php?action=import&id='.$result[$i][OSC_id].'"'.">".$lib."</a></TD>\n";
print "</TR>\n";
print '</TR>'."\n";
$i++;
}
print "</table></p>";
@ -98,7 +98,7 @@ elseif (!($err = $client->getError()) )
}
}
else {
dolibarr_print_error('',"Erreur service web ".$err);
dolibarr_print_error('',"Erreur service web ".$client->faultstring);
}
print "</TABLE>";

View File

@ -0,0 +1,313 @@
<?php
/* Copyright (C) 2007 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
* $Source$
*/
/**
\file dev/skeletons/Osc_Categorie.class.class.php
\ingroup core
\brief Example for class
\version $Revision$
*/
// Put here all includes required by your script
//require_once(DOL_DOCUMENT_ROOT."/societe.class.php");
//require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
//require_once(DOL_DOCUMENT_ROOT."/product.class.php");
/**
\class Osc_Categorie.class
\brief Class description
*/
class Osc_Categorie
{
var $db;
var $error='';
var $errors=array();
var $id;
var $dolicatid;
var $osccatid;
/**
* \brief Constructor
* \param DB Database handler
*/
function Osc_Categorie($DB)
{
$this->db = $DB;
return 1;
}
/**
* \brief Create in database
* \param user User that create
* \return int <0 si ko, >0 si ok
*/
function create($user)
{
global $conf, $langs;
// Clean parameters
$this->dolicatid=trim($this->dolicatid);
$this->ocscatid=trim($this->ocscatid);
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."osc_categories";
$sql.= "( dolicatid, osccatid)";
$sql.= " VALUES (";
$sql.= " '".$this->dolicatid."',";
$sql.= " '".$this->osccatid."'";
$sql.= ")";
dolibarr_syslog("Osc_Categorie.class::create sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."osc_categories");
/* $resql=$this->update($user, 1);
if ($resql < 0)
{
$this->error=$this->db->lasterror();
return -2;
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
if ($result < 0) $this->errors=$interface->errors;
// Fin appel triggers
$this->id = $newid;
*/
return $this->id;
}
else
{
$this->error=$this->db->lasterror();
$this->error = $sql;
dolibarr_syslog("Osc_Categorie.class::create ".$this->error);
return -1;
}
}
/*
* \brief Update database
* \param user User that modify
* \param notrigger 0=no, 1=yes (no update trigger)
* \return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
global $conf, $langs;
// Clean parameters
$this->dolicatid=trim($this->dolicatid);
$this->ocscatid=trim($this->ocscatid);
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."osc_categories SET";
$sql.= " dolicatid='".addslashes($this->dolicatid)."',";
$sql.= " osccatid='".addslashes($this->osccatid)."'";
$sql.= " WHERE rowid=".$this->id;
dolibarr_syslog("Osc_Categorie.class::update sql=".$sql,LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error=$this->db->lasterror().' sql='.$sql;
return -1;
}
if (! $notrigger)
{
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) $this->errors=$interface->errors;
// Fin appel triggers
}
return 1;
}
/*
* \brief Load object in memory from database
* \param id id object
* \param user User that load
* \return int <0 if KO, >0 if OK
*/
function fetch($id, $user=0)
{
global $langs;
$sql = "SELECT t.rowid, t.dolicatid, t.osccatid";
$sql.= " FROM ".MAIN_DB_PREFIX."osc_categories as t";
$sql.= " WHERE c.rowid = ".$id;
dolibarr_syslog("Osc_Categorie.class::fetch sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->dolicatid = $obj->dolicatid;
$this->ocscatid = $obj->osccatid;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Osc_Categorie.class::fetch ".$this->error);
return -1;
}
}
/*
* \brief Load object in memory from database
* \param id id object
* \param user User that load
* \return int <0 if KO, >0 if OK
*/
function fetch_osccat($oscid, $user=0)
{
global $langs;
$sql = "SELECT t.rowid, t.dolicatid, t.osccatid";
$sql.= " FROM ".MAIN_DB_PREFIX."osc_categories as t";
$sql.= " WHERE t.osccatid = ".$oscid;
dolibarr_syslog("Osc_Categorie.class::fetch_osccat sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->dolicatid = $obj->dolicatid;
$this->osccatid = $obj->osccatid;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Osc_Categorie.class::fetch_osccat ".$this->error);
return -1;
}
}
/*
* \brief Load object in memory from database
* \param id id object
* \param user User that load
* \return int <0 if KO, >0 if OK
*/
function fetch_dolicat($doliid, $user=0)
{
global $langs;
$sql = "SELECT t.rowid, t.dolicatid, t.osccatid";
$sql.= " FROM ".MAIN_DB_PREFIX."osc_categories as t";
$sql.= " WHERE t.dolicatid = ".$doliid;
dolibarr_syslog("Osc_Categorie.class::fetch_dolicat sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->dolicatid = $obj->dolicatid;
$this->ocscatid = $obj->osccatid;
}
$this->db->free($resql);
return 1;
}
else
{
$this->error="Error ".$this->db->lasterror();
dolibarr_syslog("Osc_Categorie.class::fetch_dolicat ".$this->error);
return -1;
}
}
/*
* \brief Delete object in database
* \param user User that delete
* \return int <0 if KO, >0 if OK
*/
function delete($user)
{
global $conf, $langs;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."osc_categories";
$sql.= " WHERE rowid=".$this->id;
dolibarr_syslog("Osc_Categorie.class::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql)
{
$this->error=$this->db->lasterror().' sql='.$sql;
return -1;
}
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
if ($result < 0) $this->errors=$interface->errors;
// Fin appel triggers
return 1;
}
/**
* \brief Initialise object with example values
* \remarks id must be 0 if object instance is a specimen.
*/
function initAsSpecimen()
{
$this->id=0;
$this->dolicatid=0;
$this->osccatid=0;
}
}
?>

View File

@ -45,6 +45,7 @@ class Osc_product
var $osc_stockmini;
var $osc_stock;
var $osc_four;
var $osc_image;
var $error;
@ -108,6 +109,7 @@ class Osc_product
$this->osc_stock = $obj[products_quantity];
$this->osc_four = $obj[manufacturers_id];
$this->osc_price = $obj[products_price];
$this->osc_image = $obj[image];
}
else {
$this->error = 'Erreur '.$err ;
@ -200,7 +202,17 @@ class Osc_product
else return '';
}
function get_osc_productid($productidp)
{
$sql = "SELECT osc_prodid";
$sql.= " FROM ".MAIN_DB_PREFIX."osc_product";
$sql.= " WHERE doli_prodidp = ".$productidp;
$result=$this->db->query($sql);
$row = $this->db->fetch_row($resql);
// test d'erreurs
if ($row) return $row[0];
else return -1;
}
/**
* \brief création d'un article dans base OSC

View File

@ -41,6 +41,8 @@ function llxHeader($head = "", $urlp = "")
$menu->add(DOL_URL_ROOT."/oscommerce_ws/index.php", $langs->trans("OSCommerceShop"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/", $langs->trans("Products"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/OSCvente.php", $langs->trans("AddProd"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/produits/categories.php", $langs->trans("Categories"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/clients/", $langs->trans("Clients"));
$menu->add_submenu(DOL_URL_ROOT."/oscommerce_ws/commandes/", $langs->trans("Commandes"));

View File

@ -11,8 +11,11 @@ define("DB_SERVER","localhost");
define("DB_SERVER_USERNAME", "root");
define("DB_SERVER_PASSWORD", "");
define("DB_DATABASE", "tahitirimai");
// chemin vers sources OSC admin
define('OSCADMIN', '/home/jean/projets/osc_tiaris/admin/');
/* constantes utiles */
define("OSC_LANGUAGE_ID",1);
define(OSC_URL, 'http://osc-tiaris/'); // url du site OSC
?>

View File

@ -24,8 +24,11 @@ set_magic_quotes_runtime(0);
require_once("./includes/configure.php");
define(OSC_IMG_URL, 'http://www.tiaris.info/catalog/images/'); // url du site OSC
// OSC
define('OSCADMIN', '/home/jean/projets/osc_tiaris/admin/');
define('OSCIMAGES', '/home/jean/projets/osc_tiaris/images/');
require(OSCADMIN.'includes/configure.php');
require(OSCADMIN.DIR_WS_CLASSES . 'object_info.php');
@ -49,6 +52,8 @@ $s->register('get_article');
$s->register('get_listearticles');
$s->register('create_article');
function create_article($prod)
{
// make a connection to the database... now
@ -98,7 +103,7 @@ function get_article($id='',$ref='') {
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
//on recherche
$sql = "SELECT p.products_id, p.products_model, p.products_quantity, p.products_status, p.products_price, d.products_name, d.products_description, m.manufacturers_name, m.manufacturers_id";
$sql = "SELECT p.products_id, p.products_model, p.products_quantity, p.products_status, concat('".OSC_IMG_URL."',p.products_image) as image, p.products_price, d.products_name, d.products_description, m.manufacturers_name, m.manufacturers_id";
$sql .= " FROM products as p ";
$sql .= " JOIN products_description as d ON p.products_id = d.products_id "; $sql .= " LEFT JOIN manufacturers as m ON p.manufacturers_id=m.manufacturers_id";
$sql .= " WHERE d.language_id =" . OSC_LANGUAGE_ID;
@ -130,7 +135,7 @@ function get_listearticles() {
if (!($db = mysql_select_db(DB_DATABASE, $connexion))) return new soap_fault("Server", "MySQL 2", mysql_error());
//on recherche
$sql = "SELECT p.products_id as OSC_id, p.products_model as model, p.products_quantity as quantity, p.products_status as status, d.products_name as name, m.manufacturers_name as manufacturer, m.manufacturers_id";
$sql = "SELECT p.products_id as OSC_id, p.products_model as model, p.products_quantity as quantity, p.products_status as status, concat('".OSC_IMG_URL."',p.products_image) as image, d.products_name as name, m.manufacturers_name as manufacturer, m.manufacturers_id";
$sql .= " FROM products as p";
$sql .= " JOIN products_description as d ON p.products_id = d.products_id "; $sql .= " LEFT JOIN manufacturers as m ON p.manufacturers_id=m.manufacturers_id";
$sql .= " WHERE d.language_id =" . OSC_LANGUAGE_ID;
@ -154,6 +159,14 @@ function get_listearticles() {
return $liste_articles;
}
function saveImage($name,$content)
{
$fich = fopen(OSCIMAGES.$name, 'wb');
fwrite($fich,base64_decode($content));
fclose($fich);
return $name.' enregistré';
}
// Return the results.
$s->service($HTTP_RAW_POST_DATA);

View File

@ -7,15 +7,16 @@ require_once('./lib/nusoap.php');
// Create the soap Object
$s = new soap_server;
$ns='oscommerce';
$s->configureWSDL('WebServicesOSCommerceForDolibarr',$ns);
$s->wsdl->schemaTargetNamespace=$ns;
#$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." !";
$returnedString = "Coucou ** de Tetiaroa ".$name." !";
return $returnedString;
}
@ -23,3 +24,4 @@ return $returnedString;
// Return the results.
$s->service($HTTP_RAW_POST_DATA);
?>