<?php
//++++++
$SYS_FOC="Nom";
//+++++
$Nom=VU($_POST['Nom']);
//++
$LIMPIAR=0;
//--------------------------------------------------------------------------
PID($StrId,V($_GET['Id']),$StrCmd,$LStrPag,V($_GET['Pag']));
//--------------------------------------------------------------------------
if(strlen($StrId)>0 && $StrCmd=="AR"){
	$Id=$StrId;
	$r=gr("ges_xml_costos_tipos","id_ct=$Id");
	$Nom=$r['ct_nom'];
}
//
if($StrCmd=="L"){
	$LIMPIAR=1;
}	
//
if($StrCmd=="G" || $StrCmd=="M"){
//
}
//
if($StrCmd=="G"){	
	if(strlen($Nom)>0){
		if(gn("count(*)","ges_xml_costos_tipos","ct_nom='$NomCom'")>0){
			$SYS_MSG="Nombre ya registrado";
			$SYS_FOC="Nom";
			$OK=0;
		}
	}	
	if($OK==1){
		$Id=GenId("id_ct","ges_xml_costos_tipos");
		$s="INSERT INTO ges_xml_costos_tipos VALUES ($Id,'$Nom')";
		ejt($s);	
		//echo $s."<br>";	
		//BIT+++++++++++++++++
		$_BIT_MOD_ID=$Id;
		$_BIT_SQL_CAB=$s;
		$_BIT_SQL_DET="";
		$_BIT_PHP="ges_xml_costos.php";
		$_BIT_ID=BIT_ADD("MANTENIMIENTO","COSTOS CONCEPTOS","GUARDAR",$_BIT_MOD_ID,$_BIT_SQL_CAB,$_BIT_SQL_DET,$_BIT_PHP);
		BIT_DET_ADD($_BIT_ID,$s);
		//BIT			
		$SYS_MSG="Datos registrados";
		$LIMPIAR=1;
		$ACTUALIZAR=1;
	}
}
//++
if($StrCmd=="M"){
	if(strlen($Nom)>0){
		if(gn("count(*)","ges_xml_costos_tipos","ct_nom='$NomCom' AND id_ct<>$StrId")>0){
			$SYS_MSG="Nombre ya registrado";
			$SYS_FOC="Nom";
			$OK=0;
		}
	}	
	//
	if($OK==1){
		$s="UPDATE ges_xml_costos_tipos 
			SET ct_nom='$Nom' WHERE id_ct=$StrId";
		ejt($s);		
		//BIT
		$_BIT_MOD_ID=$StrId;
		$_BIT_SQL_CAB=$s;
		$_BIT_SQL_DET="";
		$_BIT_PHP="ges_xml_costos.php";
		$_BIT_ID=BIT_ADD("MANTENIMIENTO","COSTOS CONCEPTOS","MODIFICAR",$_BIT_MOD_ID,$_BIT_SQL_CAB,$_BIT_SQL_DET,$_BIT_PHP);
		BIT_DET_ADD($_BIT_ID,$s);
		//BIT				
		$SYS_MSG="Datos actualizados";
		$LIMPIAR=1;
		$ACTUALIZAR=1;
	}
}
//
if($StrCmd=="E"){
	if($OK==1){	
		$s="DELETE FROM ges_xml_costos_tipos WHERE id_ct=$StrId";
		ejt($s);
		//BIT
		$_BIT_MOD_ID=$StrId;
		$_BIT_SQL_CAB=$s;
		$_BIT_SQL_DET="";
		$_BIT_PHP="ges_xml_costos.php";
		$_BIT_ID=BIT_ADD("MANTENIMIENTO","COSTOS CONCEPTOS","ELIMINAR",$_BIT_MOD_ID,$_BIT_SQL_CAB,$_BIT_SQL_DET,$_BIT_PHP);
		BIT_DET_ADD($_BIT_ID,$s);
		//BIT		
		$SYS_MSG="Datos eliminados";
		$LIMPIAR=1;	
		$ACTUALIZAR=1;
	}
}
//
if($LIMPIAR==1){
	$StrId="";
	$Nom="";
}
?>
