DEFINITION C_Article_860026467 "Tv2oip"
REGISTRE ENTIER res_860026467
REGISTRE ENTIER duree_860026467
REGISTRE ENTIER erreur_860026467
REGISTRE ENTIER efficiency_860026467
REGISTRE ENTIER EFFICACE_860026467
REGISTRE ENTIER code_errone_860026467
REGISTRE POINTEUR pt_indicator_860026467
REGISTRE POINTEUR pt_MESSAGE_860026467
#####################################################################
# TRAITEMENT
#
#	Tv2oip : DC plateforme SIP
#	27/04/06 JLG creation
#
##################################################################################################################
#	HISTORIQUE
# 
#PKH	- 09/08/2006 - Modif. des contrtles unitaires et croisis
#FO1941	- 04/09/2006 - PK Test de presence du champ ChargeIndicator avant de le lire
#JLG	- 26/04/2007 - G2R2CuNH modif enveloppe optionnelle
#JLG	- 07/06/2007 - Param NH-G2R5 : mise en commentaire des traces
# 12/11/07 - THE - ParamFTSA-G3R4 Delestage NH + modif alarmes 6371(x2)
# 22/09/08 - PKH - G3R8 evolution champ demandeur CallingNb rendu optionnel
# 11/05/10 - BEA - G3R17 Item T3G V6slot2-Rappel par le 31 V2oip_S20F2.doc controle croise presence TranslateNb
# 06/08/14 - DRE - G4R7 lot4 Controle de la presence des champs devenant facultatifs dans le cas d'article (CalledNb , DATE, Duree, RoleOfNode, Efficiency, Cause, ChargingId, SCSCFId)
#
####################################################################################################################

# Constantes

# Variables fonctionnelles

# DECLARATION POINTEUR
# Initialisation
pt_indicator_860026467 = "00000000000000"
pt_MESSAGE_860026467 = "pt_MESSAGE12312312312312312312312312131213121312131213121312131232131213112131123112312131213112312131231123121"
i_strcpy(pt_indicator_860026467,"")
i_strcpy(pt_MESSAGE_860026467,"")
#trace("[Tv2oip_tr] Traitement - Tv2oip")

################################################################
#
#	Tests semantiques
#
################################################################
#
EFFICACE_860026467 = 0


#DRE G4R7 lot4
# Controle de la presence des champs devenant facultatifs dans le cas d'article (CalledNb , DATE, Duree, RoleOfNode, Efficiency, Cause, ChargingId, SCSCFId)
SI !(i_valid_field_n(g_iartin, $Tv2oip::T3CalledNb))
ALORS
	#E.TV2OIP.TC8
	i_strcpy(pt_MESSAGE_860026467," Champ obligatoire 'CalledNb' absent ")	
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
	SAUT STOCKE_ERRONE
FINSI

SI !(i_valid_field_n(g_iartin, $Tv2oip::T3Date))
ALORS
	#E.TV2OIP.TC3
	i_strcpy(pt_MESSAGE_860026467," Champ obligatoire 'DATE' absent ")	
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
	SAUT STOCKE_ERRONE
FINSI

SI !(i_valid_field_n(g_iartin, $Tv2oip::T3Duree))
ALORS
	#E.TV2OIP.TC5
	i_strcpy(pt_MESSAGE_860026467," Champ obligatoire 'DUREE' absent ")	
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
	SAUT STOCKE_ERRONE
FINSI

SI !(i_valid_field_n(g_iartin, $Tv2oip::T3roleOfNode))
ALORS
	#E.TV2OIP.TC13
	i_strcpy(pt_MESSAGE_860026467," Champ obligatoire 'roleOfNode' absent ")	
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
	SAUT STOCKE_ERRONE
FINSI

SI !(i_valid_field_n(g_iartin, $Tv2oip::T3Efficiency))
ALORS
	#E.TV2OIP.TC10
	i_strcpy(pt_MESSAGE_860026467," Champ obligatoire 'Efficiency' absent ")	
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
	SAUT STOCKE_ERRONE
FINSI

SI !(i_valid_field_n(g_iartin, $Tv2oip::T3Cause))
ALORS
	#E.TV2OIP.TC12
	i_strcpy(pt_MESSAGE_860026467," Champ obligatoire 'Cause' absent ")	
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
	SAUT STOCKE_ERRONE
FINSI

SI !(i_valid_field_n(g_iartin, $Tv2oip::T3ChargingId))
ALORS
	#E.TV2OIP.TC2
	i_strcpy(pt_MESSAGE_860026467," Champ obligatoire 'ChargingId' absent ")	
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
	SAUT STOCKE_ERRONE
FINSI

SI !(i_valid_field_n(g_iartin, $Tv2oip::T3SCSCFId))
ALORS
	#E.TV2OIP.TC9
	i_strcpy(pt_MESSAGE_860026467," Champ obligatoire 'SCSCFId' absent ")	
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
	SAUT STOCKE_ERRONE
FINSI

# FIN Controle de la presence des champs devenant facultatifs dans le cas d'article
#\DRE G4R7 lot4


##G2R2CfNS PK ##
#Modification de la methode de calcul EFFICACE #

duree_860026467 = 0
#SI (i_valid_field_n(g_iartin, $Tv2oip::T3Duree))
#ALORS
	duree_860026467=i_get_art_field(g_iartin, $Tv2oip::DUREE)
	SI ( duree_860026467 != 0 )
	ALORS
		EFFICACE_860026467 = 1
	FINSI
