Qual: Mutualize common code

This commit is contained in:
Laurent Destailleur 2010-02-17 18:57:08 +00:00
parent c5e01667ee
commit d5b1097d13
3 changed files with 27 additions and 80 deletions

View File

@ -844,12 +844,12 @@ if ($_GET["id"] || $_GET["ref"])
// En mode visu // En mode visu
print '<table class="border" width="100%"><tr>'; print '<table class="border" width="100%"><tr>';
// Reference // Ref
print '<td width="15%">'.$langs->trans("Ref").'</td><td>'; print '<td width="15%">'.$langs->trans("Ref").'</td><td>';
print $html->showrefnav($product,'ref','',1,'ref'); print $html->showrefnav($product,'ref','',1,'ref');
print '</td>'; print '</td>';
$nblignes=4; $nblignes=3;
if (! empty($conf->global->PRODUIT_MULTIPRICES_LIMIT) && empty($socid)) $nblignes+=$conf->global->PRODUIT_MULTIPRICES_LIMIT; if (! empty($conf->global->PRODUIT_MULTIPRICES_LIMIT) && empty($socid)) $nblignes+=$conf->global->PRODUIT_MULTIPRICES_LIMIT;
else $nblignes+=3; else $nblignes+=3;
@ -862,7 +862,7 @@ if ($_GET["id"] || $_GET["ref"])
} }
print '</tr>'; print '</tr>';
// Libelle // Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td></tr>';
// MultiPrix // MultiPrix
@ -988,7 +988,7 @@ if ($_GET["id"] || $_GET["ref"])
print '</td></tr>'; print '</td></tr>';
// Description // Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">'.nl2br($product->description).'</td></tr>';
// Nature // Nature
if($product->type!=1) if($product->type!=1)

View File

@ -189,77 +189,16 @@ if ($_GET["id"] || $_GET["ref"])
$maxWidth = 160; $maxWidth = 160;
$maxHeight = 120; $maxHeight = 120;
$pdir = get_exdir($product->id,2) . $product->id ."/photos/"; $nbphoto=$product->show_photos($conf->produit->dir_output,1,1000,$nbbyrow,1,1);
$dir = $conf->produit->dir_output . '/'. $pdir;
print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
foreach ($product->liste_photos($dir) as $key => $obj)
{
$nbphoto++;
// if ($nbbyrow && $nbphoto == 1) print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
// Do not use show_photo because there is more information to show
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="'.dol_escape_htmltag($langs->trans("OriginalSize")).'" target="_blank">';
// Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
if ($obj['photo_vignette'])
{
$filename='thumbs/'.$obj['photo_vignette'];
}
else
{
$filename=$obj['photo'];
}
// Nom affiche
$viewfilename=$obj['photo'];
// Taille de l'image
$product->get_image_size($dir.$filename);
$imgWidth = ($product->imgWidth < $maxWidth) ? $product->imgWidth : $maxWidth;
$imgHeight = ($product->imgHeight < $maxHeight) ? $product->imgHeight : $maxHeight;
print '<img class="photo" border="0" width="'.$imgWidth.'" height="'.$imgHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">';
print '</a>';
print '<br>'.$viewfilename;
print '<br>';
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
if (!$obj['photo_vignette'] && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i',$obj['photo']) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight))
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_refresh($langs->trans('GenerateThumb')).'&nbsp;&nbsp;</a>';
}
if ($user->rights->produit->creer || $user->rights->service->creer)
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
print 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).'%">&nbsp;</td>';
$nbphoto++;
}
if ($nbphoto < 1) if ($nbphoto < 1)
{ {
print '<tr align=center valign=middle border=1><td class="photo">'; print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; print '<tr align=center valign=middle border=1><td class="photo">';
print "<br>".$langs->trans("NoPhotoYet")."<br><br>"; print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
print '</td></tr>'; print '</td></tr>';
print '</table>';
} }
print '</table>';
} }
} }
} }

View File

@ -23,7 +23,7 @@
/** /**
* \file htdocs/product/price.php * \file htdocs/product/price.php
* \ingroup product * \ingroup product
* \brief Page de la fiche produit * \brief Page to show product prices
* \version $Id$ * \version $Id$
*/ */
@ -126,17 +126,26 @@ dol_fiche_head($head, 'price', $titre, 0, $picto);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Reference // Ref
print '<tr>'; print '<td width="15%">'.$langs->trans("Ref").'</td><td>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
print $html->showrefnav($product,'ref','',1,'ref'); print $html->showrefnav($product,'ref','',1,'ref');
print '</td>'; print '</td>';
$nblignes=3;
if (! empty($conf->global->PRODUIT_MULTIPRICES_LIMIT) && empty($socid)) $nblignes+=$conf->global->PRODUIT_MULTIPRICES_LIMIT;
else $nblignes+=3;
if ($product->is_photo_available($conf->produit->dir_output))
{
// Photo
print '<td valign="middle" align="center" width="30%" rowspan="'.$nblignes.'">';
$nbphoto=$product->show_photos($conf->produit->dir_output,1,1,0);
print '</td>';
}
print '</tr>'; print '</tr>';
// Libelle // Label
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>'; print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td></tr>';
print '</tr>';
// MultiPrix // MultiPrix
if($conf->global->PRODUIT_MULTIPRICES) if($conf->global->PRODUIT_MULTIPRICES)
@ -252,12 +261,11 @@ else
print '</td></tr>'; print '</td></tr>';
// TVA // TVA
print '<tr><td>'.$langs->trans("VATRate").'</td><td colspan="2">'.vatrate($product->tva_tx,true).'</td></tr>'; print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.vatrate($product->tva_tx,true).'</td></tr>';
} }
// Statut // Statut
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Status").'</td><td>';
print $product->getLibStatut(2); print $product->getLibStatut(2);
print '</td></tr>'; print '</td></tr>';