<?xml version="1.0" encoding="ISO-8859-1"?>
<INDICATOR title="Intégrité tables" 
	name="iCTI_eco_integrite_tables" 
	type="CTIsql" 
	softCode="iCTI_eco"
	eisOnly="false"
	indicatorKey="" 
	linkView="ECO000001">
	<reportTitle><![CDATA[Intégrité tables [CONTEXT] [STATUT]]]></reportTitle>
	<reportDescription></reportDescription>
	<SQL database="iCTI">
		<select><![CDATA[		
						SELECT
							now() AS date,
								count_p_lignes_commandes - count_v_lignes_commandes +
								count_p_mouvements_articles - count_v_mouvements_articles
							AS ecart_total,
							count_p_lignes_commandes,
							count_v_lignes_commandes,
							count_p_lignes_commandes - count_v_lignes_commandes AS ecart_lignes_commandes,
							count_p_mouvements_articles,
							count_v_mouvements_articles,
							count_p_mouvements_articles - count_v_mouvements_articles AS ecart_mouvements_articles
						FROM
							(
							SELECT 
							(SELECT count(*) FROM eco.p_lignes_commandes) AS count_p_lignes_commandes,
							(SELECT count(*) FROM eco.v_lignes_commandes_1) AS count_v_lignes_commandes,
							(SELECT count(*) FROM eco.p_mouvements_articles) AS count_p_mouvements_articles,
							(SELECT count(*) FROM eco.v_mouvements_articles_1) AS count_v_mouvements_articles
							) subview
		]]></select>
	</SQL>
	<ALERT rule_compareField="ecart_lignes_commandes" rule_compareOperator=">" rule_compareValue="0" result="ERROR" resultText="ERREUR d'intégrité sur table p_lignes_commandes" />
	<ALERT rule_compareField="ecart_mouvements_articles" rule_compareOperator=">" rule_compareValue="0" result="ERROR" resultText="ERREUR d'intégrité sur table p_mouvements_articles" />
	<ALERT rule_compareField="ecart_total" rule_compareOperator=">" rule_compareValue="0" result="ERROR" resultText="ERREUR d'intégrité" />
	<ALERT rule_compareField="ecart_total" rule_compareOperator="=" rule_compareValue="0" result="OK" resultText="Intégrité CORRECTE" />

</INDICATOR>
