| 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/leve/application/plugins/module_fleet/controllers/ |
Upload File : |
<?php
/*
Modelo de exemplo.. Ajustar para o seu plugin
*/
_auth();
$ui->assign('_application_menu', $routes['1']);
$ui->assign('_title', $_L['Module Fleets'] . ' - ' . $config['CompanyName']);
$action = $routes['2'];
$user = User::_info();
$ui->assign('user', $user);
$ui->assign('_st', $_L['Module Fleets']);
switch ($action) {
case 'list':
//$paginator = Paginator::bootstrap('module_fleets_vehicle');
$all = ORM::for_table('module_fleets_vehicle')->order_by_desc('id')->find_many();//->offset($paginator['startpoint'])->limit($paginator['limit'])
$ui->assign('vehicles', $all);
$ui->assign('jsvar', '
_L[\'are_you_sure\'] = \'' . $_L['are_you_sure'] . '\';
');
$js_arr = array(
'numeric');
$assets_js = Asset::js($js_arr);
$ui->assign('xfooter', $assets_js . '<script type="text/javascript" src="' . $_pd . '/assets/js/vehicles-list.js"></script>');
//bottom bar com as informações
$total_value_market = 0;
foreach ($all as $v) {
$total_value_market+=$v['market_value'];
// $tota
}
$bottomBar = array(
// array('type'=>'monetary','info'=>$_L['Total Pending'],'value'=> 21),
// array('type'=>'monetary','info'=>$_L['Total Paid'],'value'=> 11),
array('type' => 'monetary', 'info' => $_L['Fleets Current value of the fleet'], 'value' => $total_value_market),
array('type' => 'int', 'info' => $_L['Fleets Vehicles Total'], 'value' => count($all))
);
$ui->assign('bottomBar', $bottomBar);
// $ui->assign('paginator', $paginator);
$ui->assign('_include', 'list-vehicles');
$ui->display('wrapper.tpl');
break;
case 'add':
$vehicleType = new VehicleType();
$ui->assign('vehicles_type', $vehicleType->all('sorder'));
$ui->assign('vehicle', null);
$ui->assign('title', $_L['Fleets Add New Vehicle']);
$css_arr = array(
'modal',
's2/css/select2.min','dp/dist/datepicker.min');
$js_arr = array(
's2/js/select2.min','dp/dist/datepicker.min',
'modal','numeric');
$assets_css = Asset::css($css_arr);
$assets_js = Asset::js($js_arr);
$ui->assign('xheader', $assets_css);
$ui->assign('xfooter', $assets_js . '<script type="text/javascript" src="' . $_pd . '/assets/js/vehicles.js"></script>');
$ui->assign('xjq', '
$(\'.amount\').autoNumeric(\'init\', {
dGroup: ' . $config['thousand_separator_placement'] . ',
aPad: ' . $config['currency_decimal_digits'] . ',
pSign: \'' . $config['currency_symbol_position'] . '\',
aDec: \'' . $config['dec_point'] . '\',
aSep: \'' . $config['thousands_sep'] . '\'
});
$(\'.integer\').autoNumeric(\'init\', {aSep: \'\', aDec: \'' . $config['dec_point'] . '\', mDec: 0, aSign: \' \', pSign: \'s\'});
');
$ui->assign('_include', 'vehicle-form');
$ui->display('wrapper.tpl');
break;
case 'add-post':
//recebe o nome do segmento para adicionar no banco de dados
$msg = "";
$board = _post('board');
if (trim($board) == '') {
$msg = $_L['Fleets Board'] . $_L['is required'];
}
if ($msg == '') {
$vehicle = new Vehicle();
$novo = $vehicle->create();
$novo->board = $board;
empty(_post('module_fleets_vehicle_type_id')) ? '' : $novo->module_fleets_vehicle_type_id = _post('module_fleets_vehicle_type_id');
empty(_post('module_fleets_vehicle_brand_id')) ? '' : $novo->module_fleets_vehicle_brand_id = _post('module_fleets_vehicle_brand_id');
empty(_post('fuel')) ? '' : $novo->fuel = _post('fuel');
// $novo->brand = _post('brand');
$novo->model = _post('model');
empty(_post('year')) ? '' : $novo->year = _post('year');
$novo->renavam = _post('renavam');
$novo->acquisition_value = Finance::amount_fix(_post('acquisition_value'));
$novo->market_value = Finance::amount_fix(_post('market_value'));
empty(_post('current_km')) ? '' : $novo->current_km = _post('current_km');
$novo->save();
_log($_L['Fleets Vehicles Added Successfully'] . "[ID]: " . $novo->id, $user['fullname'], $user['id']);
_notify($_L['Fleets Vehicles Added Successfully'], 's');
echo $novo->id;
} else {
echo $msg;
}
break;
case 'edit':
$v = new Vehicle();
$vehicle = $v->getOne(intval($routes['3']));
if ($vehicle) {
$vehicleType = new VehicleType();
$ui->assign('vehicles_type', $vehicleType->all('sorder'));
$ui->assign('vehicle', $vehicle);
$css_arr = array(
'modal',
's2/css/select2.min','dp/dist/datepicker.min');
$js_arr = array(
's2/js/select2.min','dp/dist/datepicker.min',
'modal','numeric');
$assets_css = Asset::css($css_arr);
$assets_js = Asset::js($js_arr);
$ui->assign('xheader', $assets_css);
$ui->assign('xfooter', $assets_js . '<script type="text/javascript" src="' . $_pd . '/assets/js/vehicles.js"></script>');
$ui->assign('xjq', '
$(\'.amount\').autoNumeric(\'init\', {
dGroup: ' . $config['thousand_separator_placement'] . ',
aPad: ' . $config['currency_decimal_digits'] . ',
pSign: \'' . $config['currency_symbol_position'] . '\',
aDec: \'' . $config['dec_point'] . '\',
aSep: \'' . $config['thousands_sep'] . '\'
});
$(\'.integer\').autoNumeric(\'init\', {aSep: \'\', aDec: \'' . $config['dec_point'] . '\', mDec: 0, aSign: \' \', pSign: \'s\'});
');
$ui->assign('title', $_L['Fleets Edit Vehicle']);
$ui->assign('_include', 'vehicle-form');
$ui->display('wrapper.tpl');
} else {
r2('ps/p-list', 'e', $_L['Not Found']);
}
break;
case 'edit-post':
//recebe o nome do segmento para adicionar no banco de dados
$msg = "";
$board = _post('board');
if (trim($board) == '') {
$msg = $_L['Fleets Board'] . $_L['is required'];
}
if ($msg == '') {
$v = new Vehicle();
//passa o id no getone()
$d = $v->getOne(intval(_post('id')));
if ($d) {
$d->board = $board;
$d->module_fleets_vehicle_type_id = empty(_post('module_fleets_vehicle_type_id')) ? null : _post('module_fleets_vehicle_type_id');
$d->module_fleets_vehicle_brand_id = empty(_post('module_fleets_vehicle_brand_id')) ? null : _post('module_fleets_vehicle_brand_id');
$d->fuel= empty(_post('fuel')) ? null : _post('fuel');
// $d->brand = _post('brand');
$d->model = _post('model');
$d->year = empty(_post('year')) ? null : _post('year');
$d->renavam = _post('renavam');
$d->acquisition_value = Finance::amount_fix(_post('acquisition_value'));
$d->market_value = Finance::amount_fix(_post('market_value'));
$d->current_km = empty(_post('current_km')) ? null : _post('current_km');
$d->save();
_log($_L['Fleets Vehicles Edited Successfully'] . "[ID]: " . $d->id, $user['fullname'], $user['id']);
_notify($_L['Fleets Vehicles Edited Successfully'], 's');
echo $d->id;
} else {
echo $_L['Not found'];
}
} else {
echo $msg;
}
break;
case 'delete':
$v = new Vehicle();
//passa o id no getone()
$d = $v->getOne(intval($routes[3]));
if ($d) {
$d->delete();
_log($_L['Vehicle Deleted Successfully'] . " - " + $d->id, 'Admin', $user['id']);
r2(U . 'module_fleet/vehicles/list/', 's', $_L['Fleets Vehicle Deleted Successfully']);
} else {
echo $_L['Not found'];
}
break;
case 'ajax-list':
$vehicle = new Vehicle();
//recebe o parametro do estado
if(isset($routes[3]) && $routes[3]=='alocation'){
$all=$vehicle->allNotOut();
}else{
$all = $vehicle->all('sorder');
}
foreach ($all as $s) {
$data[] = array(
'id' => $s->id,
'model' => $s->model,
'brand' => $s->brand,
'board' => $s->board
);
}
echo json_encode($data);
break;
echo 'action not defined';
}