diff --git a/htdocs/fourn/product/fiche.php b/htdocs/fourn/product/fiche.php index dda521e71bc65188bca111ccb9520dd391fd02d2..892138ce82e0a05262e1b56dbe4f1c80ac00839f 100644 --- a/htdocs/fourn/product/fiche.php +++ b/htdocs/fourn/product/fiche.php @@ -371,7 +371,7 @@ else if ($product->type == 1) $nblignefour++; print '<td valign="middle" align="center" rowspan="'.$nblignefour.'">'; - $product->show_photo($conf->produit->dir_output,1); + $product->show_photos($conf->produit->dir_output,1,1,0); print '</td></tr>'; // Description diff --git a/htdocs/fourn/product/fourn.php b/htdocs/fourn/product/fourn.php index e92a2c1932de6dc03b43d9a732028ca6f0ca6eab..eeb449fddd516499d7246fee7127f052943e5beb 100644 --- a/htdocs/fourn/product/fourn.php +++ b/htdocs/fourn/product/fourn.php @@ -110,7 +110,7 @@ if ($_GET["id"]) print '<tr><td width="20%">'.$langs->trans("InternalRef").'</td><td width="40%">'.$product->ref.'</td>'; print '<td class="photo" valign="top" rowspan="6">'; - $product->show_photo($conf->produit->dir_output); + $product->show_photos($conf->produit->dir_output,1,1,0); print '</td></tr>'; print "<tr>"; diff --git a/htdocs/fourn/product/photos.php b/htdocs/fourn/product/photos.php index efb14a239742125f1babce1a1da2f7807603da85..b6a226de1da042b78d4424077772b00ae87c8f9a 100644 --- a/htdocs/fourn/product/photos.php +++ b/htdocs/fourn/product/photos.php @@ -139,9 +139,61 @@ if ($_GET["id"]) } - // Affiche photos - $nbphoto=$product->show_photos($conf->produit->dir_output,1); - if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>"; + // Affiche photos + if ($_GET["action"] != 'ajout_photo') + { + $nbphoto=0; + $nbbyrow=5; + + $pdir = get_exdir($product->id) . $product->id ."/photos/"; + $dir = $conf->produit->dir_output . '/'. $pdir; + + print '<br><table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; + + foreach ($product->liste_photos($dir) as $obj) + { + $nbphoto++; + +// if ($nbbyrow && $nbphoto == 1) print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; + + if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>'; + if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; + + print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">'; + + // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine + if ($obj['photo_vignette']) $filename=$obj['photo_vignette']; + else $filename=$obj['photo']; + print '<img border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">'; + + print '</a>'; + print '<br>'.$langs->trans("File").': '.dolibarr_trunc($filename,16); + if ($user->rights->produit->creer) + { + print '<br>'.'<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$filename).'">'.img_delete().'</a>'; + } + if ($nbbyrow) print '</td>'; + if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>'; + } + + // Ferme tableau + while ($nbphoto % $nbbyrow) + { + print '<td width="'.ceil(100/$nbbyrow).'%"> </td>'; + $nbphoto++; + } + + if ($nbphoto < 1) + { + print '<tr align=center valign=middle border=1><td class="photo">'; + print "<br>".$langs->trans("NoPhotoYet")."<br><br>"; + print '</td></tr></table>'; + } + + print '</table>'; + } + + print "</div>\n"; } diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 1f693d1527fecee4173dca737fa2fa641fb52511..593fc9a7f783bc9b081b408bf4a3fc2c8768d52c 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -1963,18 +1963,6 @@ function get_each_prod() } - /** - * \brief Affiche la premi�re photo du produit - * \param sdir R�pertoire � scanner - * \param size 0=taille origine, 1 taille vignette - * \return int Nombre de photos affich�es - */ - function show_photo($sdir,$size=0) - { - return $this->show_photos($sdir,$size,1,0); - } - - /** * \brief Affiche toutes les photos du produit (nbmax maximum) * \param sdir R�pertoire � scanner @@ -1982,7 +1970,6 @@ function get_each_prod() * \param nbmax Nombre maximum de photos (0=pas de max) * \param nbbyrow Nombre vignettes par ligne (si mode vignette) * \return int Nombre de photos affich�es - * \todo A virer, seule la methode avec size=0 sert encore. */ function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5) { @@ -2059,50 +2046,53 @@ function get_each_prod() return $nbphoto; } - /** - * \brief Retourne tableau de toutes les photos du produit - * \param dir R�pertoire � scanner - * \param nbmax Nombre maximum de photos (0=pas de max) - * \return array Tableau de photos - */ - function liste_photos($dir,$nbmax=0) - { - $nbphoto=0; - $tabobj=array(); - - if (file_exists($dir)) - { - $handle=opendir($dir); - - while (($file = readdir($handle)) != false) - { - if (is_file($dir.$file)) - { - $nbphoto++; - $photo = $file; + /** + * \brief Retourne tableau de toutes les photos du produit + * \param dir R�pertoire � scanner + * \param nbmax Nombre maximum de photos (0=pas de max) + * \return array Tableau de photos + */ + function liste_photos($dir,$nbmax=0) + { + $nbphoto=0; + $tabobj=array(); + + if (file_exists($dir)) + { + $handle=opendir($dir); + + while (($file = readdir($handle)) != false) + { + if (is_file($dir.$file)) + { + $nbphoto++; + $photo = $file; - // On determine nom du fichier vignette - $photo_vignette=''; - if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$photo,$regs)) { - $photo_vignette=eregi_replace($regs[0],'',$photo)."_small".$regs[0]; - } - - // Objet - $obj->photo=$photo; - if ($photo_vignette && is_file($photo_vignette)) $obj->photo_vignette=$photo_vignette; - else $obj->photo_vignette=""; - $tabobj[$nbphoto-1]=$obj; + // On determine nom du fichier vignette + $photo_vignette=''; + if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$photo,$regs)) + { + $photo_vignette=eregi_replace($regs[0],'',$photo)."_small".$regs[0]; + } + + // Objet + $obj=array(); + $obj['photo']=$photo; + if ($photo_vignette && is_file($photo_vignette)) $obj['photo_vignette']=$photo_vignette; + else $obj['photo_vignette']=""; - // On continue ou on arrete de boucler ? - if ($nbmax && $nbphoto >= $nbmax) break; - } - } - - closedir($handle); - } - - return $tabobj; - } + $tabobj[$nbphoto-1]=$obj; + + // On continue ou on arrete de boucler ? + if ($nbmax && $nbphoto >= $nbmax) break; + } + } + + closedir($handle); + } + + return $tabobj; + } /** diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 75000cccb21ef970a27a529b0bfd5c051992c6e2..41521d76c68b027a28dd998b22def157d34a96d7 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -616,7 +616,7 @@ if ($_GET["id"] || $_GET["ref"]) { // Photo print '<td valign="middle" align="center" rowspan="'.$nblignes.'">'; - $nbphoto=$product->show_photo($conf->produit->dir_output,1); + $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); print '</td>'; } diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 5d1d58410f119d1b72cb3c81d12b2eb7986f405f..bf5ce99d84f260c030e44244ad54787c3de7c481 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -262,8 +262,8 @@ if ($_GET["id"] || $_GET["ref"]) $dir = $conf->produit->dir_output . '/'. $pdir; print '<br><table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; - - foreach ($product->liste_photos($dir) as $obj) + + foreach ($product->liste_photos($dir) as $key => $obj) { $nbphoto++; @@ -272,11 +272,11 @@ if ($_GET["id"] || $_GET["ref"]) if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>'; if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; - print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$obj->photo).'" alt="Taille origine" target="_blank">'; + print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$obj['photo']).'" alt="Taille origine" target="_blank">'; // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine - if ($obj->photo_vignette) $filename=$obj->photo_vignette; - else $filename=$obj->photo; + if ($obj['photo_vignette']) $filename=$obj['photo_vignette']; + else $filename=$obj['photo']; print '<img border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">'; print '</a>'; diff --git a/htdocs/product/sousproduits/fiche.php b/htdocs/product/sousproduits/fiche.php index ea24f8168aacf5426a3ff194abe69f31c60d5346..6d2e4550298b73aa5b7998ec02305a2be301180b 100644 --- a/htdocs/product/sousproduits/fiche.php +++ b/htdocs/product/sousproduits/fiche.php @@ -267,7 +267,7 @@ if ($id || $ref) { // Photo print '<td valign="middle" align="center" rowspan="'.$nblignes.'">'; - $nbphoto=$product->show_photo($conf->produit->dir_output,1); + $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); print '</td>'; } @@ -331,7 +331,7 @@ if ($id || $ref) { // Photo print '<td valign="middle" align="center" rowspan="'.$nblignes.'">'; - $nbphoto=$product->show_photo($conf->produit->dir_output,1); + $nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0); print '</td>'; }