New: Form to add a photo is immediatly available on photo page if

permissions are ok (save one click per photo to add).
This commit is contained in:
Laurent Destailleur 2014-07-04 15:06:45 +02:00
parent 3ea52a7967
commit 6144f90770
4 changed files with 47 additions and 29 deletions

View File

@ -9,6 +9,8 @@ For users:
- New: Can create proposal from an intervention. - New: Can create proposal from an intervention.
- New: Can filter events on a group of users. - New: Can filter events on a group of users.
- New: Add thirdparty to filter on events. - New: Add thirdparty to filter on events.
- New: Form to add a photo is immediatly available on photo page if
permissions are ok (save one click per photo to add).
- Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action - Fix: [ bug #1487 ] PAYMENT_DELETE trigger does not intercept trigger action
- Fix: [ bug #1470, #1472, #1473] User trigger problem - Fix: [ bug #1470, #1472, #1473] User trigger problem
- Fix: [ bug #1489, #1491 ] Intervention trigger problem - Fix: [ bug #1489, #1491 ] Intervention trigger problem

View File

@ -3055,7 +3055,7 @@ class Product extends CommonObject
* @param string $sdir Directory to scan * @param string $sdir Directory to scan
* @param int $size 0=original size, 1 use thumbnail if possible * @param int $size 0=original size, 1 use thumbnail if possible
* @param int $nbmax Nombre maximum de photos (0=pas de max) * @param int $nbmax Nombre maximum de photos (0=pas de max)
* @param int $nbbyrow Nombre vignettes par ligne (si mode vignette) * @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1.
* @param int $showfilename 1=Show filename * @param int $showfilename 1=Show filename
* @param int $showaction 1=Show icon with action links (resize, delete) * @param int $showaction 1=Show icon with action links (resize, delete)
* @param int $maxHeight Max height of image when size=1 * @param int $maxHeight Max height of image when size=1
@ -3106,10 +3106,14 @@ class Product extends CommonObject
// Get filesize of original file // Get filesize of original file
$imgarray=dol_getImageSize($dir.$photo); $imgarray=dol_getImageSize($dir.$photo);
if ($nbbyrow && $nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; if ($nbbyrow > 0)
{
if ($nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) $return.= '<tr align=center valign=middle border=1>'; if ($nbphoto % $nbbyrow == 1) $return.= '<tr align=center valign=middle border=1>';
if ($nbbyrow) $return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; $return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
}
else if ($nbbyrow < 0) $return .= '<div class="inline-block">';
$return.= "\n"; $return.= "\n";
$return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">'; $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
@ -3150,9 +3154,12 @@ class Product extends CommonObject
} }
$return.= "\n"; $return.= "\n";
if ($nbbyrow) $return.= '</td>'; if ($nbbyrow > 0)
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) $return.= '</tr>'; {
$return.= '</td>';
if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>';
}
else if ($nbbyrow < 0) $return.='</div>';
} }
if ($size == 0) { // Format origine if ($size == 0) { // Format origine
@ -3179,16 +3186,19 @@ class Product extends CommonObject
} }
} }
if ($nbbyrow && $size==1) if ($size==1)
{ {
// Ferme tableau if ($nbbyrow > 0)
while ($nbphoto % $nbbyrow)
{ {
$return.= '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>'; // Ferme tableau
$nbphoto++; while ($nbphoto % $nbbyrow)
} {
$return.= '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
$nbphoto++;
}
if ($nbphoto) $return.= '</table>'; if ($nbphoto) $return.= '</table>';
}
} }
closedir($handle); closedir($handle);

View File

@ -1283,9 +1283,11 @@ else
if ($showphoto || $showbarcode) if ($showphoto || $showbarcode)
{ {
print '<td valign="middle" align="center" width="25%" rowspan="'.$nblignes.'">'; print '<td valign="middle" align="center" width="25%" rowspan="'.$nblignes.'">';
print '<div class="photolist">';
if ($showphoto) print $object->show_photos($conf->product->multidir_output[$object->entity],1,1,0,0,0,80); if ($showphoto) print $object->show_photos($conf->product->multidir_output[$object->entity],1,1,0,0,0,80);
if ($showphoto && $showbarcode) print '<br><br>'; if ($showphoto && $showbarcode) print '<br><br>';
if ($showbarcode) print $form->showbarcode($object); if ($showbarcode) print $form->showbarcode($object);
print '</div>';
print '</td>'; print '</td>';
} }

View File

@ -130,13 +130,17 @@ if ($object->id)
print "</div>\n"; print "</div>\n";
$permtoedit=0;
if ($user->rights->produit->creer && $object->type == 0) $permtoedit=1;
if ($user->rights->service->creer && $object->type == 1) $permtoedit=1;
if (empty($conf->global->MAIN_UPLOAD_DOC)) $permtoedit=0;
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* Barre d'action */ /* Barre d'action */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
/*
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
if ($action != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer))
@ -154,16 +158,17 @@ if ($object->id)
} }
print "\n</div>\n"; print "\n</div>\n";
*/
/* /*
* Add a photo * Add a photo
*/ */
if ($action == 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer) && ! empty($conf->global->MAIN_UPLOAD_DOC)) if ($permtoedit)
{ {
// Affiche formulaire upload // Show upload form
$formfile=new FormFile($db); $formfile=new FormFile($db);
$formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("AddPhoto"), 1, 0, ($user->rights->produit->creer || $user->rights->service->creer), 50, $object, '', false, '', 0); // ajax=false for the moment. true may not work. $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans("AddPhoto"), 1, 0, $permtoedit, 50, $object, '', false, '', 0); // ajax=false for the moment. true may not work.
} }
//else print $langs->trans("NoPermissionToAddOrEditPhoto").'<br><br>'; // TODO Add this
// Affiche photos // Affiche photos
if ($action != 'ajout_photo') if ($action != 'ajout_photo')
@ -174,11 +179,10 @@ if ($object->id)
$maxWidth = 160; $maxWidth = 160;
$maxHeight = 120; $maxHeight = 120;
print $object->show_photos($dir,1,1000,$nbbyrow,1,1); print $object->show_photos($dir,1,1000,$nbbyrow,1,($permtoedit?1:0));
if ($object->nbphoto < 1) if ($object->nbphoto < 1)
{ {
print '<br>';
print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; 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 '<tr align=center valign=middle border=1><td class="photo">';
print "<br>".$langs->trans("NoPhotoYet")."<br><br>"; print "<br>".$langs->trans("NoPhotoYet")."<br><br>";