diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index c774faf5caa591bc34fc4bef7c1d7e2eca129df1..96dff7755afd19b7645a4b2c03e36ad684dc8f66 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 '</td></tr>'; - + print '<tr><td align="left"></label for="clt1">'.$langs->trans("CalcLocaltax").'</label>: '; $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 '<tr><td>'.$langs->trans("LTRate").': '. $conf->global->MAIN_INFO_VALUE_LOCALTAX1 .'</td></tr>'; - } + } print '<tr><td align="left">'.$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 '</td></tr>'; print "</table>"; print "</td></tr>\n"; @@ -1054,7 +1057,7 @@ else if($conf->global->MAIN_INFO_VALUE_LOCALTAX2!=0) { print '<tr><td>'.$langs->trans("LTRate").': '. $conf->global->MAIN_INFO_VALUE_LOCALTAX2 .'</td></tr>'; - } + } print '<tr><td align="left">'.$langs->trans("CalcLocaltax").': '; if($conf->global->MAIN_INFO_LOCALTAX_CALC2==0) { @@ -1068,7 +1071,7 @@ else { print $langs->transcountry("CalcLocaltax3",$mysoc->country_code); } - + print '</td></tr>'; print "</table>"; print "</td></tr>\n"; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index ed8354b9e8dd35dcc2b9af6d7799d400f863ae50..a2757bf5332602e0c35956b7d0560c801cde9e38 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 fd2a7d94c76006f7013bf7efff82d44bbfddb141..bc59c200f49e7dc4ea5b8808dad86ec26b3e4a7c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -58,12 +58,12 @@ ErrorCantLoadUserFromDolibarrDatabase=Failed to find user <b>%s</b> 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 b10f0db3fd4d37a709629decfeaaac45f37e4764..2b6d12870a1b949337f12391f80bec416b02a28b 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 fa959b3827772d069ca1c6634c0d18e9ac64c633..226a3501652cc16fe7642bcb3b329468eabdb29f 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.= '<!-- Show thumb -->'; - $return.= '<img class="photo" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; + $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; } else { $return.= '<!-- Show original file -->'; - $return.= '<img class="photo" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; + $return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; } $return.= '</a>'."\n"; @@ -3241,7 +3247,7 @@ class Product extends CommonObject { $return.= '<br>'; // 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.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' </a>'; } @@ -3266,7 +3272,7 @@ class Product extends CommonObject } if ($size == 0) { // Format origine - $return.= '<img class="photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; + $return.= '<img class="photo photowithmargin" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; if ($showfilename) $return.= '<br>'.$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 09f03b15437818a27e97899efe6937ff3b73a0bf..0ae65a7dec643866a7c33dd3b816a448c97cd4c5 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 66de6a9be12844ffb02a0345b05e68c22fc9851f..657d48f32d3c482bcf0aaf49a22b650f1e58c425 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