diff --git a/ChangeLog b/ChangeLog
index 5b057b66175..c250f810b6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 73859378d65..9a34de543ba 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -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.= '
';
+ if ($nbbyrow > 0)
+ {
+ if ($nbphoto == 1) $return.= '';
- if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) $return.= '';
- if ($nbbyrow) $return.= '| ';
+ if ($nbphoto % $nbbyrow == 1) $return.= ' |
';
+ $return.= '| ';
+ }
+ else if ($nbbyrow < 0) $return .= ' | ';
- if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) $return.= '
';
-
+ if ($nbbyrow > 0)
+ {
+ $return.= '';
+ if (($nbphoto % $nbbyrow) == 0) $return.= '';
+ }
+ else if ($nbbyrow < 0) $return.='';
}
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.= ' | ';
- $nbphoto++;
- }
+ // Ferme tableau
+ while ($nbphoto % $nbbyrow)
+ {
+ $return.= ' | ';
+ $nbphoto++;
+ }
- if ($nbphoto) $return.= '
';
+ if ($nbphoto) $return.= '
';
+ }
}
closedir($handle);
diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php
index deeae6784e6..94edbbd1d04 100644
--- a/htdocs/product/fiche.php
+++ b/htdocs/product/fiche.php
@@ -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 '';
+ print ' ';
if ($showphoto) print $object->show_photos($conf->product->multidir_output[$object->entity],1,1,0,0,0,80);
if ($showphoto && $showbarcode) print '
';
if ($showbarcode) print $form->showbarcode($object);
+ print ' ';
print ' | ';
}
-
+
print '';
// 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 '';
}
-
+
if ($showbarcode)
{
// Barcode type
diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php
index 306ee51d210..09f03b15437 100644
--- a/htdocs/product/photos.php
+++ b/htdocs/product/photos.php
@@ -130,13 +130,17 @@ if ($object->id)
print "\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\n";
if ($action != 'ajout_photo' && ($user->rights->produit->creer || $user->rights->service->creer))
@@ -154,16 +158,17 @@ if ($object->id)
}
print "\n
\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").'
'; // 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 '
';
print '';
print '';
print " ".$langs->trans("NoPhotoYet")."
";
|