Package sn.unitech.stock.bean

Source Code of sn.unitech.stock.bean.EventsBean$AllRefs

package sn.unitech.stock.bean;


import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;


import sn.unitech.common.dao.ReadProperties;
import sn.unitech.stock.entity.Client;
import sn.unitech.stock.entity.Commande;
import sn.unitech.stock.entity.DetailCommandId;
import sn.unitech.stock.entity.DetailEvent;
import sn.unitech.stock.entity.DetailEventId;
import sn.unitech.stock.entity.Ecritures;
import sn.unitech.stock.entity.Events;
import sn.unitech.stock.entity.Fournisseur;
import sn.unitech.stock.entity.IUniversel;
import sn.unitech.stock.entity.Stock;
import sn.unitech.stock.entity.SysAdherEvent;
import sn.unitech.stock.entity.SysAdherEventId;
import sn.unitech.stock.entity.SysEvents;
import sn.unitech.stock.entity.SysRangmnt;
import sn.unitech.stock.entity.SysTypcli;
import sn.unitech.stock.entity.Taxes;
import sn.unitech.stock.metier.EventsM;
import sn.unitech.stock.metier.iface.IEventsM;
import sn.unitech.stock.modal.Resultat;
@ManagedBean
@ViewScoped
public class EventsBean implements Serializable{

  private IEventsM<Events> eventsM= new EventsM<Events>();
  private  Events events=new Events();
  private ReadProperties readProperties=ReadProperties.getReadProperties();
    private SysAdherEvent sysAdherEvent=new SysAdherEvent();
    private SysTypcli sysTypcli=new SysTypcli();
    private SysEvents sysEvents=new SysEvents();
    private SysAdherEvent sysAdherEventConsultation=new SysAdherEvent();
    private SysEvents sysEventsConsulation=new SysEvents();
    private Client client=new Client();
    private Fournisseur fournisseur=new Fournisseur();
    private SysRangmnt sysRangmnt=new SysRangmnt();
  private AllRefs allRefs =new AllRefs();
  private CMessages cmessages =new CMessages();
  private CItems citems=new CItems();
  private Cproperties cproperties=citems;
  public Events getEvents() {
    return events;
  }

  ParamsUser getParamsUser(){ //alias
    return ((ParamsUser)ToolsBean.getToolsBean().getAttribute(ToolsBean.idParamUser));
  }
 
  public List<IUniversel> getModelProduitsStock(){
    return (List<IUniversel>)this.citems.getDataProduitsStock().getWrappedData();
  }
 
  public void findListEvents(ActionEvent e){
    this.citems.dataListEvents=null;
  }
 
  public void findEtiquette(ActionEvent e){
    if((this.cproperties.etiquette!=null)&&(!this.cproperties.etiquette.isEmpty())){
      List<IUniversel> lp=  (List<IUniversel>) this.getModelProduitsStock();
       int index;
       if((index=this.eventsM.getIndex(lp, this.cproperties.etiquette))!=-1){
         IUniversel iUniversel=lp.get(index);
         iUniversel.setSelected(true);
         lp.remove(index);
         lp.add(0, iUniversel);
       }
    }
   
  }
 
  public List<IUniversel> getModelProduitsEvents(){
    return (List<IUniversel>)this.citems.getDataProduitsEvents().getWrappedData();
  }
 
    public Map defaultParametter(){
    Map param=new HashMap<Integer,Object>();
  param.put(0,getParamsUser().adherent.getIdAdherent());
  return param;
    }
 
 
  public void changeOperation(ValueChangeEvent event){
    this.cproperties.setIdOperation(event.getNewValue().toString());
    this.citems.prepareView(this.cproperties.getIdOperation());
    this.clickAnnuler(null);
  }

