fixes bug#0012560
dev: thiago qua: wallysson Implementação efetuada. O script solicitado encontra-se anexo ao mantis. git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@87173 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
fead1d2f0d
commit
cc7663ba52
|
@ -1,12 +1,9 @@
|
|||
package com.rjconsultores.ventaboletos.web.gui.controladores.pricing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.zkoss.util.resource.Labels;
|
||||
import org.zkoss.zhtml.Messagebox;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
|
@ -14,6 +11,8 @@ import org.zkoss.zul.Textbox;
|
|||
|
||||
import com.rjconsultores.ventaboletos.entidad.Pricing;
|
||||
import com.rjconsultores.ventaboletos.service.PricingService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MensagensUtils;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
||||
|
||||
|
@ -21,6 +20,8 @@ import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
|||
@Scope("prototype")
|
||||
public class CopiarPricingController extends MyGenericForwardComposer {
|
||||
|
||||
private static final String CONTROLLER_WINDOW_TITLE = "copiarPricingController.window.title";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Autowired
|
||||
|
@ -38,42 +39,30 @@ public class CopiarPricingController extends MyGenericForwardComposer {
|
|||
}
|
||||
|
||||
public void onClick$btnSalvarCopia(Event ev) throws InterruptedException {
|
||||
if (!nombrePricing.getText().equals("") && nombrePricing.getText() != null) {
|
||||
|
||||
List<Pricing> lsPricing =
|
||||
pricingService.buscarPorNombre(nombrePricing.getText());
|
||||
|
||||
if (lsPricing.isEmpty()) {
|
||||
|
||||
Boolean resp = pricingService.clonarPricing(pricing.getPricingId(), nombrePricing.getText());
|
||||
|
||||
if (resp) {
|
||||
|
||||
closeWindow();
|
||||
Messagebox.show(
|
||||
Labels.getLabel("copiarPricingController.MSG.suscribirOK"),
|
||||
Labels.getLabel("copiarPricingController.window.title"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
|
||||
} else {
|
||||
Messagebox.show(
|
||||
Labels.getLabel("copiarPricingController.MSG.ERRO"),
|
||||
Labels.getLabel("copiarPricingController.window.title"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
}
|
||||
|
||||
} else {
|
||||
Messagebox.show(
|
||||
Labels.getLabel("copiarPricingController.MSG.Registro.Existe"),
|
||||
Labels.getLabel("copiarPricingController.window.title"),
|
||||
Messagebox.OK, Messagebox.EXCLAMATION);
|
||||
}
|
||||
} else {
|
||||
Messagebox.show(
|
||||
Labels.getLabel("copiarPricingController.MSG.sem.nome"),
|
||||
Labels.getLabel("copiarPricingController.window.title"),
|
||||
Messagebox.OK, Messagebox.EXCLAMATION);
|
||||
if (StringUtils.isBlank(nombrePricing.getText())) {
|
||||
MensagensUtils.showMessageExclamation("copiarPricingController.MSG.sem.nome",CONTROLLER_WINDOW_TITLE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (existePricingComMesmoNome()) {
|
||||
MensagensUtils.showMessageExclamation("copiarPricingController.MSG.Registro.Existe", CONTROLLER_WINDOW_TITLE);
|
||||
return;
|
||||
}
|
||||
|
||||
Boolean clonou = pricingService.clonarPricing(pricing.getPricingId(), nombrePricing.getText(),
|
||||
ApplicationProperties.getInstance().usaPadraoPricingTipoPassagemPET());
|
||||
|
||||
if (clonou) {
|
||||
closeWindow();
|
||||
MensagensUtils.showMessageInformation("copiarPricingController.MSG.suscribirOK", CONTROLLER_WINDOW_TITLE);
|
||||
} else {
|
||||
MensagensUtils.showMessageInformation("copiarPricingController.MSG.ERRO", CONTROLLER_WINDOW_TITLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected boolean existePricingComMesmoNome() {
|
||||
return pricingService.buscarPorNombre(nombrePricing.getText()).size() > 0;
|
||||
}
|
||||
|
||||
public void onClose$winCopiarPricing(Event ev) {
|
||||
|
|
|
@ -100,7 +100,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPricingVigencia
|
|||
@Controller("editarPricingController")
|
||||
@Scope("prototype")
|
||||
@SuppressWarnings("unused")
|
||||
public class EditarPricingController extends MyGenericForwardComposer {
|
||||
public class EditarPricingController extends PricingController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static Logger log = Logger.getLogger(EditarPricingController.class);
|
||||
|
@ -266,7 +266,6 @@ public class EditarPricingController extends MyGenericForwardComposer {
|
|||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
lsEmpresa = UsuarioLogado.getUsuarioLogado().getEmpresa();
|
||||
// lsEmpresa.add(empresaService.obtenerID(-1));
|
||||
|
||||
pricing = (Pricing) Executions.getCurrent().getArg().get("pricing");
|
||||
pricingList = (MyListbox) Executions.getCurrent().getArg().get("pricingList");
|
||||
|
@ -663,29 +662,27 @@ public class EditarPricingController extends MyGenericForwardComposer {
|
|||
pricingMercadoService.suscribir(pme);
|
||||
}
|
||||
|
||||
// Empresa
|
||||
// Empresa emp = empresaService.obtenerID(-1);
|
||||
// if (emp != null) {
|
||||
// pricing.setEmpresa(emp);
|
||||
// cmbEmpresa.setText(emp.getNombempresa());
|
||||
// }
|
||||
}
|
||||
|
||||
// Tipo Pasajero - Categoria
|
||||
PricingCategoria pc = new PricingCategoria();
|
||||
Categoria categoria = null;
|
||||
|
||||
if (ApplicationProperties.getInstance().habilitarPricingCategoria()) {
|
||||
pricingCategoriaList.setDisabled(Boolean.FALSE);
|
||||
btnNovoCategoria.setDisabled(Boolean.FALSE);
|
||||
btnApagarCategoria.setDisabled(Boolean.FALSE);
|
||||
btnModificarCategoria.setDisabled(Boolean.FALSE);
|
||||
|
||||
}else{
|
||||
categoria = categoriaService.obtenerID(1);
|
||||
// Tipo Pasajero - Categoria
|
||||
if (ApplicationProperties.getInstance().habilitarPricingCategoria()) {
|
||||
pricingCategoriaList.setDisabled(Boolean.FALSE);
|
||||
btnNovoCategoria.setDisabled(Boolean.FALSE);
|
||||
btnApagarCategoria.setDisabled(Boolean.FALSE);
|
||||
btnModificarCategoria.setDisabled(Boolean.FALSE);
|
||||
} else {
|
||||
incluirCategoria(categoriaService.obtenerID(1));
|
||||
}
|
||||
|
||||
incluirCategoriasPadroes();
|
||||
|
||||
btnApagar.setVisible(Boolean.FALSE);
|
||||
btnInativar.setVisible(Boolean.FALSE);
|
||||
btnAtivar.setVisible(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
private void incluirCategoria(Categoria categoria) {
|
||||
if (categoria != null && verificarCategoriaNaoAdicionada(categoria)) {
|
||||
PricingCategoria pc = new PricingCategoria();
|
||||
pc.setCategoria(categoria);
|
||||
pc.setPricing(pricing);
|
||||
pc.setActivo(Pricing.ATIVO);
|
||||
|
@ -699,12 +696,6 @@ public class EditarPricingController extends MyGenericForwardComposer {
|
|||
pricingCategoriaList.setData(lsPricingCategoria);
|
||||
pricingCategoriaService.suscribir(pc);
|
||||
}
|
||||
|
||||
if (pricing.getPricingId() == null) {
|
||||
btnApagar.setVisible(Boolean.FALSE);
|
||||
btnInativar.setVisible(Boolean.FALSE);
|
||||
btnAtivar.setVisible(Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/** Valida se a categoria não foi adicionada */
|
||||
|
@ -720,6 +711,16 @@ public class EditarPricingController extends MyGenericForwardComposer {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void incluirCategoriaNormal(Categoria categoriaNormal) {
|
||||
incluirCategoria(categoriaNormal);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void incluirCategoriaPet(Categoria categoriaPET) {
|
||||
incluirCategoria(categoriaPET);
|
||||
}
|
||||
|
||||
public void onClick$radioImp(Event ev) {
|
||||
btnNovoImporte.setVisible(true);
|
||||
btnApagarImporte.setVisible(true);
|
||||
|
|
|
@ -43,7 +43,6 @@ import com.rjconsultores.ventaboletos.entidad.PricingEspecificoCategoria;
|
|||
import com.rjconsultores.ventaboletos.entidad.PricingEspecificoOcupacion;
|
||||
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TipoPuntoVenta;
|
||||
import com.rjconsultores.ventaboletos.service.CategoriaService;
|
||||
import com.rjconsultores.ventaboletos.service.ClaseServicioService;
|
||||
import com.rjconsultores.ventaboletos.service.CorridaCtrlService;
|
||||
import com.rjconsultores.ventaboletos.service.MarcaService;
|
||||
|
@ -73,7 +72,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPricingEspecifi
|
|||
@Controller("editarPricingEspecificoController")
|
||||
@Scope("prototype")
|
||||
@SuppressWarnings({ "unchecked", "rawtypes", "unused" })
|
||||
public class EditarPricingEspecificoController extends MyGenericForwardComposer {
|
||||
public class EditarPricingEspecificoController extends PricingController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static Logger log = Logger.getLogger(EditarPricingController.class);
|
||||
|
@ -83,8 +82,6 @@ public class EditarPricingEspecificoController extends MyGenericForwardComposer
|
|||
@Autowired
|
||||
private TipoPuntoVentaService puntoVentaService;
|
||||
@Autowired
|
||||
private CategoriaService categoriaService;
|
||||
@Autowired
|
||||
private ClaseServicioService claseServicioService;
|
||||
@Autowired
|
||||
private MarcaService marcaService;
|
||||
|
@ -141,7 +138,7 @@ public class EditarPricingEspecificoController extends MyGenericForwardComposer
|
|||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
lsCategoria = categoriaService.obtenerTodos();
|
||||
lsCategoria = getCategoriaService().obtenerTodos();
|
||||
lsMarca = marcaService.buscarMarcaPorEmpresa(UsuarioLogado.getUsuarioLogado().getEmpresa());
|
||||
lsMoneda = monedaService.obtenerTodos();
|
||||
lsPtovata = puntoVentaService.obtenerTodos();
|
||||
|
@ -161,7 +158,7 @@ public class EditarPricingEspecificoController extends MyGenericForwardComposer
|
|||
|
||||
if (pricingEspecifico.getPricingespecificoId() == null) {
|
||||
btnApagar.setVisible(Boolean.FALSE);
|
||||
setTipoPassagemPadrao();
|
||||
incluirCategoriasPadroes();
|
||||
} else {
|
||||
Parada origem = pricingEspecifico.getParada();
|
||||
if (origem != null) {
|
||||
|
@ -194,33 +191,6 @@ public class EditarPricingEspecificoController extends MyGenericForwardComposer
|
|||
fechaInicio.focus();
|
||||
}
|
||||
|
||||
private void setTipoPassagemPadrao() {
|
||||
if (ApplicationProperties.getInstance().usaPadroPricingEspecificoTipoPassagemPET()) {
|
||||
Categoria categoriaNormal = buscarCategoria("NORMAL");
|
||||
Categoria categoriaPET = buscarCategoria("PET");
|
||||
|
||||
if (categoriaNormal != null) {
|
||||
PricingEspecificoCategoria pcNormal = new PricingEspecificoCategoria(categoriaNormal, pricingEspecifico, UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
pricingListEspCategoria.addItemNovo(pcNormal);
|
||||
pricingEspecifico.getPricingEspecificoCategoriaList().add(pcNormal);
|
||||
}
|
||||
|
||||
if (categoriaPET != null) {
|
||||
PricingEspecificoCategoria pcPET = new PricingEspecificoCategoria(categoriaPET, pricingEspecifico, UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
pricingListEspCategoria.addItemNovo(pcPET);
|
||||
pricingEspecifico.getPricingEspecificoCategoriaList().add(pcPET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Categoria buscarCategoria(String categoria) {
|
||||
List<Categoria> categoriaList = categoriaService.buscar(categoria);
|
||||
if(categoriaList.isEmpty()){
|
||||
return null;
|
||||
}
|
||||
return categoriaList.get(0);
|
||||
}
|
||||
|
||||
public void verPricingEspecificoOcupacion(PricingEspecificoOcupacion especificoOcupacion, Boolean isEdicao) {
|
||||
|
||||
Map args = new HashMap();
|
||||
|
@ -1082,21 +1052,6 @@ public class EditarPricingEspecificoController extends MyGenericForwardComposer
|
|||
this.puntoVentaService = puntoVentaService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the categoriaService
|
||||
*/
|
||||
public CategoriaService getCategoriaService() {
|
||||
return categoriaService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param categoriaService
|
||||
* the categoriaService to set
|
||||
*/
|
||||
public void setCategoriaService(CategoriaService categoriaService) {
|
||||
this.categoriaService = categoriaService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the claseServicioService
|
||||
*/
|
||||
|
@ -1199,4 +1154,18 @@ public class EditarPricingEspecificoController extends MyGenericForwardComposer
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void incluirCategoriaNormal(Categoria categoriaNormal) {
|
||||
PricingEspecificoCategoria pcNormal = new PricingEspecificoCategoria(categoriaNormal, pricingEspecifico, UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
pricingListEspCategoria.addItemNovo(pcNormal);
|
||||
pricingEspecifico.getPricingEspecificoCategoriaList().add(pcNormal);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void incluirCategoriaPet(Categoria categoriaPET) {
|
||||
PricingEspecificoCategoria pcPET = new PricingEspecificoCategoria(categoriaPET, pricingEspecifico, UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
pricingListEspCategoria.addItemNovo(pcPET);
|
||||
pricingEspecifico.getPricingEspecificoCategoriaList().add(pcPET);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.rjconsultores.ventaboletos.web.gui.controladores.pricing;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Categoria;
|
||||
import com.rjconsultores.ventaboletos.service.CategoriaService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||
|
||||
@Controller("pricingController")
|
||||
@Scope("prototype")
|
||||
public abstract class PricingController extends MyGenericForwardComposer {
|
||||
|
||||
private static final long serialVersionUID = -63691911293429900L;
|
||||
|
||||
@Autowired
|
||||
private CategoriaService categoriaService;
|
||||
|
||||
protected void incluirCategoriasPadroes() {
|
||||
if (ApplicationProperties.getInstance().usaPadraoPricingTipoPassagemPET()) {
|
||||
Categoria categoriaNormal = getCategoriaNormal();
|
||||
Categoria categoriaPET = getCategoriaPET();
|
||||
|
||||
if (categoriaNormal != null) {
|
||||
incluirCategoriaNormal(categoriaNormal);
|
||||
}
|
||||
|
||||
if (categoriaPET != null) {
|
||||
incluirCategoriaPet(categoriaPET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Categoria getCategoriaPET() {
|
||||
return getCategoriaService().buscarUmaCategoria("PET");
|
||||
}
|
||||
|
||||
protected Categoria getCategoriaNormal() {
|
||||
return getCategoriaService().buscarUmaCategoria("NORMAL");
|
||||
}
|
||||
|
||||
protected abstract void incluirCategoriaNormal(Categoria categoriaNormal);
|
||||
protected abstract void incluirCategoriaPet(Categoria categoriaPET);
|
||||
|
||||
public CategoriaService getCategoriaService() {
|
||||
return categoriaService;
|
||||
}
|
||||
|
||||
}
|
|
@ -9,11 +9,23 @@ public class MensagensUtils {
|
|||
}
|
||||
|
||||
public static void showMessageInformation(String labelMensagem, String tituloMenssagem) {
|
||||
showMessage(labelMensagem, tituloMenssagem, Messagebox.INFORMATION);
|
||||
}
|
||||
|
||||
public static void showMessageExclamation(String labelMensagem, String tituloMenssagem) {
|
||||
showMessage(labelMensagem, tituloMenssagem, Messagebox.EXCLAMATION);
|
||||
}
|
||||
|
||||
public static void showMessageError(String labelMensagem, String tituloMenssagem) {
|
||||
showMessage(labelMensagem, tituloMenssagem, Messagebox.ERROR);
|
||||
}
|
||||
|
||||
private static void showMessage(String labelMensagem, String tituloMenssagem, String tipoMenssagem) {
|
||||
try {
|
||||
Messagebox.show(
|
||||
Labels.getLabel(labelMensagem),
|
||||
Labels.getLabel(tituloMenssagem),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
Messagebox.OK, tipoMenssagem);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue