mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Add weather
This commit is contained in:
parent
6973e29b2c
commit
83d0f1f27f
162
htdocs/index.php
162
htdocs/index.php
|
|
@ -313,6 +313,7 @@ if (empty($user->societe_id) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTAT
|
|||
|
||||
|
||||
// Loop and displays each line of table
|
||||
$boardloaded=array();
|
||||
foreach ($keys as $key=>$val)
|
||||
{
|
||||
if ($conditions[$key])
|
||||
|
|
@ -643,13 +644,15 @@ foreach($dashboardlines as $infoKey => $tmp)
|
|||
foreach($valid_dashboardlines as $board)
|
||||
{
|
||||
if ($board->nbtodolate > 0) {
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totaltodo += $board->nbtodo;
|
||||
$totaltodo += $board->nbtodo;
|
||||
$totallate += $board->nbtodolate;
|
||||
}
|
||||
}
|
||||
//var_dump($totallate, $totaltodo);
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) && !empty($totaltodo)) $totallate = round($totallate / $totaltodo * 100, 2);
|
||||
//var_dump($totallate);
|
||||
|
||||
$totalLateNumber = $totallate;
|
||||
$totallatePercentage = !empty($totaltodo) ? round($totallate / $totaltodo * 100, 2) : 0;
|
||||
if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = $totallatePercentage;
|
||||
|
||||
$boxwork='';
|
||||
$boxwork.='<div class="box">';
|
||||
$boxwork.='<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable boxtablenobottom boxworkingboard" width="100%">'."\n";
|
||||
|
|
@ -685,7 +688,7 @@ $boxwork.='</tr>'."\n";
|
|||
// Show dashboard
|
||||
$nbworkboardempty=0;
|
||||
$isIntopOpenedDashBoard = array();
|
||||
if (! empty($valid_dashboardlines))
|
||||
if (!empty($valid_dashboardlines))
|
||||
{
|
||||
$openedDashBoard = '';
|
||||
|
||||
|
|
@ -746,14 +749,46 @@ if (! empty($valid_dashboardlines))
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
$openedDashBoard.= ' </div><!-- /.info-box-content -->'."\n";
|
||||
$openedDashBoard.= ' </div><!-- /.info-box -->'."\n";
|
||||
$openedDashBoard.= '</div><!-- /.box-flex-item -->'."\n";
|
||||
$openedDashBoard.="\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ($showweather && !empty($isIntopOpenedDashBoard))
|
||||
{
|
||||
$appendClass = $conf->global->MAIN_DISABLE_METEO == 2 ?' hideonsmartphone' : '';
|
||||
$weather = getWeatherStatus($totallate);
|
||||
|
||||
$text='';
|
||||
if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate", $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')';
|
||||
else $text=$langs->transnoentitiesnoconv("NoItemLate");
|
||||
$text.='. '.$langs->transnoentitiesnoconv("LateDesc");
|
||||
|
||||
|
||||
|
||||
$weatherDashBoard= '<div class="box-flex-item '.$appendClass.'">'."\n";
|
||||
$weatherDashBoard.= ' <div class="info-box info-box-weather info-box-weather-level'.$weather->level.'">'."\n";
|
||||
$weatherDashBoard.= ' <span class="info-box-icon"><i class="fa fa-weather-level'.$weather->level.'"></i></span>'."\n";
|
||||
$weatherDashBoard.= ' <div class="info-box-content">'."\n";
|
||||
$weatherDashBoard.= ' <span class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</span>' . "\n";
|
||||
$weatherDashBoard.= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv("NActionsLate", $totalLateNumber).'</span>' . "\n";
|
||||
|
||||
/*if($totallatePercentage>0){
|
||||
$weatherDashBoard.= ' <div class="progress"><div class="progress-bar" style="width: '.$totallatePercentage.'%"></div></div>';
|
||||
$weatherDashBoard.= ' <span class="progress-description">'.$langs->trans('NActionsLate', price($totallatePercentage).'%').'</span>' . "\n";
|
||||
}*/
|
||||
|
||||
$weatherDashBoard.= ' </div><!-- /.info-box-content -->'."\n";
|
||||
$weatherDashBoard.= ' </div><!-- /.info-box -->'."\n";
|
||||
$weatherDashBoard.= '</div><!-- /.box-flex-item -->'."\n";
|
||||
$weatherDashBoard.="\n";
|
||||
|
||||
$openedDashBoard=$weatherDashBoard.$openedDashBoard;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
|
|
@ -763,19 +798,14 @@ if (! empty($valid_dashboardlines))
|
|||
$nbworkboardcount=0;
|
||||
foreach($valid_dashboardlines as $infoKey => $board)
|
||||
{
|
||||
if(in_array($infoKey, $isIntopOpenedDashBoard)){
|
||||
if(in_array($infoKey, $isIntopOpenedDashBoard)) {
|
||||
// skip if info is present on top
|
||||
continue;
|
||||
}
|
||||
|
||||
//continue;
|
||||
}
|
||||
|
||||
if (empty($board->nbtodo)) $nbworkboardempty++;
|
||||
$nbworkboardcount++;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">';
|
||||
$boxwork .= '<div class="boxstatscontent">';
|
||||
$sep=($conf->dol_use_jmobile?'<br>':' ');
|
||||
|
|
@ -800,15 +830,6 @@ if (! empty($valid_dashboardlines))
|
|||
}
|
||||
$boxwork.='</div></div>';
|
||||
$boxwork .="\n";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
|
||||
|
|
@ -932,33 +953,68 @@ function showWeather($totallate, $text, $options, $morecss = '')
|
|||
{
|
||||
global $conf;
|
||||
|
||||
$out='';
|
||||
$offset=0;
|
||||
$factor=10; // By default
|
||||
|
||||
$used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL';
|
||||
|
||||
$level0=$offset;
|
||||
if (! empty($conf->global->{$used_conf.'0'})) {
|
||||
$level0=$conf->global->{$used_conf.'0'};
|
||||
}
|
||||
$level1=$offset+1*$factor;
|
||||
if (! empty($conf->global->{$used_conf.'1'})) {
|
||||
$level1=$conf->global->{$used_conf.'1'};
|
||||
}
|
||||
$level2=$offset+2*$factor;
|
||||
if (! empty($conf->global->{$used_conf.'2'})) {
|
||||
$level2=$conf->global->{$used_conf.'2'};
|
||||
}
|
||||
$level3=$offset+3*$factor;
|
||||
if (! empty($conf->global->{$used_conf.'3'})) {
|
||||
$level3=$conf->global->{$used_conf.'3'};
|
||||
}
|
||||
|
||||
if ($totallate <= $level0) $out.=img_weather($text, 'weather-clear.png', $options, 0, $morecss);
|
||||
elseif ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text, 'weather-few-clouds.png', $options, 0, $morecss);
|
||||
elseif ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text, 'weather-clouds.png', $options, 0, $morecss);
|
||||
elseif ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text, 'weather-many-clouds.png', $options, 0, $morecss);
|
||||
elseif ($totallate > $level3) $out.=img_weather($text, 'weather-storm.png', $options, 0, $morecss);
|
||||
return $out;
|
||||
$weather = getWeatherStatus($totallate);
|
||||
return img_weather($text, $weather->picto, $options, 0, $morecss);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get weather level
|
||||
* $conf->global->MAIN_METEO_LEVELx
|
||||
*
|
||||
* @param int $totallate Nb of element late
|
||||
* @return string Return img tag of weather
|
||||
*/
|
||||
function getWeatherStatus($totallate)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$weather = new stdClass();
|
||||
$weather->picto = '';
|
||||
|
||||
$offset=0;
|
||||
$factor=10; // By default
|
||||
|
||||
$used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL';
|
||||
|
||||
$level0=$offset;
|
||||
$weather->level=0;
|
||||
if (! empty($conf->global->{$used_conf.'0'})) {
|
||||
$level0=$conf->global->{$used_conf.'0'};
|
||||
}
|
||||
$level1=$offset+1*$factor;
|
||||
if (! empty($conf->global->{$used_conf.'1'})) {
|
||||
$level1=$conf->global->{$used_conf.'1'};
|
||||
}
|
||||
$level2=$offset+2*$factor;
|
||||
if (! empty($conf->global->{$used_conf.'2'})) {
|
||||
$level2=$conf->global->{$used_conf.'2'};
|
||||
}
|
||||
$level3=$offset+3*$factor;
|
||||
if (! empty($conf->global->{$used_conf.'3'})) {
|
||||
$level3=$conf->global->{$used_conf.'3'};
|
||||
}
|
||||
|
||||
if ($totallate <= $level0){
|
||||
$weather->picto = 'weather-clear.png';
|
||||
$weather->level=0;
|
||||
}
|
||||
elseif ($totallate <= $level1){
|
||||
$weather->picto = 'weather-few-clouds.png';
|
||||
$weather->level=1;
|
||||
}
|
||||
elseif ($totallate <= $level2){
|
||||
$weather->picto = 'weather-clouds.png';
|
||||
$weather->level=2;
|
||||
}
|
||||
elseif ($totallate <= $level3){
|
||||
$weather->picto = 'weather-many-clouds.png';
|
||||
$weather->level=3;
|
||||
}
|
||||
else{
|
||||
$weather->picto = 'weather-storm.png';
|
||||
$weather->level=4;
|
||||
}
|
||||
|
||||
return $weather;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -984,3 +984,4 @@ NoRecordedUsers=No users
|
|||
ToClose=To close
|
||||
ToProcess=To process
|
||||
ToApprove=To approve
|
||||
GlobalOpenedElemView=
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
|
|||
min-height: 90px;
|
||||
background: #fff;
|
||||
width: 100%;
|
||||
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.1), 0px 0px 2px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2), 0px 0px 2px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 2px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
|
@ -27,8 +27,21 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
|
|||
.info-box .progress .progress-bar {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.info-box .progress .progress-bar {
|
||||
background: #fff;
|
||||
float: left;
|
||||
width: 0;
|
||||
height: 100%;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
background-color: #337ab7;
|
||||
-webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);
|
||||
box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);
|
||||
-webkit-transition: width .6s ease;
|
||||
-o-transition: width .6s ease;
|
||||
transition: width .6s ease;
|
||||
}
|
||||
.info-box-icon {
|
||||
border-top-left-radius: 2px;
|
||||
|
|
@ -81,6 +94,8 @@ a.info-box-text{ text-decoration: none;}
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ICONS */
|
||||
.info-box-icon {
|
||||
color: #fff !important;
|
||||
|
|
@ -154,6 +169,62 @@ a.info-box-text{ text-decoration: none;}
|
|||
}
|
||||
|
||||
|
||||
/* USING FONTAWESOME FOR WEATHER */
|
||||
.info-box-weather .info-box-icon{
|
||||
background: rgba(0, 0, 0, 0); !important;
|
||||
}
|
||||
.fa-weather-level0:before{
|
||||
content: "\f185";
|
||||
color : #cccccc;
|
||||
}
|
||||
.fa-weather-level1:before{
|
||||
content: "\f6c4";
|
||||
color : #cccccc;
|
||||
}
|
||||
.fa-weather-level2:before{
|
||||
content: "\f0c2";
|
||||
color : #cccccc;
|
||||
}
|
||||
.fa-weather-level3:before{
|
||||
content: "\f740";
|
||||
color : #cccccc;
|
||||
}
|
||||
.fa-weather-level4:before{
|
||||
content: "\f0e7";
|
||||
color : #b91f1f;
|
||||
}
|
||||
|
||||
/* USING IMAGES FOR WEATHER INTEAD OF FONT AWESOME */
|
||||
/* For other themes just uncomment this part */
|
||||
/*.info-box-weather-level0,
|
||||
.info-box-weather-level1,
|
||||
.info-box-weather-level2,
|
||||
.info-box-weather-level3,
|
||||
.info-box-weather-level4 {
|
||||
background-position: 15px 50%;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.info-box-weather .info-box-icon{
|
||||
display: none !important;
|
||||
}
|
||||
.info-box-weather-level0 {
|
||||
background-image: url("img/weather/weather-clear.png");
|
||||
}
|
||||
.info-box-weather-level1 {
|
||||
background-image: url("img/weather/weather-few-clouds.png");
|
||||
}
|
||||
.info-box-weather-level2 {
|
||||
background-image: url("img/weather/weather-clouds.png");
|
||||
}
|
||||
.info-box-weather-level3 {
|
||||
background-image: url("img/weather/weather-many-clouds.png");
|
||||
}
|
||||
.info-box-weather-level4 {
|
||||
background-image: url("img/weather/weather-storm.png");
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
.box-flex-container{
|
||||
display: flex; /* or inline-flex */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user