diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 6b46468b916..91e34e66d94 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -195,7 +195,6 @@ if ($action == 'edit') { foreach($delays as $delay) { - $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print ''; print ''.img_object('', $delay['img']).''; @@ -235,7 +234,6 @@ else { foreach($delays as $delay) { - $value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0); print ''; print ''.img_object('', $delay['img']).''; @@ -300,16 +298,16 @@ if ($action == 'edit') { print '
'; print '
'; - print img_weather($text, 'weather-clear.png', $options); + print img_weather($text, 0, $options); print '= '; print '
'; - print img_weather($text, 'weather-few-clouds.png', $options); + print img_weather($text, 1, $options); print '<= '; print '
'; - print img_weather($text, 'weather-clouds.png', $options); + print img_weather($text, 2, $options); print '<= '; print '
'; - print img_weather($text, 'weather-many-clouds.png', $options); + print img_weather($text, 3, $options); print '<= '; print '
'; print '
'; @@ -320,16 +318,16 @@ if ($action == 'edit') { print '
'; print '
'; - print img_weather($text, 'weather-clear.png', $options); + print img_weather($text, 0, $options); print '=  %'; print '
'; - print img_weather($text, 'weather-few-clouds.png', $options); + print img_weather($text, 1, $options); print '<=  %'; print '
'; - print img_weather($text, 'weather-clouds.png', $options); + print img_weather($text, 2, $options); print '<=  %'; print '
'; - print img_weather($text, 'weather-many-clouds.png', $options); + print img_weather($text, 3, $options); print '<=  %'; print '
'; print '
'; @@ -371,19 +369,19 @@ if ($action == 'edit') { print '
'; print '
'; - print img_weather($text, 'weather-clear.png', $options); + print img_weather($text, 0, $options); print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.' %'; print '
'; - print img_weather($text, 'weather-few-clouds.png', $options); + print img_weather($text, 1, $options); print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.' %'; print '
'; - print img_weather($text, 'weather-clouds.png', $options); + print img_weather($text, 2, $options); print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.' %'; print '
'; - print img_weather($text, 'weather-many-clouds.png', $options); + print img_weather($text, 3, $options); print '<= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %'; print '
'; - print img_weather($text, 'weather-storm.png', $options); + print img_weather($text, 4, $options); print '> '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.' %'; print '
'; print '
'; @@ -391,19 +389,19 @@ if ($action == 'edit') { print '
'; print '
'; - print img_weather($text, 'weather-clear.png', $options); + print img_weather($text, 0, $options); print '= '.$level0; print '
'; - print img_weather($text, 'weather-few-clouds.png', $options); + print img_weather($text, 1, $options); print '<= '.$level1; print '
'; - print img_weather($text, 'weather-clouds.png', $options); + print img_weather($text, 2, $options); print '<= '.$level2; print '
'; - print img_weather($text, 'weather-many-clouds.png', $options); + print img_weather($text, 3, $options); print '<= '.$level3; print '
'; - print img_weather($text, 'weather-storm.png', $options); + print img_weather($text, 4, $options); print '> '.$level3; print '
'; print '
'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e851509a000..e6a93b99ea4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3225,7 +3225,7 @@ function img_object($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, * Show weather picto * * @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title. - * @param string $picto Name of image file to show (If no extension provided, we use '.png'). Image must be stored into htdocs/theme/common directory. + * @param string|int $picto Name of image file to show (If no extension provided, we use '.png'). Image must be stored into htdocs/theme/common directory. Or level of meteo image (0-4). * @param string $moreatt Add more attribute on img tag * @param int $pictoisfullpath If 1, image path is a full path * @param string $morecss More CSS @@ -3236,7 +3236,13 @@ function img_weather($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0, $mo { global $conf; - if (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; + if (is_numeric($picto)) + { + $leveltopicto=array(0=>'weather-clear.png', 1=>'weather-few-clouds.png', 2=>'weather-clouds.png', 3=>'weather-many-clouds.png', 4=>'weather-storm.png'); + //return ''; + $picto = $leveltopicto[$picto]; + } + elseif (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png'; $path = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/weather/'.$picto; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index b4c8f6bf011..9363956d764 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2251,9 +2251,53 @@ function colorValidateHex($color, $allow_white = true) /** - * @param string $hex color in hex - * @param integer $steps Steps should be between -255 and 255. Negative = darker, positive = lighter - * @return string + * Change color to make it less aggressive (ratio is negative) or more aggressive (ratio is positive) + * + * @param string $hex Color in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12') + * @param integer $ratio Default=-50. Note: 0=Component color is unchanged, -100=Component color become 88, +100=Component color become 00 or FF + * @return string New string of color + * @see colorAdjustBrightness() + */ +function colorAgressivity($hex, $ratio = -50) +{ + // Steps should be between -255 and 255. Negative = darker, positive = lighter + $ratio = max(-100, min(100, $ratio)); + + // Normalize into a six character long hex string + $hex = str_replace('#', '', $hex); + if (strlen($hex) == 3) { + $hex = str_repeat(substr($hex, 0, 1), 2).str_repeat(substr($hex, 1, 1), 2).str_repeat(substr($hex, 2, 1), 2); + } + + // Split into three parts: R, G and B + $color_parts = str_split($hex, 2); + $return = '#'; + + foreach ($color_parts as $color) { + $color = hexdec($color); // Convert to decimal + if ($ratio > 0) // We increase aggressivity + { + if ($color > 127) $color += ((255 - $color) * ($ratio / 100)); + if ($color < 128) $color -= ($color * ($ratio / 100)); + } + else // We decrease agressivity + { + if ($color > 128) $color -= (($color - 128) * (abs($ratio) / 100)); + if ($color < 127) $color += ((128 - $color) * (abs($ratio) / 100)); + } + $color = max(0, min(255, $color)); // Adjust color + $return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code + } + + //var_dump($hex.' '.$ratio.' -> '.$return); + return $return; +} + +/** + * @param string $hex Color in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12') + * @param integer $steps Step/offset added to each color component. It should be between -255 and 255. Negative = darker, positive = lighter + * @return string New color with format '#AA1122' + * @see colorAgressivity() */ function colorAdjustBrightness($hex, $steps) { diff --git a/htdocs/index.php b/htdocs/index.php index 4cd58ea6495..d8a8ffab17d 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -769,9 +769,7 @@ if (!empty($valid_dashboardlines)) $weatherDashBoard= '
'."\n"; $weatherDashBoard.= '
'."\n"; $weatherDashBoard.= ' '; - - $weatherDashBoard.= ' '; - + $weatherDashBoard.= img_weather('', $weather->level, '', 0, 'valignmiddle width50'); $weatherDashBoard.= ' '."\n"; $weatherDashBoard.= '
'."\n"; $weatherDashBoard.= ' '.$langs->trans('GlobalOpenedElemView').'' . "\n"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7c11e6d10a7..a9d217e3df5 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1258,11 +1258,12 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr $themeparam='?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss', 'aZ09')?'&optioncss='.GETPOST('optioncss', 'aZ09', 1):'').'&userid='.$user->id.'&entity='.$conf->entity; $themeparam.=($ext?'&'.$ext:'').'&revision='.$conf->global->MAIN_IHM_PARAMS_REV; if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&dol_resetcache='.$_SESSION['dol_resetcache']; - if (GETPOST('dol_hide_topmenu', 'int')) { $themeparam.='&dol_hide_topmenu='.GETPOST('dol_hide_topmenu', 'int'); } - if (GETPOST('dol_hide_leftmenu', 'int')) { $themeparam.='&dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu', 'int'); } - if (GETPOST('dol_optimize_smallscreen', 'int')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); } - if (GETPOST('dol_no_mouse_hover', 'int')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); } - if (GETPOST('dol_use_jmobile', 'int')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); } + if (GETPOSTISSET('dol_hide_topmenu')) { $themeparam.='&dol_hide_topmenu='.GETPOST('dol_hide_topmenu', 'int'); } + if (GETPOSTISSET('dol_hide_leftmenu')) { $themeparam.='&dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu', 'int'); } + if (GETPOSTISSET('dol_optimize_smallscreen')) { $themeparam.='&dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); } + if (GETPOSTISSET('dol_no_mouse_hover')) { $themeparam.='&dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); } + if (GETPOSTISSET('dol_use_jmobile')) { $themeparam.='&dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); } + if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) { $themeparam.='&THEME_AGRESSIVITY_RATIO='.GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); } if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax) { diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 3159428ce0a..33bbfdf3491 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -116,36 +116,41 @@ a.info-box-text{ text-decoration: none;} color: #fff !important; } +global->THEME_AGRESSIVITY_RATIO)) $conf->global->THEME_AGRESSIVITY_RATIO=-75; +if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) $conf->global->THEME_AGRESSIVITY_RATIO=GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); +?> .bg-infoxbox-project{ - background-color: #605ca8 !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } .bg-infoxbox-action{ - background-color: #d84b80 !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } .bg-infoxbox-propal, .bg-infoxbox-facture, .bg-infoxbox-commande{ - background-color: #abb87b !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } .bg-infoxbox-supplier_proposal, .bg-infoxbox-invoice_supplier, .bg-infoxbox-order_supplier{ - background-color: #40b0cf !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } .bg-infoxbox-contrat{ - background-color: #20a68a !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } .bg-infoxbox-bank_account{ - background-color: #e39c42 !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } .bg-infoxbox-adherent{ - //background-color: #f39c12 !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } .bg-infoxbox-expensereport{ - background-color: #755114 !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } .bg-infoxbox-holiday{ - background-color: #755114 !important; + background-color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } diff --git a/htdocs/theme/md/info-box.inc.php b/htdocs/theme/md/info-box.inc.php index 827a38738a4..c02ffef410b 100644 --- a/htdocs/theme/md/info-box.inc.php +++ b/htdocs/theme/md/info-box.inc.php @@ -95,39 +95,43 @@ a.info-box-text{ text-decoration: none;} .info-box-icon { color: #000 !important; } -/* -.bg-infoxbox-project{ - background-color: #605ca8 !important; +global->THEME_AGRESSIVITY_RATIO)) $conf->global->THEME_AGRESSIVITY_RATIO=-100; +if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) $conf->global->THEME_AGRESSIVITY_RATIO=GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); +?> +.bg-infoxbox-project i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -.bg-infoxbox-action{ - background-color: #d81b60 !important; +.bg-infoxbox-action i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -.bg-infoxbox-propal, -.bg-infoxbox-facture, -.bg-infoxbox-commande{ - background-color: #dd4b39 !important; +.bg-infoxbox-propal i.fa, +.bg-infoxbox-facture i.fa, +.bg-infoxbox-commande i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -.bg-infoxbox-supplier_proposal, -.bg-infoxbox-invoice_supplier, -.bg-infoxbox-order_supplier{ - background-color: #00c0ef !important; +.bg-infoxbox-supplier_proposal i.fa, +.bg-infoxbox-invoice_supplier i.fa, +.bg-infoxbox-order_supplier i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -.bg-infoxbox-contrat{ - background-color: #00a65a !important; +.bg-infoxbox-contrat i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -.bg-infoxbox-bank_account{ - background-color: #f39c12 !important; +.bg-infoxbox-bank_account i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -.bg-infoxbox-adherent{ - //background-color: #f39c12 !important; +.bg-infoxbox-adherent i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -.bg-infoxbox-expensereport{ - background-color: #a55114 !important; +.bg-infoxbox-expensereport i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -.bg-infoxbox-holiday{ - background-color: #cbd81b !important; +.bg-infoxbox-holiday i.fa{ + color: global->THEME_AGRESSIVITY_RATIO); ?> !important; } -*/ + .fa-dol-action:before { content: "\f073";