* * 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$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once("../includes/configure.php"); llxHeader(); if ($action == '' && !$cancel) { if ($_GET['id']) { $osc_prod = new Osc_product($db, $_GET['id']); $result = $osc_prod->fetch($_GET['id']); if ( !$result) { print '
Fiche article OSC : '.$osc_prod->osc_name.'

'; print ''; print ''; print ''; print ''; print ''; print ''; print "
Descrption'.$osc_prod->osc_desc.'
ref'.$osc_prod->osc_ref.'
Id'.$osc_prod->osc_id.'
Prix'.$osc_prod->osc_price.'
Four_id'.$osc_prod->osc_four.'
"; /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print "\n
\n"; if ($user->rights->produit->creer || $user->rights->service->creer) { print ''.$langs->trans("Import").''; } print ''.$langs->trans("Retour").''; print "\n

\n"; // seule action importer } else { print "

ERROR 1

\n"; dol_print_error('',"erreur webservice ".$osc_prod->error); } } else { print "

ERROR 1

\n"; print "Error"; } } /* action Import cr�ation de l'objet product de dolibarr * */ if (($_GET["action"] == 'import' ) && ( $_GET["id"] != '' ) && ($user->rights->produit->creer || $user->rights->service->creer)) { $osc_prod = new Osc_product($db, $_GET['id']); $result = $osc_prod->fetch($_GET['id']); if ( !$result ) { $product = new Product($db); if ($_error == 1) { print '
erreur 1
'; // exit; } $product = $osc_prod->osc2dolibarr($_GET['id']); } else { print "

erreur $osc_prod->fetch

"; } /* utilisation de la table de transco*/ if ($osc_prod->get_productid($osc_prod->osc_id)>0) { print '

Ce produit existe d�j�

'; } else { $id = $product->create($user); if ($id > 0) { print "\n
\n"; $prod = new Product($db); $res = $prod->fetch($id); $prod->add_photo_web($conf->produit->dir_output,$osc_prod->osc_image); print '

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.'

'; print ''.$langs->trans("Retour").''; print "\n

\n"; $id_entrepot = OSC_ENTREPOT; $id = $product->create_stock($user, $id_entrepot,$osc_prod->osc_stock); // if ($id > 0) exit; } else { print "

On a une erreur".$id."

"; if ($id == -3) { $_error = 1; $_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 '
erreur 1
'; // 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($user, $id_entrepot,$osc_prod->osc_stock, 0); } else print '
Erreur update '.$product->error().'
'; } else print '
update impossible $id : '.$product_control->error().'
'; } if ($id == -1) { print '

erreur'.$product->error().'

'; } print '

'.$langs->trans("Retour").'

'; } } } llxFooter('$Date$ - $Revision$'); ?>