|
|
|
@ -23,6 +23,7 @@ import org.zkoss.zkplus.databind.BindingListModelList;
|
|
|
|
|
import org.zkoss.zul.Button;
|
|
|
|
|
import org.zkoss.zul.Combobox;
|
|
|
|
|
import org.zkoss.zul.Listheader;
|
|
|
|
|
import org.zkoss.zul.Paging;
|
|
|
|
|
|
|
|
|
|
import com.rjconsultores.ventaboletos.constantes.ConstantesFuncionSistema;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Categoria;
|
|
|
|
@ -30,13 +31,10 @@ import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Marca;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Moneda;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Parada;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.PerfilFuncion;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Tarifa;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.TipoPuntoVenta;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Tramo;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Usuario;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.UsuarioPerfil;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Via;
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
|
|
|
|
import com.rjconsultores.ventaboletos.service.CategoriaService;
|
|
|
|
@ -54,7 +52,10 @@ import com.rjconsultores.ventaboletos.utilerias.CustomEnum;
|
|
|
|
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
|
|
|
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
|
|
|
|
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
|
|
|
|
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject;
|
|
|
|
|
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper;
|
|
|
|
|
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTarifa;
|
|
|
|
|
import com.trg.search.Filter;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
@ -68,6 +69,10 @@ public class BusquedaTarifaController extends MyGenericForwardComposer {
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
private static final long serialVersionUID = 152133603059627025L;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private transient PagedListWrapper<Tarifa> plwTarifa;
|
|
|
|
|
private Paging pagingTarifa;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TarifaService tarifaService;
|
|
|
|
@ -75,7 +80,6 @@ public class BusquedaTarifaController extends MyGenericForwardComposer {
|
|
|
|
|
@Autowired
|
|
|
|
|
private UsuarioService usuarioService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MarcaService marcaService;
|
|
|
|
|
@Autowired
|
|
|
|
@ -130,6 +134,347 @@ public class BusquedaTarifaController extends MyGenericForwardComposer {
|
|
|
|
|
|
|
|
|
|
private static final Logger log = Logger.getLogger(BusquedaTarifaController.class);
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doAfterCompose(Component comp) throws Exception {
|
|
|
|
|
super.doAfterCompose(comp);
|
|
|
|
|
listheaderTPP.setVisible(ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.EXIBE_TPP.getDescricao()));
|
|
|
|
|
this.cmbMarca.addEventListener("onChange", new EventListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
Marca marca = getIfSelected(cmbMarca);
|
|
|
|
|
|
|
|
|
|
lsRuta = new ArrayList<Ruta>();
|
|
|
|
|
lsRuta.add(null);
|
|
|
|
|
if (marca != null) {
|
|
|
|
|
lsRuta.addAll(rutaService.obtenerPorEmpresa(marca.getEmpresa()));
|
|
|
|
|
} else {
|
|
|
|
|
lsRuta.addAll(rutaService.obtenerTodos());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshLista(true);
|
|
|
|
|
cmbRuta.setModel(new BindingListModelList(lsRuta, true));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tarifaList.setItemRenderer(new RenderTarifa());
|
|
|
|
|
tarifaList.addEventListener("onDoubleClick", new EventListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
Tarifa t = (Tarifa) tarifaList.getSelected();
|
|
|
|
|
verTarifa(t);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
lsMarcas = marcaService.buscarMarcaPorEmpresa(UsuarioLogado.getUsuarioLogado().getEmpresa());
|
|
|
|
|
|
|
|
|
|
lsClaseServico = new ArrayList<ClaseServicio>();
|
|
|
|
|
lsClaseServico.add(null);
|
|
|
|
|
lsClaseServico.addAll(claseServicioService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsMonedas = new ArrayList<Moneda>();
|
|
|
|
|
lsMonedas.add(null);
|
|
|
|
|
lsMonedas.addAll(monedaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsVigencias = new ArrayList<VigenciaTarifa>();
|
|
|
|
|
lsVigencias.add(null);
|
|
|
|
|
lsVigencias.addAll(vigenciaTarifaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsCategoria = new ArrayList<Categoria>();
|
|
|
|
|
lsCategoria.add(null);
|
|
|
|
|
lsCategoria.addAll(categoriaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsTipoPontoVenta = new ArrayList<TipoPuntoVenta>();
|
|
|
|
|
lsTipoPontoVenta.add(null);
|
|
|
|
|
lsTipoPontoVenta.addAll(tipoPuntoVentaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsVia = new ArrayList<Via>();
|
|
|
|
|
lsVia.add(null);
|
|
|
|
|
lsVia.addAll(viaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsVende = new ArrayList<String>();
|
|
|
|
|
lsVende.add(null);
|
|
|
|
|
lsVende.add("Sim");
|
|
|
|
|
lsVende.add("Não");
|
|
|
|
|
|
|
|
|
|
if (!temPermissao(ConstantesFuncionSistema.CLAVE_TARIFAS_DESABILITAR_BOTAO_EXCLUIR_TODOS)) {
|
|
|
|
|
btnExcluirTodos.setDisabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshLista(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void verTarifa(Tarifa t) {
|
|
|
|
|
if (t == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
|
|
|
|
args.put("tarifa", t);
|
|
|
|
|
args.put("tarifaList", tarifaList);
|
|
|
|
|
|
|
|
|
|
openWindow("/gui/tarifas/editarTarifas.zul",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"), args, MODAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onClick$btnExcluirTodos(Event ev) throws InterruptedException {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
if (moneda == null && marca == null && claseServicio == null && vigenciaTarifa == null && categoria == null
|
|
|
|
|
&& tipoPuntoVenta == null && origem == null && destino == null && ruta == null && via == null) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(
|
|
|
|
|
Labels.getLabel("editarTarifaController.btnFechar.MSG.pesquisaobrigatoria"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.INFORMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int opcao = Messagebox.show(
|
|
|
|
|
Labels.getLabel("editarTarifaController.btnFechar.MSG.Deseja.BorrarEmLote"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.YES | Messagebox.NO, Messagebox.QUESTION);
|
|
|
|
|
|
|
|
|
|
if (opcao == Messagebox.YES) {
|
|
|
|
|
tarifaService.excluirTodasTarifas(moneda, marca, claseServicio, vigenciaTarifa, origem, destino, categoria, tipoPuntoVenta, ruta, via, vende);
|
|
|
|
|
|
|
|
|
|
Messagebox.show(
|
|
|
|
|
Labels.getLabel("editarTarifaController.btnFechar.MSG.borrarEmLoteOK"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.INFORMATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error(ex);
|
|
|
|
|
}
|
|
|
|
|
refreshLista(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onClick$btnRefresh(Event ev) throws InterruptedException {
|
|
|
|
|
refreshLista(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onClick$btnNovo(Event ev) {
|
|
|
|
|
verTarifa(new Tarifa());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private <T> T getIfSelected(Combobox cb) {
|
|
|
|
|
return (T) (cb.getSelectedItem() != null ? cb.getSelectedItem().getValue() : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Button getBtnExcluirTodos() {
|
|
|
|
|
return btnExcluirTodos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBtnExcluirTodos(Button btnExcluirTodos) {
|
|
|
|
|
this.btnExcluirTodos = btnExcluirTodos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void refreshLista(Boolean exibirMsgNenhumRegistro) throws InterruptedException {
|
|
|
|
|
moneda = getIfSelected(cmbMoneda);
|
|
|
|
|
marca = getIfSelected(cmbMarca);
|
|
|
|
|
claseServicio = getIfSelected(cmbClaseServicio);
|
|
|
|
|
vigenciaTarifa = getIfSelected(cmbVigenciaTarifa);
|
|
|
|
|
categoria = getIfSelected(cmbCategoria);
|
|
|
|
|
tipoPuntoVenta = getIfSelected(cmbTipoPontoVenta);
|
|
|
|
|
origem = getIfSelected(cmbOrigem);
|
|
|
|
|
destino = getIfSelected(cmbDestino);
|
|
|
|
|
ruta = getIfSelected(cmbRuta);
|
|
|
|
|
via = getIfSelected(cmbVia);
|
|
|
|
|
vende = getIfSelected(cmbVende) != null ? returnStatusVende((String) getIfSelected(cmbVende)) : null;
|
|
|
|
|
|
|
|
|
|
boolean origemEmpty = ((origem == null) && (!cmbOrigem.getText().isEmpty()));
|
|
|
|
|
boolean destinoEmpty = ((destino == null) && (!cmbDestino.getText().isEmpty()));
|
|
|
|
|
|
|
|
|
|
if ((moneda == null) && (!cmbMoneda.getText().isEmpty())) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Moneda.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((marca == null) && (!cmbMarca.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Marca.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((claseServicio == null) && (!cmbClaseServicio.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Clase servicio.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((vigenciaTarifa == null) && (!cmbVigenciaTarifa.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Vigencia Tarifa.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (origemEmpty) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Origen.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (destinoEmpty) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Destino.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((tipoPuntoVenta == null) && (!cmbTipoPontoVenta.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Tipo Punto de Venta.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((categoria == null) && (!cmbCategoria.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Tipo de Pasajero.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((ruta == null) && (!cmbRuta.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Ruta.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((via == null) && (!cmbVia.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Via.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((origem == null && destino == null) && (vende != null)) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("modificacionMasivaTarifasController.MSG.informarOrigemOuDestino"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HibernateSearchObject<Tarifa> tarifaBusqueda = new HibernateSearchObject<Tarifa>(Tarifa.class, pagingTarifa.getPageSize());
|
|
|
|
|
|
|
|
|
|
tarifaBusqueda.addFilterEqual("activo", Boolean.TRUE);
|
|
|
|
|
|
|
|
|
|
tarifaBusqueda.addFilterEqual("moneda", moneda);
|
|
|
|
|
if (marca != null) {
|
|
|
|
|
tarifaBusqueda.addFilterEqual("marca", marca);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
tarifaBusqueda.addFilterIn("marca", lsMarcas);
|
|
|
|
|
}
|
|
|
|
|
tarifaBusqueda.addFilterEqual("claseServicio", claseServicio);
|
|
|
|
|
tarifaBusqueda.addFilterEqual("vigenciaTarifa", vigenciaTarifa);
|
|
|
|
|
tarifaBusqueda.addFilterEqual("tramo.origem", origem);
|
|
|
|
|
tarifaBusqueda.addFilterEqual("tramo.destino", destino);
|
|
|
|
|
|
|
|
|
|
if (categoria != null) {
|
|
|
|
|
tarifaBusqueda.addFilterSome("lsTarifaCategoria",
|
|
|
|
|
Filter.equal("categoria.categoriaId", categoria.getCategoriaId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tipoPuntoVenta != null) {
|
|
|
|
|
tarifaBusqueda.addFilterSome("lsTarifaTipoptovta",
|
|
|
|
|
Filter.equal("tipoPuntoVenta.tipoptovtaId",
|
|
|
|
|
tipoPuntoVenta.getTipoptovtaId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ruta != null) {
|
|
|
|
|
tarifaBusqueda.addFilterEqual("ruta", ruta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (via != null) {
|
|
|
|
|
tarifaBusqueda.addFilterEqual("tramo.via", via);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vende != null) {
|
|
|
|
|
tarifaBusqueda.setDistinct(true);
|
|
|
|
|
tarifaBusqueda.addFetch("tramo");
|
|
|
|
|
tarifaBusqueda.addFilterEqual("ruta.rutaCombinacionList.indventa", vende);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
plwTarifa.init(tarifaBusqueda, tarifaList, pagingTarifa);
|
|
|
|
|
|
|
|
|
|
if (tarifaList.getData().length == 0 && exibirMsgNenhumRegistro) {
|
|
|
|
|
try {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.INFORMATION);
|
|
|
|
|
} catch (InterruptedException ex) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HabilitarBotaoExcluirTodos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HabilitarBotaoExcluirTodos() {
|
|
|
|
|
if (moneda != null || marca != null || claseServicio != null || vigenciaTarifa != null || categoria != null
|
|
|
|
|
|| tipoPuntoVenta != null || origem != null || destino != null || ruta != null || via != null) {
|
|
|
|
|
Boolean selecionouAoMenosUmCampoPesquisa = true;
|
|
|
|
|
if (selecionouAoMenosUmCampoPesquisa && tarifaList.getSize() > 0 && temPermissao(ConstantesFuncionSistema.CLAVE_TARIFAS_DESABILITAR_BOTAO_EXCLUIR_TODOS)) {
|
|
|
|
|
btnExcluirTodos.setDisabled(false);
|
|
|
|
|
} else {
|
|
|
|
|
btnExcluirTodos.setDisabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Boolean returnStatusVende(String stringVende) {
|
|
|
|
|
if (stringVende.equalsIgnoreCase("sim")) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onClick$btnPesquisa(Event ev) throws InterruptedException {
|
|
|
|
|
refreshLista(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean temPermissao(String permissao) {
|
|
|
|
|
return UsuarioLogado.getUsuarioLogado().isPermisoClave(permissao);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Combobox getCmbVende() {
|
|
|
|
|
return cmbVende;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCmbVende(Combobox cmbVende) {
|
|
|
|
|
this.cmbVende = cmbVende;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getLsVende() {
|
|
|
|
|
return lsVende;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLsVende(List<String> lsVende) {
|
|
|
|
|
this.lsVende = lsVende;
|
|
|
|
|
}
|
|
|
|
|
public List<VigenciaTarifa> getLsVigencias() {
|
|
|
|
|
return lsVigencias;
|
|
|
|
|
}
|
|
|
|
@ -274,293 +619,4 @@ public class BusquedaTarifaController extends MyGenericForwardComposer {
|
|
|
|
|
this.cmbTipoPontoVenta = cmbTipoPontoVenta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onClick$btnPesquisa(Event ev) throws InterruptedException {
|
|
|
|
|
refreshLista(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean temPermissao(String permissao) {
|
|
|
|
|
return UsuarioLogado.getUsuarioLogado().isPermisoClave(permissao);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onClick$btnExcluirTodos(Event ev) throws InterruptedException {
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
if (moneda == null && marca == null && claseServicio == null && vigenciaTarifa == null && categoria == null
|
|
|
|
|
&& tipoPuntoVenta == null && origem == null && destino == null && ruta == null && via == null) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(
|
|
|
|
|
Labels.getLabel("editarTarifaController.btnFechar.MSG.pesquisaobrigatoria"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.INFORMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int opcao = Messagebox.show(
|
|
|
|
|
Labels.getLabel("editarTarifaController.btnFechar.MSG.Deseja.BorrarEmLote"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.YES | Messagebox.NO, Messagebox.QUESTION);
|
|
|
|
|
|
|
|
|
|
if (opcao == Messagebox.YES) {
|
|
|
|
|
tarifaService.excluirTodasTarifas(moneda, marca, claseServicio, vigenciaTarifa, origem, destino, categoria, tipoPuntoVenta, ruta, via);
|
|
|
|
|
|
|
|
|
|
Messagebox.show(
|
|
|
|
|
Labels.getLabel("editarTarifaController.btnFechar.MSG.borrarEmLoteOK"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.INFORMATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error(ex);
|
|
|
|
|
}
|
|
|
|
|
refreshLista(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onClick$btnRefresh(Event ev) throws InterruptedException {
|
|
|
|
|
refreshLista(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onClick$btnNovo(Event ev) {
|
|
|
|
|
verTarifa(new Tarifa());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doAfterCompose(Component comp) throws Exception {
|
|
|
|
|
super.doAfterCompose(comp);
|
|
|
|
|
listheaderTPP.setVisible(ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.EXIBE_TPP.getDescricao()));
|
|
|
|
|
this.cmbMarca.addEventListener("onChange", new EventListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
Marca marca = getIfSelected(cmbMarca);
|
|
|
|
|
|
|
|
|
|
lsRuta = new ArrayList<Ruta>();
|
|
|
|
|
lsRuta.add(null);
|
|
|
|
|
if (marca != null) {
|
|
|
|
|
lsRuta.addAll(rutaService.obtenerPorEmpresa(marca.getEmpresa()));
|
|
|
|
|
} else {
|
|
|
|
|
lsRuta.addAll(rutaService.obtenerTodos());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshLista(true);
|
|
|
|
|
cmbRuta.setModel(new BindingListModelList(lsRuta, true));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tarifaList.setItemRenderer(new RenderTarifa());
|
|
|
|
|
tarifaList.addEventListener("onDoubleClick", new EventListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(Event event) throws Exception {
|
|
|
|
|
Tarifa t = (Tarifa) tarifaList.getSelected();
|
|
|
|
|
verTarifa(t);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
lsMarcas = marcaService.buscarMarcaPorEmpresa(UsuarioLogado.getUsuarioLogado().getEmpresa());
|
|
|
|
|
|
|
|
|
|
lsClaseServico = new ArrayList<ClaseServicio>();
|
|
|
|
|
lsClaseServico.add(null);
|
|
|
|
|
lsClaseServico.addAll(claseServicioService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsMonedas = new ArrayList<Moneda>();
|
|
|
|
|
lsMonedas.add(null);
|
|
|
|
|
lsMonedas.addAll(monedaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsVigencias = new ArrayList<VigenciaTarifa>();
|
|
|
|
|
lsVigencias.add(null);
|
|
|
|
|
lsVigencias.addAll(vigenciaTarifaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsCategoria = new ArrayList<Categoria>();
|
|
|
|
|
lsCategoria.add(null);
|
|
|
|
|
lsCategoria.addAll(categoriaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsTipoPontoVenta = new ArrayList<TipoPuntoVenta>();
|
|
|
|
|
lsTipoPontoVenta.add(null);
|
|
|
|
|
lsTipoPontoVenta.addAll(tipoPuntoVentaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsVia = new ArrayList<Via>();
|
|
|
|
|
lsVia.add(null);
|
|
|
|
|
lsVia.addAll(viaService.obtenerTodos());
|
|
|
|
|
|
|
|
|
|
lsVende = new ArrayList<String>();
|
|
|
|
|
lsVende.add(null);
|
|
|
|
|
lsVende.add("Sim");
|
|
|
|
|
lsVende.add("Não");
|
|
|
|
|
|
|
|
|
|
if (!temPermissao(ConstantesFuncionSistema.CLAVE_TARIFAS_DESABILITAR_BOTAO_EXCLUIR_TODOS)) {
|
|
|
|
|
btnExcluirTodos.setDisabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
refreshLista(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void verTarifa(Tarifa t) {
|
|
|
|
|
if (t == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> args = new HashMap<String, Object>();
|
|
|
|
|
args.put("tarifa", t);
|
|
|
|
|
args.put("tarifaList", tarifaList);
|
|
|
|
|
|
|
|
|
|
openWindow("/gui/tarifas/editarTarifas.zul",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"), args, MODAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
private <T> T getIfSelected(Combobox cb) {
|
|
|
|
|
return (T) (cb.getSelectedItem() != null ? cb.getSelectedItem().getValue() : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Button getBtnExcluirTodos() {
|
|
|
|
|
return btnExcluirTodos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBtnExcluirTodos(Button btnExcluirTodos) {
|
|
|
|
|
this.btnExcluirTodos = btnExcluirTodos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void refreshLista(Boolean exibirMsgNenhumRegistro) throws InterruptedException {
|
|
|
|
|
moneda = getIfSelected(cmbMoneda);
|
|
|
|
|
marca = getIfSelected(cmbMarca);
|
|
|
|
|
claseServicio = getIfSelected(cmbClaseServicio);
|
|
|
|
|
vigenciaTarifa = getIfSelected(cmbVigenciaTarifa);
|
|
|
|
|
categoria = getIfSelected(cmbCategoria);
|
|
|
|
|
tipoPuntoVenta = getIfSelected(cmbTipoPontoVenta);
|
|
|
|
|
origem = getIfSelected(cmbOrigem);
|
|
|
|
|
destino = getIfSelected(cmbDestino);
|
|
|
|
|
ruta = getIfSelected(cmbRuta);
|
|
|
|
|
via = getIfSelected(cmbVia);
|
|
|
|
|
vende = getIfSelected(cmbVende) != null ? returnStatusVende((String) getIfSelected(cmbVende)) : null;
|
|
|
|
|
|
|
|
|
|
if ((moneda == null) && (!cmbMoneda.getText().isEmpty())) {
|
|
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Moneda.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((marca == null) && (!cmbMarca.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Marca.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((claseServicio == null) && (!cmbClaseServicio.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Clase servicio.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((vigenciaTarifa == null) && (!cmbVigenciaTarifa.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Vigencia Tarifa.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((origem == null) && (!cmbOrigem.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Origen.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((destino == null) && (!cmbDestino.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Destino.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((tipoPuntoVenta == null) && (!cmbTipoPontoVenta.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Tipo Punto de Venta.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((categoria == null) && (!cmbCategoria.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Tipo de Pasajero.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((ruta == null) && (!cmbRuta.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Ruta.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((via == null) && (!cmbVia.getText().isEmpty())) {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.SELECCIONE.VALOR.CORRECTO") + " Via.",
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tarifaList.setData(tarifaService.obterTarifaOficialPorFiltro(moneda, marca, lsMarcas, origem, destino, claseServicio, vigenciaTarifa, categoria, tipoPuntoVenta, ruta, via, vende));
|
|
|
|
|
|
|
|
|
|
if (tarifaList.getData().length == 0 && exibirMsgNenhumRegistro) {
|
|
|
|
|
try {
|
|
|
|
|
Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),
|
|
|
|
|
Labels.getLabel("editarTarifaController.window.title"),
|
|
|
|
|
Messagebox.OK, Messagebox.INFORMATION);
|
|
|
|
|
} catch (InterruptedException ex) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HabilitarBotaoExcluirTodos();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HabilitarBotaoExcluirTodos() {
|
|
|
|
|
if (moneda != null || marca != null || claseServicio != null || vigenciaTarifa != null || categoria != null
|
|
|
|
|
|| tipoPuntoVenta != null || origem != null || destino != null || ruta != null || via != null) {
|
|
|
|
|
Boolean selecionouAoMenosUmCampoPesquisa = true;
|
|
|
|
|
if (selecionouAoMenosUmCampoPesquisa && tarifaList.getSize() > 0 && temPermissao(ConstantesFuncionSistema.CLAVE_TARIFAS_DESABILITAR_BOTAO_EXCLUIR_TODOS)) {
|
|
|
|
|
btnExcluirTodos.setDisabled(false);
|
|
|
|
|
} else {
|
|
|
|
|
btnExcluirTodos.setDisabled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Boolean returnStatusVende(String stringVende) {
|
|
|
|
|
if (stringVende.equalsIgnoreCase("sim")) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Combobox getCmbVende() {
|
|
|
|
|
return cmbVende;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCmbVende(Combobox cmbVende) {
|
|
|
|
|
this.cmbVende = cmbVende;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getLsVende() {
|
|
|
|
|
return lsVende;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setLsVende(List<String> lsVende) {
|
|
|
|
|
this.lsVende = lsVende;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|