diff --git a/htdocs/document.php b/htdocs/document.php index 724c56c0ae3..ff6f7b90007 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -1,6 +1,7 @@ * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2005 Simon Tosser * * 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 @@ -142,6 +143,17 @@ if ($modulepart) //} $original_file=$conf->commercial->dir_output.'/'.$original_file; } + + // Wrapping pour les produits et services + if ($modulepart == 'produit') + { + $user->getrights('produit'); + //if ($user->rights->commercial->lire) // Ce droit n'existe pas encore + //{ + $accessallowed=1; + //} + $original_file=$conf->produit->dir_output.'/'.$original_file; + } } diff --git a/htdocs/product/document.php b/htdocs/product/document.php new file mode 100755 index 00000000000..3367978d3bf --- /dev/null +++ b/htdocs/product/document.php @@ -0,0 +1,230 @@ + + * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005 Regis Houssin + * Copyright (C) 2005 Simon TOSSER + * + * 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('../product.class.php'); + +$user->getrights('produit'); + +if (!$user->rights->produit->lire) + accessforbidden(); + + + +llxHeader(); + +$productid=empty($_GET['id']) ? 0 : intVal($_GET['id']); +$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; + + +function do_upload ($upload_dir) +{ + global $local_file, $error_msg, $langs; + + if (! is_dir($upload_dir)) + { + create_exdir($upload_dir); + } + + if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . '/' . $_FILES['userfile']['name'])) + { + echo $langs->trans('FileUploaded'); + } + else + { + echo $langs->trans('FileNotUploaded'); + } +} + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + +if ($productid > 0) +{ + $product = new Product($db); + + if ($product->fetch($productid)) + { + $prodref = sanitize_string($product->ref); + $upload_dir = $conf->produit->dir_output.'/'.$prodref; + if ( $error_msg ) + { + echo ''.$error_msg.'

'; + } + +/******************************************************************************/ +/* Actions */ +/******************************************************************************/ + if ($action=='delete') + { + $file = $upload_dir . '/' . urldecode($_GET['urlfile']); + dol_delete_file($file); + } + + if ( $_POST['sendit'] ) + { + do_upload ($upload_dir); + } + + $h=0; + + $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Card"); + $hselected = $h; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; + $head[$h][1] = $langs->trans("Price"); + $h++; + + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][1] = $langs->trans("Photos"); + $h++; + + if($product->type == 0) + { + if ($conf->stock->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; + $head[$h][1] = $langs->trans("Stock"); + $h++; + } + } + + if ($conf->fournisseur->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; + $head[$h][1] = $langs->trans("Suppliers"); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans('Statistics'); + $h++; + + //erics: pour créer des produits composés de x 'sous' produits + $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; + $head[$h][1] = $langs->trans('Packs'); + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans('Referers'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; + $head[$h][1] = $langs->trans('Documents'); + $hselected=$h; + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans('Product').': '.$product->ref); + + print_titre($langs->trans('AssociatedDocuments').' '.$product->ref_url); + + print '
'; + print ''; + print '
'; + print ''; + print '
'; + print '

'; + + clearstatcache(); + + $errorlevel=error_reporting(); + error_reporting(0); + $handle=opendir($upload_dir); + error_reporting($errorlevel); + + print ''; + + if ($handle) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + while (($file = readdir($handle))!==false) + { + if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $var=!$var; + print ''; + print '\n"; + print ''; + print ''; + print '\n"; + } + } + closedir($handle); + } + else + { + print '
'.$langs->trans('ErrorCantOpenDir').' '.$upload_dir.'
'; + } + print '
'.$langs->trans('Document').''.$langs->trans('Size').''.$langs->trans('Date').' 
'; + echo ''.$file.''; + print "'.filesize($upload_dir.'/'.$file). ' bytes'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).''; + if ($file == $propref . '.pdf') + { + echo '-'; + } + else + { + echo ''.$langs->trans('Delete').''; + } + print "
'; + + print ''; + } + else + { + dolibarr_print_error($db); + } +} +else +{ + print $langs->trans("UnkownError"); +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 4174e294561..92c00c93cf6 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -360,6 +360,9 @@ if ($_GET["id"]) $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; $head[$h][1] = $langs->trans('Referers'); $h++; + $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; + $head[$h][1] = $langs->trans('Documents'); + $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref);