
import java.math.BigDecimal;

import com.softwareag.entirex.aci.Broker;
import com.softwareag.entirex.aci.BrokerException;

/**
 * <p>Titre : Jwlwfpl1Web</p>
 * <p>Description : Classe de récupération de la liste des Fiches portage</p>
 * <p>Copyright : Copyright (c) 2009</p>
 * <p>Societe : ENSOR</p>
 * @author AR & DR & PY <i>06/04/2012</i>
 * @version 1.0
 */
public class Jwlwfpl1Web {	

		private static String PRINT = "NO";
		/**
		 * <p>Titre : getFichesPortage</p>
		 * <p>Description : Récupération de l'objet Liste des fiches portage</p>
		 * <p>Copyright : Copyright (c) 2012</p>
		 * <p>Societe : ENSOR</p>
		 * @author AR & DR & PY <i>06/04/2012</i>
		 * @version 1.0
		 */
		public static Jwlwfpl1 getFichesPortage(
			String nbrep,
			String page,
			String fonction,
			String cd_prt ,           
			String fi_por_zone,     
			String type_portage,
			String no_ticket,
			String etat_ticket,
			String cd_cible_1,
			String num_cli,
			String num_reclamation,
			String mot_directeur_voie,
			String cd_postal,
			String cd_insee,
			String localite,
			String type_cas_logistic,
			String etat_cas_logistic,
			String numero_voie,
			String groupe_exploitant,
			String numero_session,
			String utilisateur,
			String cd_cible,
			String cd_stegrp,
			Broker broker) throws BrokerException {
			// Initialisation des variables en entrees
	     	Jwlwfpl1 jwlwfpl1 = new Jwlwfpl1(broker, Constantes.SERVER_ADRESSE);
			
			// Initialisation de la vWebent depuis les informations de connexion
			Jwlwfpl1.Nwlwfpl1Axwebent vWebent = jwlwfpl1.new Nwlwfpl1Axwebent();
			vWebent.dbid 		   		= new BigDecimal (Constantes.DBID);
			vWebent.cible_exploitant 	= Constantes.CD_CIBLE;
			vWebent.groupe_exploitant 	= groupe_exploitant;
			vWebent.numero_session 		= new BigDecimal (numero_session);
			vWebent.utilisateur 		= utilisateur;
			vWebent.transaction 		= "WLWFPLST";
			vWebent.fonction 			= fonction;
			vWebent.cd_cible 			= cd_cible;
			vWebent.cd_stegrp 			= cd_stegrp;
			vWebent.cd_application 		= Constantes.CD_APPLICATION;
			jwlwfpl1.setNwlwfpl1Axwebent (vWebent);
	        
			// Initialisation des paramètres de pagination
			Jwlwfpl1.Nwlwfpl1Axweblst vWeblst = jwlwfpl1.new Nwlwfpl1Axweblst();
			vWeblst.nb_rep_souhait 		      = new BigDecimal(nbrep);
			vWeblst.num_page_souhait   		  = new BigDecimal(page);
			jwlwfpl1.setNwlwfpl1Axweblst (vWeblst);

			// Initialisation des critères (tous à vide pour l'instant)
			Jwlwfpl1.Nwlwfpl1Awlwfpl1 vLwfpl1 		        					 = jwlwfpl1.new Nwlwfpl1Awlwfpl1();
			Jwlwfpl1.Nwlwfpl1Awlwfpl1Demande vLwfpl1Demande 					 = jwlwfpl1.new Nwlwfpl1Awlwfpl1Demande();
			Jwlwfpl1.Nwlwfpl1Awlwfpl1DemandeCritere_select vLwfpl1DemandeCritere = jwlwfpl1.new Nwlwfpl1Awlwfpl1DemandeCritere_select();
			
			vLwfpl1DemandeCritere.cd_prt 	  	= cd_prt;
			vLwfpl1DemandeCritere.fi_por_zone 	= fi_por_zone;
			vLwfpl1DemandeCritere.type_portage  = type_portage;
			vLwfpl1DemandeCritere.no_ticket     = no_ticket;
			vLwfpl1DemandeCritere.etat_ticket   = etat_ticket;
			
			vLwfpl1DemandeCritere.cd_cible 		= cd_cible_1;
			if(!"".equals(num_cli) && num_cli!=null){
    			num_cli = Utils.transformNumClient(num_cli) ;
    		}
			vLwfpl1DemandeCritere.num_cli = num_cli;
			if(!"".equals(num_reclamation) && num_reclamation!=null){
				vLwfpl1DemandeCritere.num_reclamation = new BigDecimal(num_reclamation);
			}
			vLwfpl1DemandeCritere.mot_directeur_voie = mot_directeur_voie;
			vLwfpl1DemandeCritere.cd_postal 		 = cd_postal;
			vLwfpl1DemandeCritere.cd_insee 		  	 = cd_insee;
			vLwfpl1DemandeCritere.localite 		   	 = localite;
			vLwfpl1DemandeCritere.type_cas_logistic  = type_cas_logistic;
			vLwfpl1DemandeCritere.etat_cas_logistic  = etat_cas_logistic;
			vLwfpl1DemandeCritere.numero_voie  		 = numero_voie;
			
			vLwfpl1Demande.critere_select = vLwfpl1DemandeCritere;
			vLwfpl1.demande = vLwfpl1Demande;
			
			jwlwfpl1.setNwlwfpl1Awlwfpl1 (vLwfpl1);
			
		    // CALL SERVER
		    jwlwfpl1.nwlwfpl1();
				                                
	        // Verification du code retour
			vWebent = jwlwfpl1.getNwlwfpl1Axwebent();
			System.out.println("Code retour nwlwfpl1() = " + vWebent.code_retour.intValue());
			
			if(vWebent.code_retour.intValue() != 0){
				for(int i=0; i < vWebent.nb_ano.intValue(); i++){
				   System.out.println(vWebent.t_ano[i].code_ano + "[" + vWebent.t_ano[i].type_ano + "] : '" + vWebent.t_ano[i].lib_ano.trim() + "'");
			   	   }
				}
			else {
				//Récupération du résultat si code retour OK
				Jwlwfpl1.Nwlwfpl1Awlwfpl1_tab vWeblsttab = jwlwfpl1.getNwlwfpl1Awlwfpl1_tab();
				
				//Affichage de la liste des résultats
				if(PRINT == "YES") {
					for(int i = 0; i < new BigDecimal(nbrep).intValue(); i++){
							System.out.println ("cd_cible =" + vWeblsttab.ligne_ref[i].cd_cible
									+ ";num_cli=" 		  	 + vWeblsttab.ligne_ref[i].num_cli 
									+ ";num_voie=" 		  	 + vWeblsttab.ligne_ref[i].numero_voie
									+ ";voie=" 		  		 + vWeblsttab.ligne_ref[i].voie 
									+ ";type_adresse="   	 + vWeblsttab.ligne_ref[i].type_adresse 
									+ ";etat_adresse=" 		 + vWeblsttab.ligne_ref[i].etat_adresse 
									+ ";dt_debval_cpl=" 	 + vWeblsttab.ligne_ref[i].dt_debval_cpl.intValue()
									+ ";cd_postal=" 		 + vWeblsttab.ligne_ref[i].cd_postal
									+ ";localite=" 		  	 + vWeblsttab.ligne_ref[i].localite 
									+ ";cd_insee=" 		  	 + vWeblsttab.ligne_ref[i].cd_insee
									+ ";fi_type_depot=" 	 + vWeblsttab.ligne_ref[i].fi_type_depot
									+ ";fi_tpr_groupe=" 	 + vWeblsttab.ligne_ref[i].fi_tpr_groupe
									+ ";lib_reponse=" 		 + vWeblsttab.ligne_ref[i].lib_reponse
									+ ";cd_reponse=" 		 + vWeblsttab.ligne_ref[i].cd_reponse
									+ ";dt_deb_periode=" 	 + vWeblsttab.ligne_ref[i].dt_deb_periode.intValue()
									+ ";dt_deb_periode1=" 	 + vWeblsttab.ligne_ref[i].dt_deb_periode1.intValue()
									+ ";dt_deb_periode2=" 	 + vWeblsttab.ligne_ref[i].dt_deb_periode2.intValue()
									+ ";dt_deb_periode3=" 	 + vWeblsttab.ligne_ref[i].dt_deb_periode3.intValue()
									+ ";dt_fin_periode=" 	 + vWeblsttab.ligne_ref[i].dt_fin_periode.intValue()
									+ ";dt_fin_periode1=" 	 + vWeblsttab.ligne_ref[i].dt_fin_periode1.intValue()
									+ ";dt_fin_periode2=" 	 + vWeblsttab.ligne_ref[i].dt_fin_periode2.intValue()
									+ ";dt_fin_periode3=" 	 + vWeblsttab.ligne_ref[i].dt_fin_periode3.intValue()
									+ ";num_reclamation=" 	 + vWeblsttab.ligne_ref[i].num_reclamation.intValue()
									+ ";num_reclamation1=" 	 + vWeblsttab.ligne_ref[i].num_reclamation1.intValue()
									+ ";num_reclamation2=" 	 + vWeblsttab.ligne_ref[i].num_reclamation2.intValue()
									+ ";num_reclamation3=" 	 + vWeblsttab.ligne_ref[i].num_reclamation3.intValue()
							);
							System.out.println("\n");
					}
					//Affichage des informations de pagination
					System.out.println ("nb_rep_rendues : "    + jwlwfpl1.getNwlwfpl1Axweblst().nb_rep_rendues);
					System.out.println ("num_page_rendue : "   + jwlwfpl1.getNwlwfpl1Axweblst().num_page_rendue);
					System.out.println ("top_page_suivante : " + jwlwfpl1.getNwlwfpl1Axweblst().top_page_suivante);
					System.out.println ("nb_pages_totales : "  + jwlwfpl1.getNwlwfpl1Axweblst().nb_pages_totales);
				}
			}
			return jwlwfpl1;
			
	   } // End getFichesPortage

		/**
		 * <p>Titre : main</p>
		 * <p>Description : Programme principal de tests</p>
		 * <p>Copyright : Copyright (c) 2012</p>
		 * <p>Societe : ENSOR</p>
		 * @author AR & DR & PY <i>06/04/2012</i>
		 * @version 1.0
		 */
	   	public static void main(String[] args) throws BrokerException {
			Constantes.loadProperties("LW") ;
			JxweblogWeb.setUtilisateur ("GLIWB02");
			JxweblogWeb.setPassword ("GLIWB02");
			Broker broker 	  = JxweblogWeb.logonBroker();
			Jxweblog jxweblog = JxweblogWeb.getConnexion(broker);
			PRINT = "YES";
			
			Jxweblog.NxweblogAxwebent connexion = jxweblog.getNxweblogAxwebent();
			String groupe_exploitant 			= connexion.groupe_exploitant;
			String numero_session 				= Integer.toString(connexion.numero_session.intValue());
			String utilisateur 					= connexion.utilisateur;
			String cd_cible 					= connexion.cd_cible;
			String cd_stegrp 					= connexion.cd_stegrp;
			
			getFichesPortage ( "15", "1", "I",
			"0001", "0001", "N", null, null, null, null,null, null,null,null, null,null,null,null,
			groupe_exploitant, numero_session, utilisateur, cd_cible, cd_stegrp,broker);
			JxweblogWeb.closeConnexion (jxweblog);
	   }
} // END Jwlwdil1Php