diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index c774faf5caa..96dff7755af 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -117,7 +117,7 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
}
else dol_syslog($imgThumbMini);
}
- else dol_syslog($langs->trans("ErrorImageFormatNotSupported"),LOG_WARNING);
+ else dol_syslog("ErrorImageFormatNotSupported",LOG_WARNING);
}
else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result))
{
@@ -133,9 +133,10 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
}
}
else
- {
+ {
$error++;
- setEventMessage($langs->trans("ErrorOnlyPngJpgSupported"),'errors');
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorBadImageFormat"),'errors');
}
}
}
@@ -158,7 +159,7 @@ if ( ($action == 'update' && empty($_POST["cancel"]))
// Local taxes
dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION",$_POST["optionlocaltax1"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION",$_POST["optionlocaltax2"],'chaine',0,'',$conf->entity);
-
+
if($_POST["optionlocaltax1"]=="localtax1on")
{
if(!isset($_REQUEST['lt1']))
@@ -226,13 +227,15 @@ if ($action == 'addthumb')
else
{
$error++;
- setEventMessage($langs->trans("ErrorImageFormatNotSupported"),'errors');
- dol_syslog($langs->transnoentities("ErrorImageFormatNotSupported"),LOG_WARNING);
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorBadImageFormat"),'errors');
+ dol_syslog($langs->transnoentities("ErrorBadImageFormat"),LOG_WARNING);
}
}
else
{
$error++;
+ $langs->load("errors");
setEventMessage($langs->trans("ErrorFileDoesNotExists",$_GET["file"]),'errors');
dol_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING);
}
@@ -601,7 +604,7 @@ if ($action == 'edit' || $action == 'updateedit')
$formcompany->select_localtax(1,$conf->global->MAIN_INFO_VALUE_LOCALTAX1, "lt1");
}
print '';
-
+
print '
| '.$langs->trans("CalcLocaltax").': ';
$opcions=array($langs->transcountry("CalcLocaltax1",$mysoc->country_code),$langs->transcountry("CalcLocaltax2",$mysoc->country_code),$langs->transcountry("CalcLocaltax3",$mysoc->country_code));
print $form->selectarray("clt1", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC1);
@@ -1003,7 +1006,7 @@ else
if($conf->global->MAIN_INFO_VALUE_LOCALTAX1!=0)
{
print ' |
| '.$langs->trans("LTRate").': '. $conf->global->MAIN_INFO_VALUE_LOCALTAX1 .' |
';
- }
+ }
print '| '.$langs->trans("CalcLocaltax").': ';
if($conf->global->MAIN_INFO_LOCALTAX_CALC1==0)
{
@@ -1016,7 +1019,7 @@ else
else if($conf->global->MAIN_INFO_LOCALTAX_CALC1==2){
print $langs->transcountry("CalcLocaltax3",$mysoc->country_code);
}
-
+
print ' |
';
print "";
print "\n";
@@ -1054,7 +1057,7 @@ else
if($conf->global->MAIN_INFO_VALUE_LOCALTAX2!=0)
{
print '| '.$langs->trans("LTRate").': '. $conf->global->MAIN_INFO_VALUE_LOCALTAX2 .' |
';
- }
+ }
print '| '.$langs->trans("CalcLocaltax").': ';
if($conf->global->MAIN_INFO_LOCALTAX_CALC2==0)
{
@@ -1068,7 +1071,7 @@ else
{
print $langs->transcountry("CalcLocaltax3",$mysoc->country_code);
}
-
+
print ' |
';
print "";
print "\n";
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index ed8354b9e8d..a2757bf5332 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -37,7 +37,7 @@ ErrorSupplierCodeRequired=Supplier code required
ErrorSupplierCodeAlreadyUsed=Supplier code already used
ErrorBadParameters=Bad parameters
ErrorBadValueForParameter=Wrong value '%s' for parameter incorrect '%s'
-ErrorBadImageFormat=Image file has not a supported format
+ErrorBadImageFormat=Image file has not a supported format (Your PHP does not support functions to convert images of this format)
ErrorBadDateFormat=Value '%s' has wrong date format
ErrorWrongDate=Date is not correct!
ErrorFailedToWriteInDir=Failed to write in directory %s
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index fd2a7d94c76..bc59c200f49 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -58,12 +58,12 @@ ErrorCantLoadUserFromDolibarrDatabase=Failed to find user %s in Dolibarr
ErrorNoVATRateDefinedForSellerCountry=Error, no vat rates defined for country '%s'.
ErrorNoSocialContributionForSellerCountry=Error, no social contribution type defined for country '%s'.
ErrorFailedToSaveFile=Error, failed to save file.
-ErrorOnlyPngJpgSupported=Error, only .png and .jpg image format file are supported.
-ErrorImageFormatNotSupported=Your PHP does not support functions to convert images of this format.
SetDate=Set date
SelectDate=Select a date
SeeAlso=See also %s
BackgroundColorByDefault=Default background color
+FileNotUploaded=The file was not uploaded
+FileUploaded=The file was successfully uploaded
FileWasNotUploaded=A file is selected for attachment but was not yet uploaded. Click on "Attach file" for this.
NbOfEntries=Nb of entries
GoToWikiHelpPage=Read online help (need Internet access)
diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang
index b10f0db3fd4..2b6d12870a1 100644
--- a/htdocs/langs/en_US/propal.lang
+++ b/htdocs/langs/en_US/propal.lang
@@ -55,8 +55,6 @@ NoOpenedPropals=No opened commercial proposals
NoOtherOpenedPropals=No other opened commercial proposals
RefProposal=Commercial proposal ref
SendPropalByMail=Send commercial proposal by mail
-FileNotUploaded=The file was not uploaded
-FileUploaded=The file was successfully uploaded
AssociatedDocuments=Documents associated with the proposal:
ErrorCantOpenDir=Can't open directory
DatePropal=Date of proposal
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index fa959b38277..226a3501652 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -46,6 +46,8 @@ class Product extends CommonObject
protected $isnolinkedbythird = 1; // No field fk_soc
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+ var $regeximgext='\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff';
+
//! Identifiant unique
var $id ;
//! Ref
@@ -1479,7 +1481,7 @@ class Product extends CommonObject
$this->date_modification = $obj->tms;
$this->import_key = $obj->import_key;
$this->entity = $obj->entity;
-
+
$this->ref_ext = $obj->ref_ext;
$this->db->free($resql);
@@ -3068,18 +3070,19 @@ class Product extends CommonObject
}
/**
- * Deplace fichier uploade sous le nom $files dans le repertoire sdir
+ * Move an uploaded file described into $file array into target directory $sdir.
*
- * @param string $sdir Repertoire destination finale
- * @param string $file Nom du fichier uploade
- * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut)
- * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut)
- * @return void
+ * @param string $sdir Target directory
+ * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...)
+ * @param int $maxWidth Largeur maximum que dois faire la miniature (160 by defaut)
+ * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 by defaut)
+ * @return int <0 if KO, >0 if OK
*/
function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+ $result = 0;
$dir = $sdir .'/'. get_exdir($this->id,2) . $this->id ."/photos";
dol_mkdir($dir);
@@ -3098,6 +3101,9 @@ class Product extends CommonObject
$this->add_thumb($originImage,$maxWidth,$maxHeight);
}
}
+
+ if (is_numeric($result) && $result > 0) return 1;
+ else return -1;
}
/**
@@ -3192,7 +3198,7 @@ class Product extends CommonObject
if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory
- if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file))
+ if (dol_is_file($dir.$file) && preg_match('/('.$this->regeximgext.')$/i', $dir.$file))
{
$nbphoto++;
$photo = $file;
@@ -3227,11 +3233,11 @@ class Product extends CommonObject
$alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
if ($photo_vignette && $imgarray['height'] > $maxHeight) {
$return.= '';
- $return.= '
';
+ $return.= '
';
}
else {
$return.= '';
- $return.= '
';
+ $return.= '
';
}
$return.= ''."\n";
@@ -3241,7 +3247,7 @@ class Product extends CommonObject
{
$return.= '
';
// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
- if ($photo_vignette && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight))
+ if ($photo_vignette && preg_match('/('.$this->regeximgext.')$/i', $photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight))
{
$return.= 'id.'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' ';
}
@@ -3266,7 +3272,7 @@ class Product extends CommonObject
}
if ($size == 0) { // Format origine
- $return.= '
';
+ $return.= '
';
if ($showfilename) $return.= '
'.$viewfilename;
if ($showaction)
@@ -3334,14 +3340,14 @@ class Product extends CommonObject
while (($file = readdir($handle)) != false)
{
if (! utf8_check($file)) $file=utf8_encode($file); // readdir returns ISO
- if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file))
+ if (dol_is_file($dir.$file) && preg_match('/('.$this->regeximgext.')$/i', $dir.$file))
{
$nbphoto++;
// On determine nom du fichier vignette
$photo=$file;
$photo_vignette='';
- if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs))
+ if (preg_match('/('.$this->regeximgext.')$/i', $photo, $regs))
{
$photo_vignette=preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0];
}
@@ -3385,7 +3391,7 @@ class Product extends CommonObject
dol_delete_file($file);
// Si elle existe, on efface la vignette
- if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$filename,$regs))
+ if (preg_match('/('.$this->regeximgext.')$/i',$filename,$regs))
{
$photo_vignette=preg_replace('/'.$regs[0].'/i','',$filename).'_small'.$regs[0];
if (file_exists(dol_osencode($dirthumb.$photo_vignette)))
diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php
index 09f03b15437..0ae65a7dec6 100644
--- a/htdocs/product/photos.php
+++ b/htdocs/product/photos.php
@@ -26,6 +26,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
@@ -59,7 +60,20 @@ if ($id > 0 || ! empty($ref))
if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
- if ($object->id) $result = $object->add_photo($dir, $_FILES['userfile']);
+ if ($object->id)
+ {
+ if (image_format_supported($_FILES['userfile']['name']) >= 1)
+ {
+ $result = $object->add_photo($dir, $_FILES['userfile']);
+ if ($result > 0) setEventMessage($langs->trans("FileUploaded"));
+ else setEventMessage($langs->trans("FileNotUploaded"), 'errors');
+ }
+ else
+ {
+ $langs->load("errors");
+ setEventMessage($langs->trans("ErrorBadImageFormat"), 'errors');
+ }
+ }
}
if ($action == 'confirm_delete' && $_GET["file"] && $confirm == 'yes' && ($user->rights->produit->creer || $user->rights->service->creer))
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 66de6a9be12..657d48f32d3 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -2120,9 +2120,11 @@ div.dolgraph div.legend, div.dolgraph div.legend div { background-color: rgba(25
div.dolgraph div.legend table tbody tr { height: auto; }
.photo {
-border: 0px;
-/* filter:alpha(opacity=55); */
-/* opacity:.55; */
+ border: 0px;
+}
+.photowithmargin {
+ margin-bottom: 2px;
+ margin-top: 2px;
}
.logo_setup