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 filter events on a group of users.
- 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 #1470, #1472, #1473] User trigger problem
- Fix: [ bug #1489, #1491 ] Intervention trigger problem

View File

@ -1749,7 +1749,7 @@ class Product extends CommonObject
return -1;
}
}
/**
* Charge tableau des stats contrat pour le produit/service
*
@ -2930,7 +2930,7 @@ class Product extends CommonObject
function load_virtual_stock()
{
global $conf;
if (! empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT))
{
$stock_commande_client=$stock_commande_fournisseur=0;
@ -2953,7 +2953,7 @@ class Product extends CommonObject
$result=$this->load_stats_commande_fournisseur(0,'3');
if ($result < 0) dol_print_error($db,$this->error);
$stock_commande_fournisseur=$this->stats_commande_fournisseur['qty'];
$result=$this->load_stats_reception(0,'3');
if ($result < 0) dol_print_error($db,$this->error);
$stock_reception_fournisseur=$this->stats_reception['qty'];
@ -3055,7 +3055,7 @@ class Product extends CommonObject
* @param string $sdir Directory to scan
* @param int $size 0=original size, 1 use thumbnail if possible
* @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 $showaction 1=Show icon with action links (resize, delete)
* @param int $maxHeight Max height of image when size=1
@ -3106,10 +3106,14 @@ class Product extends CommonObject
// Get filesize of original file
$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 ($nbbyrow) $return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
if ($nbphoto % $nbbyrow == 1) $return.= '<tr align=center valign=middle border=1>';
$return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
}
else if ($nbbyrow < 0) $return .= '<div class="inline-block">';
$return.= "\n";
$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";
if ($nbbyrow) $return.= '</td>';
if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) $return.= '</tr>';
if ($nbbyrow > 0)
{
$return.= '</td>';
if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>';
}
else if ($nbbyrow < 0) $return.='</div>';
}
if ($size == 0) { // Format origine
@ -3179,16 +3186,19 @@ class Product extends CommonObject
}
}
if ($nbbyrow && $size==1)
if ($size==1)
{
// Ferme tableau
while ($nbphoto % $nbbyrow)
if ($nbbyrow > 0)
{
$return.= '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
$nbphoto++;
}
// Ferme tableau
while ($nbphoto % $nbbyrow)
{
$return.= '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
$nbphoto++;
}
if ($nbphoto) $return.= '</table>';
if ($nbphoto) $return.= '</table>';
}
}
closedir($handle);

View File

@ -220,7 +220,7 @@ if (empty($reshook))
$object->barcode_type_code = $stdobject->barcode_type_code;
$object->barcode_type_coder = $stdobject->barcode_type_coder;
$object->barcode_type_label = $stdobject->barcode_type_label;
$object->description = dol_htmlcleanlastbr(GETPOST('desc'));
$object->url = GETPOST('url');
$object->note = dol_htmlcleanlastbr(GETPOST('note'));
@ -334,7 +334,7 @@ if (empty($reshook))
$object->barcode_type_code = $stdobject->barcode_type_code;
$object->barcode_type_coder = $stdobject->barcode_type_coder;
$object->barcode_type_label = $stdobject->barcode_type_label;
$object->accountancy_code_sell = GETPOST('accountancy_code_sell');
$object->accountancy_code_buy = GETPOST('accountancy_code_buy');
@ -1278,17 +1278,19 @@ else
if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) $nblignes+=2;
if ($object->isservice()) $nblignes++;
else $nblignes+=4;
// Photo
if ($showphoto || $showbarcode)
{
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 && $showbarcode) print '<br><br>';
if ($showbarcode) print $form->showbarcode($object);
print '</div>';
print '</td>';
}
print '</tr>';
// Type
@ -1300,7 +1302,7 @@ else
print $form->editfieldval("Type",'fk_product_type',$object->type,$object,$user->rights->produit->creer||$user->rights->service->creer,$typeformat);
print '</td></tr>';
}
if ($showbarcode)
{
// Barcode type

View File

@ -130,13 +130,17 @@ if ($object->id)
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 */
/* */
/* ************************************************************************** */
/*
print "\n<div class=\"tabsAction\">\n";
if ($action != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer))
@ -154,16 +158,17 @@ if ($object->id)
}
print "\n</div>\n";
*/
/*
* 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->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
if ($action != 'ajout_photo')
@ -174,11 +179,10 @@ if ($object->id)
$maxWidth = 160;
$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)
{
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>";