| Server IP : 162.214.74.102 / Your IP : 216.73.216.59 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/www/lrsys_apps/dialogo/application/plugins/module_fleet/controllers/ |
Upload File : |
<?php
_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':
$vehicleBrand = new VehicleBrand();
$all = $vehicleBrand->all('sorder');
$ui->assign('vehicles_brand', $all);
$ui->assign('jsvar', '
_L[\'are_you_sure\'] = \'' . $_L['are_you_sure'] . '\';
');
$ui->assign('xfooter', '<script type="text/javascript" src="' . $_pd . '/assets/js/vehicles-brand.js"></script>');
$ui->assign('_include', 'list-vehicles-brand');
$ui->display('wrapper.tpl');
break;
case 'add-post':
//recebe o nome do segmento para adicionar no banco de dados
$msg = "";
$name = _post('name');
if (trim($name) == '') {
$msg = $_L['Name'] . $_L['is required'];
}
if ($msg == '') {
$vehicleBrand = new VehicleBrand();
$novo = $vehicleBrand->create();
$novo->name = $name;
$novo->save();
echo $novo->id;
} else {
echo $msg;
}
break;
case 'edit-post':
$vt = new VehicleBrand();
//passa o id no getone()
$d = $vt->getOne(intval(_post('id')));
if ($d) {
if (!$d->default) {
$d->name = _post('name');
$d->save();
_log($_L['Vehicle Brand Added'] . " - " + $d->name, 'Admin', $user['id']);
r2(U . 'module_fleet/vehicles_brand/list/', 's', $_L['Vehicle Brand Updated Successfully']);
// }
} else {
r2(U . 'module_fleet/vehicles_brand/list', 'e', $_L['Not permited edit this vehicle Brand']);
}
} else {
echo $_L['Not found'];
}
break;
case 'delete':
$vt = new VehicleBrand();
//passa o id no getone()
$d = $vt->getOne(intval($routes[3]));
if ($d) {
if (!$d->default) {
// find all items com a unidade
//se encontrar emite mensagem de impossibilidade de exclusão
// $itens = ORM::for_table('sys_items')->raw_query(" select 1 from sys_items where commercial_unit_id = $id or tax_unit_id=$id ")->find_many();
// if (count($itens) > 0) {
// r2(U . 'unit/list/', 'e', $_L['Not permited remove this unit. Unit having Items']);
// } else {
$d->delete();
_log($_L['Vehicle Brand Deleted'] . " - " + $d->name, 'Admin', $user['id']);
r2(U . 'module_fleet/vehicles_brand/list/', 's', $_L['Vehicle Brand Deleted Successfully']);
// }
} else {
r2(U . 'module_fleet/vehicles_brand/list', 'e', $_L['Not permited remove this vehicle brand']);
}
} else {
echo $_L['Not found'];
}
break;
case 'reorder':
$vehicleBrand = new VehicleBrand();
//passa o id no getone()
$all = $vehicleBrand->all('sorder');
$ui->assign('ritem', $_L['Fleets Vehicles Brand']);
$ui->assign('d', $all);
$ui->assign('xheader', '
<link rel="stylesheet" type="text/css" href="' . $_theme . '/css/liststyle.css"/>
');
$ui->assign('display_name', 'name');
$ui->assign('xjq', Reorder::js('module_fleets_vehicle_brand'));
$ui->display('reorder.tpl');
break;
case 'ajax-list':
//recebe o parametro do estado
$vehicleBrand = new VehicleBrand();
//passa o id no getone()
$all = $vehicleBrand->all('sorder');
foreach ($all as $s) {
$data[] = array(
'id' => $s->id,
'name' => ($s->default) ? $_L[$s->name] : $s->name
);
}
echo json_encode($data);
break;
echo 'action not defined';
}