#FINSI

## Efficiency ##
efficiency_860026467 =i_get_art_field(g_iartin, $Tv2oip::Efficiency)
SI (efficiency_860026467 != 0x01 && efficiency_860026467 != 0x02)
ALORS
	#E.TV2OIP.TC11
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6370,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,efficiency_860026467)
	SAUT STOCKE_ERRONE
FINSI

## roleOfNode ##
res_860026467 =i_get_art_field(g_iartin, $Tv2oip::roleOfNode)
SI (res_860026467 != 0x00 && res_860026467 != 0x01)
ALORS
	#E.TV2OIP.TC14
	code_errone_860026467 = 0x5040
	code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
	erreur_860026467 = i_PlvMessEmettre(6371,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,res_860026467)
	SAUT STOCKE_ERRONE
FINSI

#G2R2CfNS PK
#Rajout des tests syntaxique pour chargeIndicator et ASFacresult#

# Chargindicator ##
#FO1942 PK Test de presence du champ ChargeIndicator
SI (i_valid_field_n(g_iartin,$Tv2oip::ChargeIndicator))
ALORS
	#E.TV2OIP.TC15
	erreur_860026467 = i_get_art_str(g_iartin, $Tv2oip::ChargeIndicator,pt_indicator_860026467)
	SI (i_strcmp(pt_indicator_860026467 , "y") && i_strcmp(pt_indicator_860026467 , "n") && i_strcmp(pt_indicator_860026467 , "O"))
	ALORS
		code_errone_860026467 = 0x5040
		code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
		erreur_860026467 = i_PlvMessEmettre(6381,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_indicator_860026467)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

## ASFacresult  ##
#FO1912 PK Test de presence du champ ASFacResult
SI (i_valid_field_n(g_iartin,$Tv2oip::ASFacResult))
ALORS  
	#E.TV2OIP.TC16
	#E.TV2OIP.TC18 traite par binaire
	res_860026467 = i_get_art_field(g_iartin, $Tv2oip::ASFacResult)
	SI (res_860026467 != 0x01 && res_860026467 != 0x02)
	ALORS
		code_errone_860026467 = 0x5040
		code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
		erreur_860026467 = i_PlvMessEmettre(6382,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,res_860026467)
		SAUT STOCKE_ERRONE
	FINSI
FINSI

#G3R17 ASServicename = 20 et answerIndicator = "Yes"
erreur_860026467 = i_get_art_str(g_iartin, $Tv2oip::AnswerIndicator , pt_indicator_860026467 ) 
SI ((i_get_art_field(g_iartin, $Tv2oip::T3ASService1 + 4) == 20) && (i_strcmp(pt_indicator_860026467,"Yes") == 0))
ALORS
	#E.TV2OIP.TC19
	#TranslatedNb doit etre present
	SI (i_valid_field_n(g_iartin,$Tv2oip::TranslatedNb) == 0)
	ALORS
		code_errone_860026467 = 0x5040
		code_errone_860026467 = code_errone_860026467 + EFFICACE_860026467
		i_strcpy (pt_MESSAGE_860026467, "champ TranslatedNb absent")
		erreur_860026467 = i_PlvMessEmettre(6384,2,g_iartin,"",3,code_errone_860026467,C_Article_860026467,pt_MESSAGE_860026467)
		SAUT STOCKE_ERRONE
	FINSI

FINSI
#Test sur presence du champ CallingNb
#sans emission de message simple 
SI (! i_valid_field_n(g_iartin,$Tv2oip::CallingNb))
ALORS
     #E.TV2OIP.TC7
     #trace ("champ CallingNb absent envoi en elimine")
     #erreur = i_PlvMessEmettre(6384,2,g_iartin,"",1,C_Article,0,0)
     SAUT STOCKE_ELM
FINSI


# Creation Enveloppe Optionnelle avec Compteur Recyclage pour symphonie
#==============================================================================
# G2R2CuNH
erreur_860026467 = i_add_opt( "E_V2OIP" )

# champ T1 (renseigne par l'ATP)
# Champ L1 (calculee par ATP)
# Champ CptRecy
erreur_860026467 = i_set_attr_val_n($E_V2OIP::CptRecy,3)
# fin G2R2CuNH

SAUT STOCKE_OK

#==============================================================================
#	Stockage en valide
#==============================================================================

POINT   STOCKE_OK
#trace("[Tv2oip_tr] #trace Stockage en valide")
erreur_860026467 = i_stocke_art(g_iartin, 0, PT_OK, 0)

RETOUR TRAIT_OK

#==============================================================================
#	Stockage en errone
#==============================================================================

POINT  STOCKE_ERRONE

#trace("[Tv2oip_tr] Stockage en ERRONE ")

erreur_860026467 = i_make_art_rej(g_iartin, g_iartout5, code_errone_860026467)
erreur_860026467 = i_stocke_art(g_iartout5, 0, PT_ERRONE, 0)

RETOUR TRAIT_OK

#==============================================================================
#	Stockage en elimine
#==============================================================================

POINT  STOCKE_ELM

trace("[Tv2oip_tr] Stockage en ELIMINE ")

erreur_860026467 = i_stocke_art(g_iartin, 0, PT_ELIMINE, 0)

RETOUR TRAIT_OK

#--------------Fin Pcode Traitement Tv2oip_tr.src-------------------------
