Fix: La liste des vignettes qd plusieurs photo affichaient toujours le meme nom de fichier
This commit is contained in:
parent
5dbf26a344
commit
54b48dc64d
@ -371,7 +371,7 @@ else
|
|||||||
if ($product->type == 1) $nblignefour++;
|
if ($product->type == 1) $nblignefour++;
|
||||||
|
|
||||||
print '<td valign="middle" align="center" rowspan="'.$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>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
|
|||||||
@ -110,7 +110,7 @@ if ($_GET["id"])
|
|||||||
print '<tr><td width="20%">'.$langs->trans("InternalRef").'</td><td width="40%">'.$product->ref.'</td>';
|
print '<tr><td width="20%">'.$langs->trans("InternalRef").'</td><td width="40%">'.$product->ref.'</td>';
|
||||||
|
|
||||||
print '<td class="photo" valign="top" rowspan="6">';
|
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 '</td></tr>';
|
||||||
|
|
||||||
print "<tr>";
|
print "<tr>";
|
||||||
|
|||||||
@ -140,8 +140,60 @@ if ($_GET["id"])
|
|||||||
|
|
||||||
|
|
||||||
// Affiche photos
|
// Affiche photos
|
||||||
$nbphoto=$product->show_photos($conf->produit->dir_output,1);
|
if ($_GET["action"] != 'ajout_photo')
|
||||||
if ($nbphoto < 1) print $langs->trans("NoPhotoYet")."<br><br>";
|
{
|
||||||
|
$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";
|
print "</div>\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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)
|
* \brief Affiche toutes les photos du produit (nbmax maximum)
|
||||||
* \param sdir Répertoire à scanner
|
* \param sdir Répertoire à scanner
|
||||||
@ -1982,7 +1970,6 @@ function get_each_prod()
|
|||||||
* \param nbmax Nombre maximum de photos (0=pas de max)
|
* \param nbmax Nombre maximum de photos (0=pas de max)
|
||||||
* \param nbbyrow Nombre vignettes par ligne (si mode vignette)
|
* \param nbbyrow Nombre vignettes par ligne (si mode vignette)
|
||||||
* \return int Nombre de photos affichées
|
* \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)
|
function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5)
|
||||||
{
|
{
|
||||||
@ -2083,14 +2070,17 @@ function get_each_prod()
|
|||||||
|
|
||||||
// On determine nom du fichier vignette
|
// On determine nom du fichier vignette
|
||||||
$photo_vignette='';
|
$photo_vignette='';
|
||||||
if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$photo,$regs)) {
|
if (eregi('(\.jpg|\.bmp|\.gif|\.png|\.tiff)$',$photo,$regs))
|
||||||
|
{
|
||||||
$photo_vignette=eregi_replace($regs[0],'',$photo)."_small".$regs[0];
|
$photo_vignette=eregi_replace($regs[0],'',$photo)."_small".$regs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Objet
|
// Objet
|
||||||
$obj->photo=$photo;
|
$obj=array();
|
||||||
if ($photo_vignette && is_file($photo_vignette)) $obj->photo_vignette=$photo_vignette;
|
$obj['photo']=$photo;
|
||||||
else $obj->photo_vignette="";
|
if ($photo_vignette && is_file($photo_vignette)) $obj['photo_vignette']=$photo_vignette;
|
||||||
|
else $obj['photo_vignette']="";
|
||||||
|
|
||||||
$tabobj[$nbphoto-1]=$obj;
|
$tabobj[$nbphoto-1]=$obj;
|
||||||
|
|
||||||
// On continue ou on arrete de boucler ?
|
// On continue ou on arrete de boucler ?
|
||||||
|
|||||||
@ -616,7 +616,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
{
|
{
|
||||||
// Photo
|
// Photo
|
||||||
print '<td valign="middle" align="center" rowspan="'.$nblignes.'">';
|
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>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -263,7 +263,7 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
|
|
||||||
print '<br><table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
|
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++;
|
$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 && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
|
||||||
if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
|
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
|
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
|
||||||
if ($obj->photo_vignette) $filename=$obj->photo_vignette;
|
if ($obj['photo_vignette']) $filename=$obj['photo_vignette'];
|
||||||
else $filename=$obj->photo;
|
else $filename=$obj['photo'];
|
||||||
print '<img border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">';
|
print '<img border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">';
|
||||||
|
|
||||||
print '</a>';
|
print '</a>';
|
||||||
|
|||||||
@ -267,7 +267,7 @@ if ($id || $ref)
|
|||||||
{
|
{
|
||||||
// Photo
|
// Photo
|
||||||
print '<td valign="middle" align="center" rowspan="'.$nblignes.'">';
|
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>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ if ($id || $ref)
|
|||||||
{
|
{
|
||||||
// Photo
|
// Photo
|
||||||
print '<td valign="middle" align="center" rowspan="'.$nblignes.'">';
|
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>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user