diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 404488fdbb2..205a2d2de4d 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -116,4 +116,5 @@ PriceQtyHT=Price for this quantity HT PriceQtyTTC=Price for this quantity TTC NoPriceDefinedForThisSupplier=No price/qty defined for this supplier/product RecordedProducts=Products recorded -RecordedProductsAndServices=Products/services recorded \ No newline at end of file +RecordedProductsAndServices=Products/services recorded +RegenerateThumb=Regenerate thumb \ No newline at end of file diff --git a/htdocs/langs/fr_FR/products.lang b/htdocs/langs/fr_FR/products.lang index 6a3d742ea2f..88b77e8099a 100644 --- a/htdocs/langs/fr_FR/products.lang +++ b/htdocs/langs/fr_FR/products.lang @@ -117,3 +117,4 @@ PriceQtyTTC=Prix pour la quantit NoPriceDefinedForThisSupplier=Aucun prix/qté défini pour ce fournisseur/produit RecordedProducts=Produits en vente RecordedProductsAndServices=Produits/services en vente +RegenerateThumb=Régénérer la vignette \ No newline at end of file diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 68ebcdfc1dc..44fbbbc2d3c 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -760,6 +760,18 @@ function img_file($alt = "default") return ''.$alt.''; } +/** + \brief Affiche logo refresh + \param alt Texte sur le alt de l'image + \return string Retourne tag img +*/ +function img_refresh($alt = "default") +{ + global $conf,$langs; + if ($alt=="default") $alt=$langs->trans("Refresh"); + return ''.$alt.''; +} + /** \brief Affiche logo dossier \param alt Texte sur le alt de l'image diff --git a/htdocs/product.class.php b/htdocs/product.class.php index be41f555202..e57a1ba2761 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -2124,8 +2124,10 @@ 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é + * \param maxWidth Largeur maximum que dois faire la miniature (160 par défaut) + * \param maxHeight Hauteur maximum que dois faire la miniature (120 par défaut) */ - function add_photo($sdir, $files) + function add_photo($sdir, $files, $maxWidth = 160, $maxHeight = 120) { $dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/"; $dir .= "photos/"; @@ -2147,10 +2149,22 @@ class Product if (file_exists($originImage) && eregi('(\.jpg|\.png)$',$files['name'])) { // Crée fichier en taille vignette - vignette($originImage); + $this->add_thumb($originImage,$maxWidth,$maxHeight); } } } + + /** + * \brief Génère la vignette + * \param sdir Répertoire destination finale + * \param files Nom du fichier uploadé + * \param maxWidth Largeur maximum que dois faire la miniature (160 par défaut) + * \param maxHeight Hauteur maximum que dois faire la miniature (120 par défaut) + */ + function add_thumb($files, $maxWidth = 160, $maxHeight = 120) + { + vignette($files,$maxWidth,$maxHeight); + } /** * \brief Déplace fichier récupéré sur internet (utilisé pour interface avec OSC) diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 8dc9fe419db..1385bf7dc5e 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -70,6 +70,12 @@ if ($_GET["action"] == 'delete' && $_GET["file"]) $product->delete_photo($conf->produit->dir_output."/".$_GET["file"]); } +if ($_GET["action"] == 'addthumb' && $_GET["file"]) +{ + $product = new Product($db); + $product->add_thumb($conf->produit->dir_output."/".$_GET["file"]); +} + /* * @@ -182,6 +188,7 @@ if ($_GET["id"] || $_GET["ref"]) if ($obj['photo_vignette']) { $filename=$obj['photo_vignette']; + $thumbfilename=$obj['photo_vignette']; } else { @@ -195,9 +202,15 @@ if ($_GET["id"] || $_GET["ref"]) print ''; print '
'.$langs->trans("File").': '.dolibarr_trunc($viewfilename,16); + print '
'; + // On propose la génération de la vignette si elle n'existe pas + if (!$obj['photo_vignette']) + { + print ''.img_refresh($langs->trans('RegenerateThumb')).'  '; + } if ($user->rights->produit->creer) { - print '
'.''.img_delete().''; + print ''.img_delete().''; } if ($nbbyrow) print ''; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '';