Skip to content

Commit

Permalink
Enhance #11643
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 18, 2019
1 parent 2285e0d commit b8e1cc8
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 66 deletions.
38 changes: 18 additions & 20 deletions htdocs/admin/delais.php
Expand Up @@ -195,7 +195,6 @@
{
foreach($delays as $delay)
{

$value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>';
Expand Down Expand Up @@ -235,7 +234,6 @@
{
foreach($delays as $delay)
{

$value=(! empty($conf->global->{$delay['code']})?$conf->global->{$delay['code']}:0);
print '<tr class="oddeven">';
print '<td width="20px">'.img_object('', $delay['img']).'</td>';
Expand Down Expand Up @@ -300,16 +298,16 @@

print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clear.png', $options);
print img_weather($text, 0, $options);
print '= <input type="text" size="2" name="MAIN_METEO_LEVEL0" value="'.$level0.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-few-clouds.png', $options);
print img_weather($text, 1, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL1" value="'.$level1.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clouds.png', $options);
print img_weather($text, 2, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL2" value="'.$level2.'"/></td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-many-clouds.png', $options);
print img_weather($text, 3, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_LEVEL3" value="'.$level3.'"/></td>';
print '</div>';
print '</div>';
Expand All @@ -320,16 +318,16 @@

print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clear.png', $options);
print img_weather($text, 0, $options);
print '= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL0" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-few-clouds.png', $options);
print img_weather($text, 1, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL1" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clouds.png', $options);
print img_weather($text, 2, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL2" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'"/>&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-many-clouds.png', $options);
print img_weather($text, 3, $options);
print '&lt;= <input type="text" size="2" name="MAIN_METEO_PERCENTAGE_LEVEL3" value="'.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'"/>&nbsp;%</td>';
print '</div>';
print '</div>';
Expand Down Expand Up @@ -371,39 +369,39 @@

print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clear.png', $options);
print img_weather($text, 0, $options);
print '= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL0.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-few-clouds.png', $options);
print img_weather($text, 1, $options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL1.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clouds.png', $options);
print img_weather($text, 2, $options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL2.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-many-clouds.png', $options);
print img_weather($text, 3, $options);
print '&lt;= '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-storm.png', $options);
print img_weather($text, 4, $options);
print '&gt; '.$conf->global->MAIN_METEO_PERCENTAGE_LEVEL3.'&nbsp;%</td>';
print '</div>';
print '</div>';
} else {

print '<div>';
print '<div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clear.png', $options);
print img_weather($text, 0, $options);
print '= '.$level0;
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-few-clouds.png', $options);
print img_weather($text, 1, $options);
print '&lt;= '.$level1;
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-clouds.png', $options);
print img_weather($text, 2, $options);
print '&lt;= '.$level2;
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-many-clouds.png', $options);
print img_weather($text, 3, $options);
print '&lt;= '.$level3;
print '</div><div class="inline-block" style="padding-right: 20px">';
print img_weather($text, 'weather-storm.png', $options);
print img_weather($text, 4, $options);
print '&gt; '.$level3;
print '</div>';
print '</div>';
Expand Down
10 changes: 8 additions & 2 deletions htdocs/core/lib/functions.lib.php
Expand Up @@ -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
Expand All @@ -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 '<i class="fa fa-weather-level'.$picto.'"></i>';
$picto = $leveltopicto[$picto];
}
elseif (! preg_match('/(\.png|\.gif)$/i', $picto)) $picto .= '.png';

$path = DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/weather/'.$picto;

Expand Down
50 changes: 47 additions & 3 deletions htdocs/core/lib/functions2.lib.php
Expand Up @@ -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)
{
Expand Down
4 changes: 1 addition & 3 deletions htdocs/index.php
Expand Up @@ -769,9 +769,7 @@
$weatherDashBoard= '<div class="box-flex-item '.$appendClass.'">'."\n";
$weatherDashBoard.= ' <div class="info-box '.$openedDashBoardSize.' info-box-weather info-box-weather-level'.$weather->level.'">'."\n";
$weatherDashBoard.= ' <span class="info-box-icon">';

$weatherDashBoard.= ' <i class="fa fa-weather-level'.$weather->level.'"></i>';

$weatherDashBoard.= img_weather('', $weather->level, '', 0, 'valignmiddle width50');
$weatherDashBoard.= ' </span>'."\n";
$weatherDashBoard.= ' <div class="info-box-content">'."\n";
$weatherDashBoard.= ' <span class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</span>' . "\n";
Expand Down
11 changes: 6 additions & 5 deletions htdocs/main.inc.php
Expand Up @@ -1258,11 +1258,12 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
$themeparam='?lang='.$langs->defaultlang.'&amp;theme='.$conf->theme.(GETPOST('optioncss', 'aZ09')?'&amp;optioncss='.GETPOST('optioncss', 'aZ09', 1):'').'&amp;userid='.$user->id.'&amp;entity='.$conf->entity;
$themeparam.=($ext?'&amp;'.$ext:'').'&amp;revision='.$conf->global->MAIN_IHM_PARAMS_REV;
if (! empty($_SESSION['dol_resetcache'])) $themeparam.='&amp;dol_resetcache='.$_SESSION['dol_resetcache'];
if (GETPOST('dol_hide_topmenu', 'int')) { $themeparam.='&amp;dol_hide_topmenu='.GETPOST('dol_hide_topmenu', 'int'); }
if (GETPOST('dol_hide_leftmenu', 'int')) { $themeparam.='&amp;dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu', 'int'); }
if (GETPOST('dol_optimize_smallscreen', 'int')) { $themeparam.='&amp;dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); }
if (GETPOST('dol_no_mouse_hover', 'int')) { $themeparam.='&amp;dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); }
if (GETPOST('dol_use_jmobile', 'int')) { $themeparam.='&amp;dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); }
if (GETPOSTISSET('dol_hide_topmenu')) { $themeparam.='&amp;dol_hide_topmenu='.GETPOST('dol_hide_topmenu', 'int'); }
if (GETPOSTISSET('dol_hide_leftmenu')) { $themeparam.='&amp;dol_hide_leftmenu='.GETPOST('dol_hide_leftmenu', 'int'); }
if (GETPOSTISSET('dol_optimize_smallscreen')) { $themeparam.='&amp;dol_optimize_smallscreen='.GETPOST('dol_optimize_smallscreen', 'int'); }
if (GETPOSTISSET('dol_no_mouse_hover')) { $themeparam.='&amp;dol_no_mouse_hover='.GETPOST('dol_no_mouse_hover', 'int'); }
if (GETPOSTISSET('dol_use_jmobile')) { $themeparam.='&amp;dol_use_jmobile='.GETPOST('dol_use_jmobile', 'int'); $conf->dol_use_jmobile=GETPOST('dol_use_jmobile', 'int'); }
if (GETPOSTISSET('THEME_AGRESSIVITY_RATIO')) { $themeparam.='&amp;THEME_AGRESSIVITY_RATIO='.GETPOST('THEME_AGRESSIVITY_RATIO', 'int'); }

if (! defined('DISABLE_JQUERY') && ! $disablejs && $conf->use_javascript_ajax)
{
Expand Down
23 changes: 14 additions & 9 deletions htdocs/theme/eldy/info-box.inc.php
Expand Up @@ -116,36 +116,41 @@
color: #fff !important;
}

<?php
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib/php';
if (! isset($conf->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: <?php print colorAgressivity('#605ca8', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-action{
background-color: #d84b80 !important;
background-color: <?php print colorAgressivity('#d84b80', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-propal,
.bg-infoxbox-facture,
.bg-infoxbox-commande{
background-color: #abb87b !important;
background-color: <?php print colorAgressivity('#abb87b', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-supplier_proposal,
.bg-infoxbox-invoice_supplier,
.bg-infoxbox-order_supplier{
background-color: #40b0cf !important;
background-color: <?php print colorAgressivity('#40b0cf', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-contrat{
background-color: #20a68a !important;
background-color: <?php print colorAgressivity('#20a68a', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-bank_account{
background-color: #e39c42 !important;
background-color: <?php print colorAgressivity('#e39c42', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-adherent{
//background-color: #f39c12 !important;
background-color: <?php print colorAgressivity('#f39c12', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-expensereport{
background-color: #755114 !important;
background-color: <?php print colorAgressivity('#755114', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-holiday{
background-color: #755114 !important;
background-color: <?php print colorAgressivity('#755114', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}


Expand Down
52 changes: 28 additions & 24 deletions htdocs/theme/md/info-box.inc.php
Expand Up @@ -95,39 +95,43 @@
.info-box-icon {
color: #000 !important;
}
/*
.bg-infoxbox-project{
background-color: #605ca8 !important;
<?php
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib/php';
if (! isset($conf->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: <?php print colorAgressivity('#605ca8', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-action{
background-color: #d81b60 !important;
.bg-infoxbox-action i.fa{
color: <?php print colorAgressivity('#d84b80', $conf->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: <?php print colorAgressivity('#abb87b', $conf->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: <?php print colorAgressivity('#40b0cf', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-contrat{
background-color: #00a65a !important;
.bg-infoxbox-contrat i.fa{
color: <?php print colorAgressivity('#20a68a', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-bank_account{
background-color: #f39c12 !important;
.bg-infoxbox-bank_account i.fa{
color: <?php print colorAgressivity('#e39c42', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-adherent{
//background-color: #f39c12 !important;
.bg-infoxbox-adherent i.fa{
color: <?php print colorAgressivity('#f39c12', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-expensereport{
background-color: #a55114 !important;
.bg-infoxbox-expensereport i.fa{
color: <?php print colorAgressivity('#755114', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
.bg-infoxbox-holiday{
background-color: #cbd81b !important;
.bg-infoxbox-holiday i.fa{
color: <?php print colorAgressivity('#755114', $conf->global->THEME_AGRESSIVITY_RATIO); ?> !important;
}
*/


.fa-dol-action:before {
content: "\f073";
Expand Down

0 comments on commit b8e1cc8

Please sign in to comment.