diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 71bec12d9e1..4c0fc5618db 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -851,30 +851,31 @@ class Product } /** - * - * + * \brief Déplace fichier uploadé sous le nom $files dans le répertoire sdir + * \param sdir Répertoire destination finale + * \param $files Nom du fichier uploadé */ function add_photo($sdir, $files) { - $dir = $sdir .'/'. get_exdir($this->id) . $this->id ."/"; - $dir .= "photos/"; - + if (! file_exists($dir)) - { - dolibarr_syslog("Product Create $dir"); - create_exdir($dir); - } + { + dolibarr_syslog("Product Create $dir"); + create_exdir($dir); + } + + if (file_exists($dir)) + { + // Crée fichier en taille vignette + // \todo A faire - if ( file_exists($dir)) - { - if (doliMoveFileUpload($files['tmp_name'], $dir . $files['name'])) - { - - } - } + // Crée fichier en taille origine + doliMoveFileUpload($files['tmp_name'], $dir . $files['name'])) + } } + /** * * @@ -903,6 +904,7 @@ class Product } } } + /** * Je sais c'est sale mais le besoin est urgent ;-) * diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 16cebf37a39..9c5aa6d50cc 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -41,33 +41,29 @@ $mesg = ''; if (!$user->rights->produit->lire) accessforbidden(); - $types[0] = $langs->trans("Product"); $types[1] = $langs->trans("Service"); -/* - * - */ +/* + * Upload photo + */ if ( $_POST["sendit"] && defined('MAIN_UPLOAD_DOC') && MAIN_UPLOAD_DOC == 1) { - if ($_GET["id"]) + if ($_POST["id"]) { $product = new Product($db); - $result = $product->fetch($_GET["id"]); - - // if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) - - // var_dump($_FILES); + $result = $product->fetch($_POST["id"]); $product->add_photo($conf->produit->dir_output, $_FILES['photofile']); } + + $_GET["id"]=$_POST["id"]; } + /* * */ - - if ($_GET["action"] == 'fastappro') { $product = new Product($db); @@ -369,7 +365,8 @@ else $head[$h][1] = $langs->trans("Stock"); $h++; } - + } + if ($conf->fournisseur->enabled) { $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; @@ -381,8 +378,6 @@ else $head[$h][1] = $langs->trans("Photos"); $h++; - } - $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; $head[$h][1] = $langs->trans('Statistics'); $h++; @@ -560,16 +555,16 @@ else { print_titre($langs->trans("AddPhoto")); - print '