  public void changeTypeClient(ValueChangeEvent event){
    if(event.getNewValue()!=null){
    this.sysTypcli.setIdTypcli(Integer.parseInt(event.getNewValue().toString()));
    this.sysTypcli=eventsM.getCurrentTypeClient(this.sysTypcli.getIdTypcli());
    if((this.sysTypcli.getIsIntern().equals("False"))&&(this.sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_DETAILEVENT))){
      this.citems.isFromDetailEvent=true;
    }else this.citems.isFromDetailEvent=false;
    this.client.setAdresse("");
    this.client.setNumPiece("");
    this.client.setNom("");
    }this.sysTypcli.setIdTypcli(0);
  }
 
  public void changeClient(ValueChangeEvent event){
    if(event.getNewValue()!=null && sysTypcli.getIsIntern().equals("True")){
    this.client=this.eventsM.getCurrentClient(Integer.parseInt(event.getNewValue().toString()));
    }
  }

  public void changePiece(ValueChangeEvent event){
    this.cproperties.setIdPiece(event.getNewValue().toString());
  }

  public void changeFournisseur(ValueChangeEvent event){
    this.fournisseur.setIdFourn(Integer.parseInt(event.getNewValue().toString()));
        this.fournisseur=this.eventsM.getCurrentFournisseur(this.fournisseur.getIdFourn());
  }

  public void changeRangement(ValueChangeEvent event){
    this.cproperties.setIdRangement(event.getNewValue().toString());
  }
 
  public void changeCommande(ValueChangeEvent event){
    this.cproperties.setIdCommande(event.getNewValue().toString());
  }
 
  public void chargeProduitsFromDetailEvents(String codetiers,String tiers,boolean isNonEnregistre){
    Map param=new HashMap<Integer, Integer>();
    if(isNonEnregistre){     
    param.put(0, getParamsUser().getAdherent().getIdAdherent());
    param.put(1, this.sysEvents.getCodEvtCoupl());
    param.put(2, this.client.getNom());
    this.citems.dataProduitsStock.setWrappedData(this.eventsM.getProduitsFromDetailEvent(readProperties.read("Events.produitsDetailEvent"), param))
    }
    else {
    param.put(0, getParamsUser().getAdherent().getIdAdherent());
    param.put(1,codetiers);
    param.put(2,tiers);
    param.put(3, this.sysEvents.getCodEvtCoupl());
    this.citems.dataProduitsStock.setWrappedData(this.eventsM.getProduitsFromDetailEvent(readProperties.read("Events.produitsDetailEventClientInterne"), param));
  }
  }
  public void chargeProduitsFromDetailCommande(String idCommande){
    Map param=new HashMap<Integer, Integer>();
    param.put(0, Integer.parseInt(idCommande));
    this.citems.dataProduitsStock.setWrappedData(this.eventsM.getDetailCommande(readProperties.read("Events.detailCommande"), param))
  }
 
  public void changeConsultationOperation(ValueChangeEvent event){
    this.citems.dataListEvents=null;
    this.cproperties.setIdOperationConsultation(event.getNewValue().toString());
    sysAdherEventConsultation=eventsM.getSingleAdherEvent(new SysAdherEventId(getParamsUser().adherent.getIdAdherent(),this.cproperties.idOperationConsultation));
    sysEventsConsulation=eventsM.getCurrentOperation(this.cproperties.idOperationConsultation);
   
  }

 
  public void prepareProduitsFromStock(ActionEvent ev){
    Map param=new HashMap<Integer, Integer>();
    param.put(0, getParamsUser().getAdherent());
    try{
    param.put(1,Integer.parseInt(this.citems.idFamilleProd));
    List<IUniversel> list=this.eventsM.getProduitsFromStock(readProperties.read("Events.produitsFromStock"), param);
    list=eventsM.newListIUniversel(list, this.getModelProduitsEvents());
    this.citems.dataProduitsStock.setWrappedData(list);
    }catch(Exception e){
      Map paramAll=new HashMap<Integer, Integer>();
      paramAll.put(0, getParamsUser().getAdherent());
      paramAll.put(1, getParamsUser().getAdherent().getIdAdherent());
      List<IUniversel> list=this.eventsM.getProduitsFromStock(readProperties.read("Events.produitsAllFromStock"), paramAll);
      list=eventsM.newListIUniversel(list, this.getModelProduitsEvents());
      this.citems.dataProduitsStock.setWrappedData(list);
    }
  }

 
  public void addSelectedProduits(ActionEvent e){
    DataModel<IUniversel> dataModel=this.citems.getDataProduitsStock();
    IUniversel iuniversel;
    for(int i=0;i<dataModel.getRowCount();i++){
      dataModel.setRowIndex(i);
      iuniversel=dataModel.getRowData();
      if(iuniversel.isSelected()){
        this.completeEvent();
        if((this.sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_PRODUIT))||(this.sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_STOCK))){
          iuniversel.setQteContenant(1);
          iuniversel.setQteDetail(0);
        }else if(this.sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_DETAILCOMMANDE)){
          Map<Integer, Integer> param=new HashMap<Integer, Integer>();
          param.put(0, Integer.parseInt(this.cproperties.getIdRangement()));
          param.put(1, iuniversel.getSysProduit().getIdProduit());
          iuniversel.setIdStock(this.eventsM.findIdStock(readProperties.read("Events.findIdStock"), param));
          if(iuniversel.getIdStock()==-1){
            this.cmessages.setMessageErreur("Le produit n'est pas class� dans ce rangement.");
            break;
          }else this.cmessages.setMessageErreur("");
        }
        this.getModelProduitsEvents().add(iuniversel);
      }
    }
  }
 
 
 
  public void removeDetailEvent(ActionEvent e){
    IUniversel ui=this.citems.dataProduitsEvents.getRowData();
    getModelProduitsEvents().remove(ui);
    this.citems.dataProduitsEvents.setWrappedData(getModelProduitsEvents());
  }
 
  public void selectProduit(ValueChangeEvent e){
    IUniversel i= this.citems.dataProduitsStock.getRowData();
    this.getModelProduitsStock().remove(i);
    i.getSysProduit().setSelected((Boolean) e.getNewValue());
    this.getModelProduitsStock().add(i);
   
  }
 
  public void saveEvents(ActionEvent e){
    List<DetailEvent> listDetailEvent=getListDetailEvent(getModelProduitsEvents());
    ToolsBean.getToolsBean().setAttribute(this.cproperties.paramIdLot,null);
    if(this.citems.dataProduitsEvents.getRowCount()==0){
      this.cmessages.saveMessage="La liste est vide.";
    }
    else if(listDetailEvent.size()==this.citems.dataProduitsEvents.getRowCount()){
      Resultat result;
      result=this.eventsM.saveEvents(listDetailEvent, this.citems.listTaxesEtValues);
      this.cmessages.saveMessage=result.getMessage();
      if(result.isSucceed()){
        ToolsBean.getToolsBean().setAttribute(this.cproperties.paramIdLot,result.getId());
        this.events=new Events();
        this.getModelProduitsEvents().clear();
      }
    }
    else{
      this.citems.dataProduitsEvents.setRowIndex(listDetailEvent.size());
      String produit=this.citems.dataProduitsEvents.getRowData().getSysProduit().getDesignation();
      this.cmessages.saveMessage="Revoir les quantites saisies du produit "+produit;
    }
  }
 
  public void completeEvent(){
    this.events.setSysEvents(this.sysEvents);
    this.events.setSysUsers(getParamsUser().getSysUser());
    this.events.setSysDate(new Date());
    try {
      this.events.setSysTime(ToolsBean.getToolsBean().getSdfHeure().parse(""+ToolsBean.getToolsBean().getSdfHeure().format(new Date())));
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    if(this.cproperties.idCommande!=null && !this.cproperties.idCommande.isEmpty()){
      this.events.setCommande(new Commande(Integer.parseInt(this.cproperties.idCommande)));
    }
    if(this.cproperties.isUseRangmnt()){
      this.events.setCodRangement(Integer.parseInt(this.cproperties.idRangement));
    }else if(this.citems.dataProduitsEvents.getRowCount()>0){
      this.events.setCodRangement(this.getModelProduitsEvents().get(0).getSysRangmnt().getIdRangmnt());
    }
    this.events.setTiers(ToolsBean.TIERS_RANGEMENT);
    if(this.cproperties.isUseClient()){
      this.events.setCodTiers(this.sysTypcli.getIsIntern().equals("False")?"-1":this.client.getIdClient()+"");
      this.events.setTiers(ToolsBean.TIERS_CLIENT);
      this.events.setIntituleTiers(this.client.getNom());
      this.events.setAdresseTiers(this.client.getAdresse());
      this.events.setNumPiece(this.client.getNumPiece());
    }else if(this.cproperties.isUseFournisseur()){
      this.events.setCodTiers(this.fournisseur.getIdFourn()+"");
      this.events.setTiers(ToolsBean.TIERS_FOURNISSEUR);
      this.events.setIntituleTiers(this.fournisseur.getNom()+" "+this.fournisseur.getPrenom());
      this.events.setAdresseTiers(this.fournisseur.getAdresse());
      this.events.setCommande(new Commande(Integer.parseInt(this.cproperties.getIdCommande())));
    }
    this.events.setMntNet(this.citems.getMontantNet());
    this.events.setMntReglement(this.citems.getMontantRegle());
    this.events.setMntReliquat(this.citems.getMontantReliquat());
    this.events.setMntTot((this.citems.getMontantNet()+this.citems.getMontantRemise())-this.citems.getTaxeEtFrais());
    this.events.setTotTax(this.citems.getMontantTaxe());
    this.events.setTotRemise(this.citems.getMontantRemise());
    this.events.setTotFrais(this.citems.montantFrais);
  }
 
  public List<DetailEvent> getListDetailEvent(List<IUniversel> list){
    List<DetailEvent> listDetailEvent=new ArrayList<DetailEvent>();
    if(list.size()>0)this.completeEvent();
   
    for(int i=0;i<list.size();i++){
      if(sysEvents.getUseControleQuantite().equals("True"))
      if(!eventsM.isOkQuantite(list.get(i)))
        break
      DetailEvent detailEvent=new DetailEvent(new Stock(list.get(i).getIdStock()));
      detailEvent.setPrixTot(list.get(i).getPrixTot());
      detailEvent.setPrixUnitc(list.get(i).getPrixUnitc());
      detailEvent.getStock().setSysProduit(list.get(i).getSysProduit());
      detailEvent.setSysUnite(list.get(i).getSysProduit().getSysUniteByCodUnitc());
      if(this.sysAdherEvent.getSysAdherent().getUseDetail().equals("True")){
        detailEvent.setCodUnitd(list.get(i).getSysProduit().getSysUniteByCodUnitd().getIdUnite());
        detailEvent.setQteDetail(list.get(i).getQteDetail());
        detailEvent.setPrixUnitd(list.get(i).getPrixUnitd());
      }
      if(this.sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_DETAILCOMMANDE))
        detailEvent.setCodLotCouple(((DetailCommandId) list.get(i).getId()).getIdCommand());
      else if (this.sysEvents.getCodEvtCoupl()!=null)
        detailEvent.setCodLotCouple(((DetailEventId)list.get(i).getId()).getIdLot());
      detailEvent.setEvents(this.events);
      detailEvent.setQteContenant(list.get(i).getQteContenant());
      listDetailEvent.add(detailEvent);
      }
   
    return listDetailEvent;
  }
 
  public void clickListeProduits(ActionEvent e){
    if(ToolsBean.FROM_TABLE_DETAILEVENT.equals(this.sysEvents.getTablFrom())){
       if(this.cproperties.isUseClient())
        this.chargeProduitsFromDetailEvents(this.client.getIdClient()+"", ToolsBean.TIERS_CLIENT,this.sysTypcli.getIsIntern().equals("False"));
       else if(this.cproperties.isUseFournisseur())
      this.chargeProduitsFromDetailEvents(this.fournisseur.getIdFourn()+"", ToolsBean.TIERS_FOURNISSEUR,false)
    }
    else if(ToolsBean.FROM_TABLE_DETAILCOMMANDE.equals(this.sysEvents.getTablFrom()))
      this.chargeProduitsFromDetailCommande(this.cproperties.idCommande);
      else
          this.prepareProduitsFromStock(null);
      this.cproperties.modalPanel=ToolsBean.MODAL_PANEL;
     
  }
 
  public void clickSurTerminer(ActionEvent e){
  this.cproperties.setModalPanel("")
  }
 


  public SysEvents getSysEventsConsulation() {
    return sysEventsConsulation;
  }

  public void setSysEventsConsulation(SysEvents sysEventsConsulation) {
    this.sysEventsConsulation = sysEventsConsulation;
  }

  public void clickTaxesFrais(ActionEvent e){
    this.completeEvent();
    this.citems.montantRegle=0d;
    this.citems.setListTaxesEtValues(this.eventsM.getTaxesAndValues(this.getModelProduitsEvents(),this.events));
  }
 
  public void clickAnnuler(ActionEvent e){
    this.getModelProduitsEvents().clear();
    if(this.citems.listTaxesEtValues!=null)
    this.citems.listTaxesEtValues.clear();
    this.citems.setMontantFrais(0d);
    this.citems.setMontantNet(0d);
    this.citems.setMontantRegle(0d);
    this.citems.setMontantReliquat(0d);
    this.citems.setMontantRemise(0d);
    this.citems.setMontantTaxe(0d);
    this.cmessages.saveMessage="";
  }
 
  public void clickOngletConsultation(ActionEvent e){
    this.citems.dataListEvents=null;
    sysAdherEventConsultation=eventsM.getSingleAdherEvent(new SysAdherEventId(getParamsUser().adherent.getIdAdherent(),this.cproperties.idOperationConsultation));
    sysEventsConsulation=eventsM.getCurrentOperation(this.cproperties.idOperationConsultation);
  }

 
  public void detailEvents(){
    int currentIndex=this.citems.dataListEvents.getRowIndex();
    if((this.cproperties.getLastIndex()!=-1)&&(this.cproperties.getLastIndex()!= currentIndex)){
      this.citems.dataListEvents.setRowIndex(this.cproperties.getLastIndex());
      this.citems.dataListEvents.getRowData().setListDetailEvent(null);
      this.citems.dataListEvents.getRowData().setLabelDetail(ToolsBean.lblDetail);
    }
    this.citems.dataListEvents.setRowIndex(currentIndex);
    Events events=this.citems.dataListEvents.getRowData();
    if(events.getLabelDetail().equals(ToolsBean.lblFermer)){
      events.setListDetailEvent(null);
      events.setLabelDetail(ToolsBean.lblDetail);
    }   
    else{
      this.cproperties.idEvent=events.getIdLot();
      events.setListDetailEvent(this.citems.getListDetailEvent());
      if((events.getListDetailEvent()!=null)&&(events.getListDetailEvent().size()>0))
        events.setLabelDetail(ToolsBean.lblFermer);
    }
    this.cproperties.setLastIndex(currentIndex);
  }
 
  public void detailEcritures(){
    Events events=this.citems.dataListEvents.getRowData();
    this.cproperties.idNumop=events.getIdLot();
  }
 
  public AllRefs getAllRefs() {
    return allRefs;
  }
  public SysAdherEvent getSysAdherEvent() {
    return sysAdherEvent;
  }
  public void setSysAdherEvent(SysAdherEvent sysAdherEvent) {
    this.sysAdherEvent = sysAdherEvent;
  }
  public SysTypcli getSysTypcli() {
    return sysTypcli;
  }

  public void setSysTypcli(SysTypcli sysTypcli) {
    this.sysTypcli = sysTypcli;
  }

  public Client getClient() {
    return client;
  }

  public void setClient(Client client) {
    this.client = client;
  }

  public Fournisseur getFournisseur() {
    return fournisseur;
  }

  public void setFournisseur(Fournisseur fournisseur) {
    this.fournisseur = fournisseur;
  }

  public void setAllRefs(AllRefs allRefs) {
    this.allRefs = allRefs;
  }
  public CMessages getCmessages() {
    return cmessages;
  }
  public void setCmessages(CMessages cmessages) {
    this.cmessages = cmessages;
  }
  public CItems getCitems() {
    return citems;
  }
  public void setCitems(CItems citems) {
    this.citems = citems;
  }
  public Cproperties getCproperties() {
    return cproperties;
  }
  public void setCproperties(Cproperties cproperties) {
    this.cproperties = cproperties;
  }

  public SysEvents getSysEvents() {
    return sysEvents;
  }

  public void setSysEvents(SysEvents sysEvents) {
    this.sysEvents = sysEvents;
  }

  public SysAdherEvent getSysAdherEventConsultation() {
    return sysAdherEventConsultation;
  }

  public void setSysAdherEventConsultation(SysAdherEvent sysAdherEventConsultation) {
    this.sysAdherEventConsultation = sysAdherEventConsultation;
  }

  public class AllRefs implements Serializable{
   
  }
 
  public class CMessages implements Serializable{
    String messageErreur;
    String saveMessage;

    public String getSaveMessage() {
      return saveMessage;
    }

    public void setSaveMessage(String saveMessage) {
      this.saveMessage = saveMessage;
    }

    public String getMessageErreur() {
      return messageErreur;
    }

    public void setMessageErreur(String messageErreur) {
      this.messageErreur = messageErreur;
    }
  }
  public class Cproperties implements Serializable{
     String idOperation;
         boolean useClient;
         boolean useFournisseur;
         boolean useRangmnt;
         boolean showFamilleProduit;
         String idPiece;
         String idRangement;
         String idCommande;
         String modalPanel;
         boolean isFromDetailEvent;
         Double montantTaxe;
         Double montantFrais;
         Double montantRemise;
         Double montantReliquat;
         Double montantRegle=0d;
     Double montantNet;
         Double taxeEtFrais;
         String idFamilleProd;
         int lastIndex=-1;
         int idEvent;
         String idOperationConsultation;
         Double montantEspece=0d;
         Double monnaie=0d;
         public String etiquette;
         int idNumop;
         Date dateDebut;
         Date dateFin;
         String paramCodAdherent=getParamsUser().adherent.getIdAdherent();
         String paramCompte=getParamsUser().sysUser.getCompte().getIdCompte();
         String paramDateComptable;
         String paramCodUsers=getParamsUser().sysUser.getId().getIdUser();
         String paramIdLot="paramIdLot";

         SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/yyyy");

    public String getParamCodAdherent() {
      return paramCodAdherent;
    }

    public void setParamCodAdherent(String paramCodAdherent) {
      this.paramCodAdherent = paramCodAdherent;
    }

    public String getParamCompte() {
      return paramCompte;
    }

    public void setParamCompte(String paramCompte) {
      this.paramCompte = paramCompte;
    }


    public String getParamDateComptable() {
      return paramDateComptable;
    }

    public void setParamDateComptable(String paramDateComptable) {
      this.paramDateComptable = paramDateComptable;
    }

    public String getParamCodUsers() {
      return paramCodUsers;
    }

    public void setParamCodUsers(String paramCodUsers) {
      this.paramCodUsers = paramCodUsers;
    }

    public String getParamIdLot() {
      return paramIdLot;
    }

    public void setParamIdLot(String paramIdLot) {
      this.paramIdLot = paramIdLot;
    }

    public Cproperties(){
           this.setDateDebut(new Date());
           this.setDateFin(new Date());
           this.paramDateComptable=sdf.format(new Date());
           if(ToolsBean.getToolsBean().getAttribute(this.paramIdLot)!=null){
               this.paramIdLot=ToolsBean.getToolsBean().getAttribute(this.paramIdLot).toString();
           }

         }
        
    public String getModalPanel() {
      return modalPanel;
    }

    public void setModalPanel(String modalPanel) {
      this.modalPanel = modalPanel;
    }

    public boolean isUseFournisseur() {
      return ((sysEvents.getPanelSource()!=null)&&(sysEvents.getPanelSource().equals(ToolsBean.panelFournisseur))||
           (sysEvents.getPanelDestination()!=null)&&(sysEvents.getPanelDestination().equals(ToolsBean.panelFournisseur)));
    }

    public void setUseFournisseur(boolean useFournisseur) {
      this.useFournisseur = useFournisseur;
    }

    public String getIdOperation() {
      return idOperation;
    }

    public void setIdOperation(String idOperation) {
      this.idOperation = idOperation;
    }
     
    public boolean isUseClient() {
       return ((sysEvents.getPanelSource()!=null)&&(sysEvents.getPanelSource().equals(ToolsBean.panelClient))||
           (sysEvents.getPanelDestination()!=null)&&(sysEvents.getPanelDestination().equals(ToolsBean.panelClient)));
    }

    public void setUseClient(boolean useClient) {
      this.useClient = useClient;
    }

    public boolean isUseRangmnt() {
      return ((sysEvents.getPanelDestination()!=null)&&(sysEvents.getPanelDestination().equals(ToolsBean.panelRangmnt)));
    }

    public void setUseRangmnt(boolean useRangmnt) {
      this.useRangmnt = useRangmnt;
    }

    public String getIdPiece() {
      return idPiece;
    }

    public void setIdPiece(String idPiece) {
      this.idPiece = idPiece;
    }

    public String getIdRangement() {
      return idRangement;
    }

    public void setIdRangement(String idRangement) {
      this.idRangement = idRangement;
    }

    public String getIdCommande() {
      return idCommande;
    }

    public void setIdCommande(String idCommande) {
      this.idCommande = idCommande;
    }


    public boolean isShowFamilleProduit() {
      return (sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_STOCK));
    }

    public void setShowFamilleProduit(boolean showFamilleProduit) {
      this.showFamilleProduit = showFamilleProduit;
    }

    public boolean isIsFromDetailEvent() {
      return isFromDetailEvent;
    }

    public void setIsFromDetailEvent(boolean isFromDetailEvent) {
      this.isFromDetailEvent = isFromDetailEvent;
    }

    public String getIdFamilleProd() {
      return idFamilleProd;
    }

    public void setIdFamilleProd(String idFamilleProd) {
      this.idFamilleProd = idFamilleProd;
    }

    public int getLastIndex() {
      return lastIndex;
    }

    public void setLastIndex(int lastIndex) {
      this.lastIndex = lastIndex;
    }

    public int getIdEvent() {
      return idEvent;
    }

    public void setIdEvent(int idEvent) {
      this.idEvent = idEvent;
    }

    public String getIdOperationConsultation() {
      return idOperationConsultation;
    }

    public void setIdOperationConsultation(String idOperationConsultation) {
      this.idOperationConsultation = idOperationConsultation;
    }

    public Double getMontantEspece() {
      return (montantEspece=this.montantEspece==null?0:this.montantEspece);
    }

    public void setMontantEspece(Double montantEspece) {
      this.montantEspece = montantEspece;
    }

    public Double getMonnaie() {
      this.monnaie=this.getMontantEspece()-citems.getMontantNet();
      return this.monnaie;
    }

    public void setMonnaie(Double monnaie) {
      this.monnaie = monnaie;
    }

    public String getEtiquette() {
      return etiquette;
    }

    public void setEtiquette(String etiquette) {
      this.etiquette = etiquette;
    }

    public int getIdNumop() {
      return idNumop;
    }

    public void setIdNumop(int idNumop) {
      this.idNumop = idNumop;
    }

    public Date getDateDebut() {
      return dateDebut;
    }

    public void setDateDebut(Date dateDebut) {
      this.dateDebut = dateDebut;
    }

    public Date getDateFin() {
      return dateFin;
    }

    public void setDateFin(Date dateFin) {
      this.dateFin = dateFin;
    }


  }
  public class CItems extends Cproperties implements Serializable{
    Map<String,String> itemsOperation=new HashMap<String, String>();
    Map<String,Integer> itemsClient=new HashMap<String,Integer>();
    Map<String,Integer> itemsFournisseur=new HashMap<String, Integer>();
    Map<String,Integer> itemsTypesClient=new HashMap<String, Integer>();
    Map<String,String> itemsPiece=new HashMap<String, String>();
    Map<String,String> itemsRangement=new HashMap<String, String>();
    Map<String,Integer> itemsCommandeFournisseur=new HashMap<String, Integer>();
    Map<String,Integer> itemsPeriode=new HashMap<String, Integer>();
    Map<String,String> itemsRangmntLivraison=new HashMap<String, String>();
    Map<String,String> itemsFamilleProd=new HashMap<String, String>();
    DataModel<IUniversel> dataProduitsEvents=new ListDataModel(new ArrayList<IUniversel>());
    DataModel<IUniversel> dataProduitsStock=new ListDataModel<IUniversel>(new ArrayList<IUniversel>());
    List<Taxes> listTaxesEtValues;
        DataModel<Events>   dataListEvents=new ListDataModel<Events>(new ArrayList<Events>());
        List<DetailEvent>  listDetailEvent=new ArrayList<DetailEvent>();
        List<Ecritures>  listEcritures=new ArrayList<Ecritures>();
       
    public CItems(){
      this.itemsOperation= eventsM.getAllOperation(readProperties.read("Events.allOperation"),defaultParametter());
          if(itemsOperation.values().iterator().hasNext())
      this.idOperation=itemsOperation.values().iterator().next();
      this.idOperationConsultation=this.idOperation;
      prepareView(this.idOperation);
            this.itemsPeriode=eventsM.getAllPeriode(readProperties.read("Events.allPeriode"),null);
    }

    public void prepareView(String idEvent){
      this.setModalPanel("");
      sysAdherEvent=eventsM.getSingleAdherEvent(new SysAdherEventId(getParamsUser().adherent.getIdAdherent(),idEvent));
      sysEvents=eventsM.getCurrentOperation(idEvent);
      if(this.isUseClient()){
              sysTypcli.setIdTypcli(this.getItemsTypesClient().values().iterator().next());
              sysTypcli=eventsM.getCurrentTypeClient(sysTypcli.getIdTypcli());
              Iterator<Integer> it=this.getItemsClient().values().iterator();
              if(it.hasNext()&& sysTypcli.getIsIntern().equals("True"))
        client=eventsM.getCurrentClient(it.next());
              else{
                client.setIdClient(-1);
                client.setNom("");
                client.setAdresse("");
                client.setNumPiece("");
              }
      }
      if(this.isUseFournisseur()){
        fournisseur.setIdFourn(this.getItemsFournisseur().values().iterator().next());
              fournisseur=eventsM.getCurrentFournisseur(this.itemsFournisseur.values().iterator().next());
      }
      if(sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_STOCK)||sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_PRODUIT)){
        this.showFamilleProduit=true;
      }else this.showFamilleProduit=false;
      if(sysEvents.getTablFrom().equals(ToolsBean.FROM_TABLE_DETAILEVENT)){
        this.isFromDetailEvent=true;
      }else this.isFromDetailEvent=false;
    }
      
    public Map<String, String> getItemsFamilleProd() {
      this.itemsFamilleProd=eventsM.findGroupProd(readProperties.read("Commande.jpqlFamilleProd"),ToolsBean.getToolsBean().defaultParametter());
      return this.itemsFamilleProd;
    }
   
    public void setItemsFamilleProd(Map<String, String> itemsFamilleProd) {
      this.itemsFamilleProd = itemsFamilleProd;
    }

    public Map<String, String> getItemsOperation() {
      return this.itemsOperation;
    }
    public void setItemsOperation(Map<String, String> itemsOperation) {
      this.itemsOperation = itemsOperation;
    }

    public Map<String, Integer> getItemsClient() {
      if(this.isUseClient()){
        Map param=new HashMap<Integer,Integer>();
        param.put(0,getParamsUser().getAdherent().getIdAdherent());
      param.put(1,sysTypcli.getIdTypcli())
      return(this.itemsClient= eventsM.getAllClients(readProperties.read("Events.allClients"),param));
      }
      else return(this.itemsClient=new HashMap<String, Integer>());
    }

    public void setItemsClient(Map<String, Integer> itemsClient) {
      this.itemsClient = itemsClient;
    }

    public Map<String, Integer> getItemsFournisseur() {
      if(this.isUseFournisseur())
        return (this.itemsFournisseur=eventsM.getAllFournisseurs(readProperties.read("Events.allFournisseur"),defaultParametter()));
        else return(this.itemsFournisseur=new HashMap<String, Integer>());
    }

    public void setItemsFournisseur(Map<String, Integer> itemsFournisseur) {
      this.itemsFournisseur = itemsFournisseur;
    }

    public Map<String, Integer> getItemsTypesClient() {
      if(this.isUseClient())
      return (this.itemsTypesClient=eventsM.getTypeClients(readProperties.read("Events.allType"+sysEvents.getLibelleTiers()),defaultParametter()));
      else return(this.itemsTypesClient=new HashMap<String, Integer>());
    }

    public void setItemsTypesClient(Map<String, Integer> itemsTypesClient) {
      this.itemsTypesClient = itemsTypesClient;
    }

    public Map<String, String> getItemsPiece() {
      if(this.isUseClient())
        return (this.itemsPiece=eventsM.getAllPiece(readProperties.read("Events.allPiece"),null));
        else return(this.itemsPiece=new HashMap<String, String>());
    }

    public void setItemsPiece(Map<String, String> itemsPiece) {
      this.itemsPiece = itemsPiece;
    }

    public Map<String, String> getItemsRangement() {
      if(this.isUseRangmnt())
        return (this.itemsRangement=eventsM.getAllRangement(readProperties.read("Events.allrangement"),defaultParametter()));
        else return(this.itemsRangement=new HashMap<String, String>());
     }


   
    public void setItemsRangement(Map<String, String> itemsRangement) {
      this.itemsRangement = itemsRangement;
    }

    public Map<String, Integer> getItemsCommandeFournisseur() {
      if(this.isUseFournisseur()){
        Map<Integer,Integer> param=new HashMap<Integer,Integer>();
          param.put(0,fournisseur.getIdFourn());
        return (this.itemsCommandeFournisseur=eventsM.getAllCommandeFournisseur(readProperties.read("Events.allCommandeFournisseur"),param));
      }else return(this.itemsCommandeFournisseur=new HashMap<String, Integer>());
    }

    public void setItemsCommandeFournisseur(
        Map<String, Integer> itemsCommandeFournisseur) {
      this.itemsCommandeFournisseur = itemsCommandeFournisseur;
    }

    public Map<String, Integer> getItemsPeriode() {
      return itemsPeriode;
    }

    public void setItemsPeriode(Map<String, Integer> itemsPeriode) {
      this.itemsPeriode = itemsPeriode;
    }


    public DataModel<IUniversel> getDataProduitsStock() {
      List<IUniversel> list=eventsM.newListIUniversel((List<IUniversel>)this.dataProduitsStock.getWrappedData(),getModelProduitsEvents());
      this.dataProduitsStock.setWrappedData(list);
      return dataProduitsStock;
    }

    public void setDataProduitsStock(DataModel<IUniversel> dataProduitsStock) {
      this.dataProduitsStock = dataProduitsStock;
    }
    public Double getMontantTaxe() {
      return (montantTaxe=eventsM.getMontant(this.listTaxesEtValues,ToolsBean.EST_DE_NATURE_TAXE));
      }

      public void setMontantTaxe(Double montantTaxe) {
        this.montantTaxe = montantTaxe;
      }

      public Double getMontantFrais() {
        return (montantFrais=eventsM.getMontant(this.listTaxesEtValues,ToolsBean.EST_DE_NATURE_FRAIS));
      }

      public void setMontantFrais(Double montantFrais) {
        this.montantFrais = montantFrais;
      }

      public Double getMontantRemise() {
        return (montantRemise=eventsM.getMontant(this.listTaxesEtValues,ToolsBean.EST_DE_NATURE_REMISE));
      }

      public void setMontantRemise(Double montantRemise) {
        this.montantRemise = montantRemise;
      }

      public Double getMontantNet() {
      this.montantNet  =eventsM.getMontantTotalProduits(getModelProduitsEvents())+
                  this.getMontantTaxe()+this.getMontantFrais()-this.getMontantRemise();
      return this.montantNet; 
      }

      public void setMontantNet(Double montantNet) {
        this.montantNet = montantNet;
      }

      public List<Taxes> getListTaxesEtValues() {
        return listTaxesEtValues;
      }

      public void setListTaxesEtValues(List<Taxes> listTaxesEtValues) {
        this.listTaxesEtValues = listTaxesEtValues;
      }
      public Double getTaxeEtFrais() {
        return this.getMontantFrais()+this.getMontantTaxe();
      }

      public void setTaxeEtFrais(Double taxeEtFrais) {
        this.taxeEtFrais = taxeEtFrais;
      }
     
      public Double getMontantReliquat() {
        return this.getMontantNet()-this.getMontantRegle();
      }

      public void setMontantReliquat(Double montantReliquat) {
        this.montantReliquat = montantReliquat;
      }
     
      public Double getMontantRegle() {
        return (this.montantRegle.compareTo(0d)==0?this.getMontantNet():this.montantRegle);
      }

      public void setMontantRegle(Double montantRegle) {
        this.montantRegle = montantRegle;
      }

      public DataModel<IUniversel> getDataProduitsEvents() {
        return dataProduitsEvents;
      }

      public void setDataProduitsEvents(DataModel<IUniversel> dataProduitsEvents) {
        this.dataProduitsEvents = dataProduitsEvents;
      }

      public void setItemsRangmntLivraison(Map<String, String> itemsRangmntLivraison) {
        this.itemsRangmntLivraison = itemsRangmntLivraison;
      }
     
      public DataModel<Events> getDataListEvents() {
        if(this.dataListEvents==null){
          this.dataListEvents=new ListDataModel<Events>(new ArrayList<Events>());   
        Map<Integer,Object> param=new HashMap<Integer, Object>();
        param.put(0,getParamsUser().sysUser.getId().getIdUser());
        param.put(1,getParamsUser().adherent.getIdAdherent());
        param.put(2,this.idOperationConsultation);
        param.put(3,dateDebut);
        param.put(4,dateFin);
        dataListEvents.setWrappedData((List<Events>) eventsM.listEvents(readProperties.read("Events.jpqlListEvents"), param));
        }
        return dataListEvents;
      }


      public void setDataListEvents(DataModel<Events> dataListEvents) {
        this.dataListEvents = dataListEvents;
      }

      public List<DetailEvent> getListDetailEvent() {
        Map param=new HashMap<Integer,Integer>();
        param.put(0,this.idEvent);
        this.listDetailEvent=eventsM.listDetailEvent(readProperties.read("Events.jpqlListDetailEvents"), param);
        return listDetailEvent;
      }

      public void setListDetailEvent(List<DetailEvent> listDetailEvent) {
        this.listDetailEvent = listDetailEvent;
      }

      public List<Ecritures> getListEcritures() {
        Map param= new HashMap<Integer,Double>();
        param.put(0,Double.parseDouble(""+this.idNumop));
        this.listEcritures=eventsM.listEcritures(readProperties.read("Events.jpqlListEcritures"), param);
        return listEcritures;
      }

      public void setListEcritures(List<Ecritures> listEcritures) {
        this.listEcritures = listEcritures;
      }

     
  }


}
TOP

Related Classes of sn.unitech.stock.bean.EventsBean$AllRefs

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.