| Server IP : 162.214.74.102 / Your IP : 216.73.217.80 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/lrsys/public_html/lrsys_apps/dialogo/application/plugins/module_fleet/controllers/ |
Upload File : |
<?php
_auth();
$ui->assign('_title', $_L['Module Fleets']. ' - ' . $config['CompanyName']);
$ui->assign('_st', $_L['Module Fleets']." - ".$_L['Fleets Report']);
$user = User::_info();
$ui->assign('user', $user);
$action = route(2);
if ($action == '') {
$action = 'index';
}
$jsvar = '
_L[\'Income\'] = \'' . $_L['Income'] . '\';
_L[\'Expense\'] = \'' . $_L['Expense'] . '\';
_L[\'Fleet Driver Comsumer Diary\'] = \'' . $_L['Fleet Driver Comsumer Diary'] . '\';
_L[\'Income n Expense\'] = \'' . $_L['Income n Expense'] . '\';
_L[\'Income vs Expense\'] = \'' . $_L['Income vs Expense'] . '\';
_L[\'Cash Flow\'] = \'' . $_L['Cash Flow'] . '\';
_L[\'Jan\'] = \'' . $_L['Jan'] . '\';
_L[\'Feb\'] = \'' . $_L['Feb'] . '\';
_L[\'Mar\'] = \'' . $_L['Mar'] . '\';
_L[\'Apr\'] = \'' . $_L['Apr'] . '\';
_L[\'May\'] = \'' . $_L['May'] . '\';
_L[\'Jun\'] = \'' . $_L['Jun'] . '\';
_L[\'Jul\'] = \'' . $_L['Jul'] . '\';
_L[\'Aug\'] = \'' . $_L['Aug'] . '\';
_L[\'Sep\'] = \'' . $_L['Sep'] . '\';
_L[\'Oct\'] = \'' . $_L['Oct'] . '\';
_L[\'Nov\'] = \'' . $_L['Nov'] . '\';
_L[\'Dec\'] = \'' . $_L['Dec'] . '\';
_L[\'Last 12 Months\'] = \'' . $_L['Last 12 Months'] . '\';
_L[\'Data View\'] = \'' . $_L['Data View'] . '\';
_L[\'Refresh\'] = \'' . $_L['Refresh'] . '\';
_L[\'Reset\'] = \'' . $_L['Reset'] . '\';
_L[\'Cancel\'] = \'' . $_L['Cancel'] . '\';
_L[\'Save as Image\'] = \'' . $_L['Save as Image'] . '\';
_L[\'Click to Save\'] = \'' . $_L['Click to Save'] . '\';
_L[\'Average\'] = \'' . $_L['Average'] . '\';
_L[\'Line\'] = \'' . $_L['Line'] . '\';
_L[\'Bar\'] = \'' . $_L['Bar'] . '\';
var c_month = \'' . ib_lan_get_line(date('F')) . '\';
var c_year = \'' . date('Y') . '\';
var ib_graph_primary_color = \'#2196f3\';
var ib_graph_secondary_color = \'#eb3c00\';
';
switch ($action) {
case 'index':
if(!empty(_post('date'))){
$date= _post('date');
$date=explode('/', $date);
$_SESSION['ano_filtro_consumo_diario']=$date[1];
$_SESSION['mes_filtro_consumo_diario']=$date[0];
}
$ano_filtro=isset($_SESSION['ano_filtro_consumo_diario'])?$_SESSION['ano_filtro_consumo_diario']:date('Y');
$mes_filtro=isset($_SESSION['mes_filtro_consumo_diario'])?$_SESSION['mes_filtro_consumo_diario']:date('m');
$ui->assign('date',$mes_filtro."/".$ano_filtro);
$xheader = Asset::css(array('dp/dist/datepicker.min'));
$xfooter = Asset::js(array('dashboard/graph', 'chart/echarts.min', 'numeric','dp/dist/datepicker.min'));
$xjq = '';
$dashboard_section_0 = '';
$ui->assign('xheader', $xheader);
$ui->assign('xfooter', $xfooter );
$ui->assign('jsvar', $jsvar. showGraphconsummer_driver(). showGraph_km_lts());
$ui->assign('xjq', "");
$ui->assign('_include', 'report_fleets');
$ui->display('wrapper.tpl');
break;
}
function showGraphconsummer_driver(){
global $_L;
$ano_filtro=isset($_SESSION['ano_filtro_consumo_diario'])?$_SESSION['ano_filtro_consumo_diario']:date('Y');
$mes_filtro=isset($_SESSION['mes_filtro_consumo_diario'])?$_SESSION['mes_filtro_consumo_diario']:date('m');
//list de dias do mes selecionado
$finish_day = date("t", mktime(0, 0, 0, $mes_filtro, '01', $ano_filtro));
$listDay = '';
for ($i = 1; $i <= $finish_day; $i++) {
$listDay.= ",'".($i < 10 ? "0" . $i : $i)."'";
}
//lista de funcioinarios com registros em frotas
$employes = ORM::for_table('crm_accounts')
->table_alias('c')
->select_expr('distinct(c.id) as id_unico')
->select('c.*')
->join('module_fleets_alocation_vehicle', array('a.employee_id', '=', 'c.id'), 'a')
->find_many();
$values='';
$dataPie="";
foreach ($employes as $e) {
$diaryConsum="";
$sumConsumerLts=0;
for ($i = 1; $i <= $finish_day; $i++) {
$consumer = ORM::for_table('module_fleets_alocation_vehicle')
->raw_query("SELECT sum((tank_out+supply_liters)-tank_in ) as lts FROM erp_lrsys.module_fleets_alocation_vehicle
where date_out>='".$ano_filtro."-".$mes_filtro."-".$i." 00:00:00' and date_out<='".$ano_filtro."-".$mes_filtro."-".$i." 23:59:59' and `out`='0'"
. " and employee_id=".$e->id
. "")->find_many();
if($consumer[0]->lts>0){
$diaryConsum.=",".$consumer[0]->lts;
$sumConsumerLts+=$consumer[0]->lts;
}else{
$diaryConsum.=",0";
}
}
$dataPie.=",{name:'".$e->account."',value:".$sumConsumerLts."}";
$values.= ",{
name:'".$e->account."',
type:'line',
smooth:true,
itemStyle: {normal: {areaStyle: {type: 'default'}}},
data:[".substr($diaryConsum,1)."]
}";
}
return " $(function() { var c3_opt = {
title : {
text:_L['Fleet Driver Comsumer Diary'],
subtext: '".$mes_filtro." / ".$ano_filtro."'
},
tooltip : {
trigger: 'axis'
},
// legend: {
// data:['Moto 1','Moto 2']//[_L['Income'],_L['Expense']]
// },
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false, title : _L['Data View'],
lang: [_L['Data View'], _L['Cancel'], _L['Reset']] },
magicType : {show: true, title : {
line : 'Line',
bar : 'Bar',
stack : 'Stack',
tiled : 'Tiled',
force: 'Force',
chord: 'Chord',
pie: 'Pie',
funnel: 'Funnel'
}, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true, title : 'Reset'},
saveAsImage : {show: true, title : _L['Save as Image'],
type : 'png',
lang : [_L['Click to Save']]}
}
},
calculable : true,
xAxis : [
{
type : 'category',
boundaryGap : false,
data :[". substr($listDay, 1)."]
}
],
yAxis : [
{
type : 'value'
}
],
series :
[
".substr($values,1)."
]
};
var c3_d = echarts.init(document.getElementById('driver_consum'));
c3_d.setOption(c3_opt);
//fim do primeiro gráfico
var c2_opt = {
tooltip : {
trigger: 'item',
formatter: \"{a} <br/>{b} : {c} ({d}%)\"
},
legend: {
orient : 'vertical',
x : 'left',
data:['','']
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, title : _L['Data View'],
readOnly: false,
lang: [_L['Data View'], _L['Cancel'], _L['Reset']] },
restore : {show: true, title : 'Reset'},
saveAsImage : {show: true, title : _L['Save as Image'],
type : 'png',
lang : [_L['Click to Save']]}
}
},
calculable : true,
series : [
{
name:'".$_L['Fleets Percentage of spending fuels per employeer']."',
type:'pie',
radius : ['50%', '60%'],
itemStyle : {
normal : {
label : {
show : true
},
labelLine : {
show : true
}
},
emphasis : {
label : {
show : true,
position : 'center',
textStyle : {
fontSize : '30',
fontWeight : 'bold'
}
}
}
},
data:[
".substr($dataPie,1)."
]
}
]
};
var c2 = echarts.init(document.getElementById('consumer_driver_pie'));
c2.setOption(c2_opt);
});";
}
function showGraph_km_lts(){
global $_L;
$ano_filtro=isset($_SESSION['ano_filtro_consumo_diario'])?$_SESSION['ano_filtro_consumo_diario']:date('Y');
$mes_filtro=isset($_SESSION['mes_filtro_consumo_diario'])?$_SESSION['mes_filtro_consumo_diario']:date('m');
//list de dias do mes selecionado
$finish_day = date("t", mktime(0, 0, 0, $mes_filtro, '01', $ano_filtro));
$listDay = '';
$lts="";
$km="";
for ($i = 1; $i <= $finish_day; $i++) {
$listDay.= ",'".($i < 10 ? "0" . $i : $i)."'";
$consumer = ORM::for_table('module_fleets_alocation_vehicle')
->raw_query("SELECT sum((tank_out+supply_liters)-tank_in ) as lts ,
sum(km_in-km_out) as km
FROM erp_lrsys.module_fleets_alocation_vehicle
where date_out>='".$ano_filtro."-".$mes_filtro."-".$i." 00:00:00' and date_out<='".$ano_filtro."-".$mes_filtro."-".$i." 23:59:59' and `out`='0'"
. "")->find_many();
if($consumer[0]->lts>0){
$lts.=",".$consumer[0]->lts;
}else{
$lts.=",0";
}
if($consumer[0]->km>0){
$km.=",".$consumer[0]->km;
}else{
$km.=",0";
}
}
$series="{
name:'".$_L['Fleets Km']."',
type:'line',
smooth:true,
itemStyle: {normal: {areaStyle: {type: 'default'}}},
data:[".substr($km,1)."]
}".",{
name:'".$_L['Fleets Lts']."',
type:'line',
smooth:true,
itemStyle: {normal: {areaStyle: {type: 'default'}}},
data:[".substr($lts,1)."]
}";
return " $(function() { var c4_opt = {
title : {
text:'".$_L['Fleets Chart Km / Lts']."',
subtext: '".$mes_filtro." / ".$ano_filtro."'
},
tooltip : {
trigger: 'axis'
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true, readOnly: false, title : _L['Data View'],
lang: [_L['Data View'], _L['Cancel'], _L['Reset']] },
magicType : {show: true, title : {
line : 'Line',
bar : 'Bar',
stack : 'Stack',
tiled : 'Tiled',
force: 'Force',
chord: 'Chord',
pie: 'Pie',
funnel: 'Funnel'
}, type: ['line', 'bar', 'stack', 'tiled']},
restore : {show: true, title : 'Reset'},
saveAsImage : {show: true, title : _L['Save as Image'],
type : 'png',
lang : [_L['Click to Save']]}
}
},
calculable : true,
xAxis : [
{
type : 'category',
boundaryGap : false,
data :[". substr($listDay, 1)."]
}
],
yAxis : [
{
type : 'value'
}
],
series :
[
".$series."
]
};
var c4_d = echarts.init(document.getElementById('km_lts'));
c4_d.setOption(c4_opt);
});";
}