<?php
	$P_C="CboEmp";
	$StrHWND_G=$_SESSION['SYS_HW']."_GI";
	$LIMPIAR=0;
	//-------------------------+++++
	$StrDATA=V($_POST['TxtDAT']);
	$StrId=V($_POST['TxtId']);
	$StrCmd=V($_POST['TxtAc']);
	//-------------------------
	if(strlen($StrCmd)==0){
		$StrCmd=V($_GET['TxtAc']);
		if($StrCmd=="X")$StrCmd="C";
	}
	//-------------------------	
	$DR=vbval(V($_POST['TxtDR']));
	$DR_NOM=V($_POST['DR_NOM']);
	$DR_DES=vbval(V($_POST['DR_DES']));
	$DR_PRI=vbval(V($_POST['DR_PRI']));	
	//-------------------------	
	$StrEmp=V($_POST['CboEmp']);
	$StrAlm=V($_POST['CboAlm']);
	//
	if(strlen($StrEmp)==0)$StrEmp=GE("N");
	if(strlen($StrAlm)==0)$StrAlm=GA($StrEmp,"N");	
	//
	if($_SERVER['REQUEST_METHOD']=="POST"){
		$StrN_AUTO=vbval(V($_POST['ChN_AUTO']));
	}else{
		$StrN_AUTO="1";
	}
	
	$StrSer=V($_POST['TxtSer']);
	$StrNum=V($_POST['TxtNum']);
	$StrFec=V($_POST['TxtFec']);
	$StrCli=V($_POST['TxtCli']);
	$StrCar=V($_POST['TxtCar']);
	//
	$StrEmpR=V($_POST['CboEmpR']);
	$StrSerR=V($_POST['TxtSerR']);
	$StrNumR=V($_POST['TxtNumR']);
	//
	$StrCod=V($_POST['TxtCod']);
	$StrDes=V($_POST['TxtDes']);
	$StrMARCA=V($_POST['TxtMarcas']);
	$StrCant=V($_POST['TxtCant']);
	$StrCUni=V($_POST['TxtCUni']);
	//
	$StrPro_ID=vbval(V($_POST['Pro_TxtId']));
	$StrPro_CA=vbval(V($_POST['TxtCant']));
 	$Pro_Des=V($_POST['Pro_TxtDes']);
	$Pro_Pre=V($_POST['Pro_TxtPre']);
	$Pro_Cod=V($_POST['Pro_TxtCod']);
	$Pro_Marca=V($_POST['Pro_TxtMarca']);
	//
	if(strlen($StrFec)==0)$StrFec=date("d-m-y");
	if(strlen($StrIdCliente)==0)$StrIdCliente="0";

	if(strlen($StrPro_PR)==0 || !is_numeric($StrPro_PR)) $StrPro_PR="0";
	//------------------------
	$StrTC=gs("valor","valores","dato='T_CAMBIO'");
	//-------------------------
	//ACTIVAR DESDE OTRA PAGINA
	if(strlen($StrId)==0){
		$StrId=V($_GET['Id']);
		if(is_numeric($StrId)==false){
			$StrId="";
		}else{
			$StrCmd="AR";
			$LStrPag=V($_GET['Pag']);
			if(!is_numeric($LStrPag)){
				$LStrPag="";
			}
		}
	}
	//FUNCIONES DE DESZPLAZAMIENTO
	if(strlen($LStrPag)==0)$LStrPag="0";
	if($StrCmd=="MSig")$LStrPag=($LStrPag+1);
	if($StrCmd=="MAnt")$LStrPag=($LStrPag-1);
	if($StrCmd=="MPri")$LStrPag=0;
	if($StrCmd=="MUlt")$LStrPag=(floor($LStrTR / $VP_RegXPag) );
	//FUNCION PARA ACTIVAR UN REGISTRO
	if(strlen($StrId)>0 && $StrCmd=="AR"){
		$Id=$StrId;
		$StrEmp=gs("EMPC","vginterna","ID=$Id");
		$StrAlm=gs("ALM","vginterna","ID=$Id");
		//echo "@".$StrEmp."@".$StrAlm;
		$StrSer=gs("SER","vginterna","ID=$Id");		
		$StrNum=gs("NUM","vginterna","ID=$Id");		
		$StrFec=gs("DATE_FORMAT(FEC,'%d-%m-%y')","vginterna","ID=$Id");
		$StrCli=gs("DES","vginterna","ID=$Id");	
		
		$StrEmpR=gs("C_EMP","vginterna","ID=$Id");	
		$StrSerR=gs("COT_SER","vginterna","ID=$Id");	
		$StrNumR=gs("COT_NUM","vginterna","ID=$Id");
		$StrAnu=gs("ANU","vginterna","ID=$Id");
		$StrCar=gs("CAR","vginterna","ID=$Id");
		ejt("DELETE FROM temp_compras WHERE cod_temc='$StrHWND_G'");
		$s="SELECT * FROM ginterna_det WHERE id_gi=$Id ORDER BY cx";		
		$cx=0;	
		$result = grs($s);			
		while ($row = $result->fetch_row()){
			$cx++;
			$AR_ID=$row[2];
			$AR_CA=$row[3];
			$AR_CU=$row[6];
			$AR_PR=0;
			$AR_IM=0;
			$s="INSERT INTO temp_compras VALUES ('$StrHWND_G',
			   $AR_ID,$AR_CA,$AR_PR,$AR_IM,$cx,'','',$AR_CU)";
			ejt($s);
		}
		$IDC=gn("gi_id_cotizacion","ginterna","id_gi=$Id");
		if($IDC>0){
			$DR_NOM="PROFORMA";		 
			$DR_DES="0";
			$DR_PRI=vbval(gs("cot_pri","cotizaciones","id_cotizacion=$IDC"));
			$StrCod="";
			$StrDes="";
			$StrMARCA="";
			$StrCant="";
			$StrCUni="";			
		}
		$_ID=gn("count(*)","guias","id_comr=-2 AND id_ref=$Id AND anu='N'");
		if($_ID>0){
			$DR=$_ID;	
		}
	}
	//
	if($StrCmd=="KCH"){
		$DAT = explode(',',$StrDATA);
		$i=0;
		for($i=0;$i<count($DAT);$i++){
			$STR_INDEX=vbval($DAT[$i]);
			ejt("DELETE FROM temp_compras WHERE 
				temc_index=$STR_INDEX AND cod_temc='$StrHWND_G'");			
		}		
		$LStrFoc="document.getElementById('TxtCod').focus();";						
		$StrGT="S";	
		$StrVuelto="0.0";
		$StrPagarCon="0";		
	}
	//
	if($StrCmd=="LOAD_REF_X"){
		$DR_NOM="";		 
		$DR_DES="0";
		$DR_PRI="0";
		$StrSerR="";
		$StrNumR="";
		$StrCli="";
		ejt("DELETE FROM temp_compras WHERE cod_temc='$StrHWND_G'");		
	}
	//
	if($StrCmd=="LOAD_REF"){				
		ejt("DELETE FROM temp_compras WHERE cod_temc='$StrHWND_G'");
		$_CXX=0;
		$ISER=vbval($StrSerR);
		$INUM=vbval($StrNumR);
		/*
		$IDC=gn("id_cotizacion","cotizaciones","iser=$ISER AND inum=$INUM ");
		*/
		$EmpR_=gn("id_emp","empresas","emp_nomc='$StrEmpR'");		
		$IDC=gn("ID_COT","vix_cotizaciones","SER_=$ISER AND NUM_=$INUM AND ID_EMP=$EmpR_");
		
		
		$StrCli=gs("CLI","vcotizaciones","ID=$IDC");
		$s="SELECT * FROM cotizaciones_det ".
		   "WHERE id_cotizacion=$IDC ORDER BY cx";
		$result = grs($s);			
		while ($row = $result->fetch_assoc()){
			$_IDP=$row['id_producto'];
			$_CAN=$row['ca_control'] - $row['dej'];
			if($_CAN>0){
				$_PRE=0;
				$_IMP=0;
				$_CXX++;
				$_COD=gs("COD","vproductos","ID=$_IDP");
				$_DES=gs("DESCRIPCION","vproductos","ID=$_IDP");
				$_CAU=$row['can_uni'];
				$s="INSERT INTO temp_compras VALUES ('$StrHWND_G',
				   $_IDP,$_CAN,$_PRE,$_CAN,$_CXX,'$_COD','$_DES',$_CAU)";
				ejt($s);	
			}
		}
		$DR_NOM="PROFORMA";		 
		$DR_DES=vbval(gs("cot_des","cotizaciones","id_cotizacion=$IDC"));
		$DR_PRI=vbval(gs("cot_pri","cotizaciones","id_cotizacion=$IDC"));
	}
	//
	if($StrCmd=="C"){
		ejt("DELETE FROM temp_compras WHERE cod_temc='$StrHWND_G'");
		$LIMPIAR=1;
	}
	//
	if($StrCmd=="KILLER"){
		ejt("DELETE FROM temp_compras WHERE 
				temc_index=$StrPro_ID AND cod_temc='$StrHWND_G'");
		$LStrFoc="document.getElementById('TxtCod').focus();";						
		$StrGT="S";	
		$StrVuelto="0.0";
		$StrPagarCon="0";
	}	
	//
	if($StrCmd=="ADD"){	
		$StrVuelto="0.0";
		$StrPagarCon="0";	
		if($StrPro_ID==0){
			$LStrMsg="No se puede determinar el ID del producto";
			$LStrFoc="document.getElementById('TxtCod').focus();";						
			$StrGT="S";			
		}
		if(strlen($StrGT)==0){
			if($StrPro_CA==0){
				$LStrMsg="La cantidad debe ser mayor a cero";
				$LStrFoc="document.getElementById('TxtCant').focus();";						
				$StrGT="S";							
			}
		}
		if(strlen($StrGT)==0){
			if(gn("count(*)","temp_compras",
				  "temc_id_producto=$StrPro_ID AND cod_temc='$StrHWND_G'")>0){
				$LStrMsg="El producto que desea agregar ya se encuentra en la lista";
				$LStrFoc="document.getElementById('TxtCod').focus();";						
				$StrGT="S";	
			}
		}
		
		if(strlen($StrGT)==0){
			$StrImporte=round($StrPro_CA * $StrPro_PR,2);
			$StrIndex=GenId("temc_index","temp_compras");
			$s="INSERT INTO temp_compras VALUES ('$StrHWND_G',
				$StrPro_ID,$StrPro_CA,0,0,
				$StrIndex,'$StrCod','$StrDes',$StrCUni)";
			ejt($s);
			$StrCant="";
			$StrPre="";
			$StrCli="";
			$StrMARCA="";
			$StrCod="";
			$StrImp="";
			$Pro_Des="";
			$StrDes="";
			$Pro_Pre="";
			$Pro_Cod="";
			$Pro_Marca="";
			$StrCUni="";
			$LStrFoc="document.getElementById('TxtCod').focus();";						
			$StrGT="S";	
		}
	}	
	//------------------------------------------------------+++
	if(($StrCmd=="G" || $StrCmd=="M") && strlen($StrGT)==0){					
		$StrAlm_=gn("id_almacen","almacenes","alm_obs='$StrAlm'");
		$iStrSerR=vbval($StrSerR);
		$iStrNumR=vbval($StrNumR);	
		$EmpR_=gn("id_emp","empresas","emp_nomc='$StrEmpR'");		
		$COT_=gn("ID_COT","vix_cotizaciones","SER_=$iStrSerR AND NUM_=$iStrNumR AND ID_EMP=$EmpR_");
		$CLI_=0;//gn("id_cliente","cotizaciones","id_cotizacion=$IDC");	
		if(gn("count(*)","temp_compras","cod_temc='$StrHWND_G'")==0){
			$LStrMsg="La lista de productos esta vacia";
			$LStrFoc="document.getElementById('TxtCod').focus();";						
			$StrGT="S";
		}
	}	
	//FUNCIONES DE ACTUALIZACION
	if($StrCmd=="G" && strlen($StrGT)==0){			
		if($StrN_AUTO=="1"){
			//GI_GEN_NUM_MAX($StrAlm_,$StrNum,$StrSer);	
			GI_GEN_NUM_MAX_23($StrAlm_,$StrNum,$StrSer);	
		}
		$iStrNum=vbval($StrNum);
		$iStrSer=vbval($StrSer);
		if(gn("count(*)","ginterna","gi_id_alm=$StrAlm_ AND gi_inum=$iStrNum AND gi_iserie=$iStrSer")>0){
			$LStrMsg="GUIA INTERNA segun almacen, numero ya registrados";			
			$LStrFoc="document.getElementById('TxtNum').focus();";						
			$StrGT="S";
		}
	}
	if($StrCmd=="G" && strlen($StrGT)==0){
		//PARSE ANTES DE VALIDAR
		FxCOT_PARSE_CANTIDADES($COT_);
		//PARSE ANTES DE VALIDAR
		//VALIDAR QUE LAS CANTIDADES SEAN LAS CORRECTAS (ca_control - dej)=CAN_DIS
		$s="SELECT temc_id_producto as IDP,temc_cant as CAN,dscto as UNI  
			FROM temp_compras WHERE cod_temc='$StrHWND_G' ORDER BY temc_index";
		$result = grs($s);			
		while ($row = $result->fetch_assoc()){
			$_IDP=$row['IDP'];
			$_UNI=$row['UNI'];
			$_CAN=$row['CAN'];			
			$_KAN=gn("ca_control - dej","cotizaciones_det",
					 "id_cotizacion=$COT_ AND id_producto=$_IDP AND can_uni=$_UNI");
			if($_CAN>$_KAN){
				$_COD=gs("pro_codigo","productos","id_producto=$_IDP");
				$LStrMsg="CANTIDAD SUPERIOR : $_COD x $_UNI , cantidad maxima a emitir : $_KAN";			
				$LStrFoc="document.getElementById('TxtNum').focus();";						
				$StrGT="S";
				break;
			}
		}		
	}
	if($StrCmd=="G" && strlen($StrGT)==0){
		$StrFec_=ToDate($StrFec);		
		$GII=GenGI();
		//		
		$CORRE=1;
		$StrId=GenId("id_gi","ginterna");
		$s="INSERT INTO ginterna VALUES ($StrId,$StrAlm_,$iStrNum,
			'$StrNum','$StrFec_',$CLI_,'$StrCli',$COT_,
			'$StrSerR','$StrNumR','N',".GetIDU().",$GII,'$StrSer',$iStrSer,'$StrCar',$CORRE)";
	 	ejt($s);
		//++
		$_BIT_MOD_ID=$StrId;
		$_BIT_SQL_CAB=$s;
		$_BIT_SQL_DET="";
		$_BIT_PHP="guia_interna.php";
		$_BIT_ID=BIT_ADD("ALMACEN","GUIA INTERNA","GUARDAR",$_BIT_MOD_ID,$_BIT_SQL_CAB,$_BIT_SQL_DET,$_BIT_PHP);
		BIT_DET_ADD($_BIT_ID,$s);	
		//++
		$qqq=ejt("DELETE FROM ginterna_det WHERE id_gi=$StrId");
		//++
		BIT_DET_ADD($_BIT_ID,$qqq);	
		//++
		$s="SELECT temc_id_producto,temc_cant,cod,des,dscto
			FROM temp_compras WHERE cod_temc='$StrHWND_G' 
			ORDER BY temc_index";
		$result = grs($s);			
		$cx=0;			
		while ($row = $result->fetch_row()){
			$cx++;
			$G_ID=$row[0];
			$G_CA=$row[1];
			$G_CO=$row[2];
			$G_DE=$row[3];
			$G_CU=$row[4];
			$ss="INSERT INTO ginterna_det ".
			    "VALUES ($StrId,$cx,$G_ID,$G_CA,'$G_CO','$G_DE',$G_CU,$G_CA)";
			ejt($ss);
			//++
			BIT_DET_ADD($_BIT_ID,$ss);	
			//++		
			STOCK_SUB($StrAlm_,$G_ID,$G_CA * $G_CU);
			//ZTOCK_SUB($StrAlm_,$G_ID,$G_CA,$G_CU);
			if(gn("count(*)","vis_sp","ID_PRO=$G_ID AND PIE=$G_CU")>0){
				ZTOCK_SUB($StrAlm_,$G_ID,$G_CA,$G_CU);
			}else{
				ZTOCK_SUB_P($StrAlm_,$G_ID,$G_CA,$G_CU);
			}			
			//
			$_IDP=$G_ID;
			$_CAN=$G_CA;
			$_UNI=$G_CU;
			CONTROL(-3,$COT_,$_IDP,$_CAN,$_UNI);
			//
			T_P_ACT($G_ID);
		}
		//FV_VEN_INI
		FxCOT_PARSE_CANTIDADES($COT_);
		FUN_COT_UPDATE($COT_);
		//FV_VEN_FIN			
		if(strlen($LStrMsg)==0){
			$LStrMsg="Los datos han sido registrado: GUIA INTERNA : $StrSer - $StrNum";
		}
		$LStrFoc="document.getElementById('$P_C').focus();";						
		$StrGT="S";		
	}
	
	if($StrCmd=="E"){
		$_IR=gn("gi_id_cotizacion","ginterna","id_gi=$StrId");					
		$IdComR_=-3;
		$StrAlm_=gn("gi_id_alm","ginterna","id_gi=$StrId");	
		//
		$_ID=gn("count(*)","guias","id_comr=-2 AND id_ref=$StrId AND anu='N'");
		if($_ID>0){
			$LStrMsg="El presente registro esta relacionado a una ".
			         "GUIA DE REMISION por lo tanto no se ELIMINAR";			
			$LStrFoc="document.getElementById('$P_C').focus();";						
			$StrGT="S";
		}
		//
		if(strlen($StrGT)==0){
			if($POL_ELI==0){
				$LStrMsg="El presente usuario no tiene permisos para eliminar una guia interna";			
				$LStrFoc="document.getElementById('$P_C').focus();";						
				$StrGT="S";
			}
		}
		//
		if(strlen($StrGT)==0){
			$s="SELECT id_producto as IDP,ca as CAN,can_uni as PIE ".
			   "FROM ginterna_det WHERE id_gi=$StrId";
			$result = grs($s);			
			while ($row = $result->fetch_assoc()){
				$E_IDP=$row['IDP'];
				$E_CAN=$row['CAN'];
				$E_PIE=$row['PIE'];
				$TOT_DEV=gn("SUM(CAN)",
							"vdevoluciones_full",
						    "ANU='N' AND TIP='D' AND ".
							"ID_COM=-3 AND ID_REF=$_IR AND ".
							"IDP=$E_IDP AND PIE=$E_PIE");
				$TOT_SAL=gn("SUM(CAN)","vgiainterna_full",
						    "ANU='N' AND ID_COT=$_IR AND ".
							"IDP=$E_IDP AND PIE=$E_PIE");
				if($TOT_DEV > ($TOT_SAL - 	$E_CAN)){
					$LStrMsg="STOCK INSUFICIENTE, se ha registrado una o ".
					         "mas devoluciones para el producto : ".
							 gs("DESCRIPCION","vproductos","ID=".$E_IDP);			
					$LStrFoc="document.getElementById('$P_C').focus();";						
					$StrGT="S";
					break;
				}
			}
		}
		//		
		if(strlen($StrGT)==0){						
			$s="SELECT id_producto,ca,can_uni FROM ginterna_det WHERE id_gi=$StrId";
			$result = grs($s);			
			while ($row = $result->fetch_row()){
				$E_ID=$row[0];
				$E_CA=$row[1];
				$E_CU=$row[2];						
				STOCK_ADD($StrAlm_,$E_ID,$E_CA*$E_CU);
				ZTOCK_ADD($StrAlm_,$E_ID,$E_CA,$E_CU);			
				CONTROLZ($IdComR_,$_IR,$E_ID,$E_CA,$E_CU);
				T_P_ACT($E_ID);
			}
			//FV_VEN_INI
			//FxCOT_PARSE_CANTIDADES($_IR);
			//FUN_COT_UPDATE($_IR);
			//FV_VEN_FIN
			$qqq=ejt("DELETE FROM ginterna_det WHERE id_gi=$StrId");
			//BIT
			$_BIT_MOD_ID=$StrId;
			$_BIT_SQL_CAB=$qqq;
			$_BIT_SQL_DET="";
			$_BIT_PHP="guia_interna.php";
			$_BIT_ID=BIT_ADD("ALMACEN","GUIA INTERNA","ELIMINAR",$_BIT_MOD_ID,$_BIT_SQL_CAB,$_BIT_SQL_DET,$_BIT_PHP);
			BIT_DET_ADD($_BIT_ID,$qqq);
			//BIT	
			$qqq=ejt("DELETE FROM ginterna WHERE id_gi=$StrId");
			BIT_DET_ADD($_BIT_ID,$qqq);
			//
			ejt("DELETE FROM temp_compras WHERE cod_temc='$StrHWND_G'");
			//FV_VEN_INI
			FxCOT_PARSE_CANTIDADES($_IR);
			FUN_COT_UPDATE($_IR);
			//FV_VEN_FIN
			$LStrMsg="Los datos han sido eliminados";
			$LStrFoc="document.getElementById('$P_C').focus();";						
			$StrGT="S";
			//
			$LIMPIAR=1;
		}
	}	
	//
	if($StrCmd=="A"){
		$_ID=gn("count(*)","guias","id_comr=-2 AND id_ref=$StrId AND anu='N'");
		if($_ID>0){
			$LStrMsg="El presente registro esta relacionado a una ".
			         "GUIA DE REMISION por lo tanto no se ANULAR";			
			$LStrFoc="document.getElementById('$P_C').focus();";						
			$StrGT="S";
		}
		if(strlen($StrGT)==0){
			$_IR=gn("gi_id_cotizacion","ginterna","id_gi=$StrId");					
			$IdComR_=-3;
			$StrAlm_=gn("gi_id_alm","ginterna","id_gi=$StrId");					
			$s="SELECT id_producto,ca,can_uni FROM ginterna_det WHERE id_gi=$StrId";
			$result = grs($s);			
			while ($row = $result->fetch_row()){
				$E_ID=$row[0];
				$E_CA=$row[1];
				$E_CU=$row[2];						
				STOCK_ADD($StrAlm_,$E_ID,$E_CA*$E_CU);
				ZTOCK_ADD($StrAlm_,$E_ID,$E_CA,$E_CU);			
				CONTROLZ($IdComR_,$_IR,$E_ID,$E_CA,$E_CU);
				T_P_ACT($E_ID);
			}
			//FV_VEN_INI
			//FxCOT_PARSE_CANTIDADES($_IR);
			//FUN_COT_UPDATE($_IR);
			//FV_VEN_FIN
			$qqq=ejt("UPDATE ginterna SET gi_anu='S' WHERE id_gi=$StrId");
			//BIT
			$_BIT_MOD_ID=$StrId;
			$_BIT_SQL_CAB=$qqq;
			$_BIT_SQL_DET="";
			$_BIT_PHP="guia_interna.php";
			$_BIT_ID=BIT_ADD("ALMACEN","GUIA INTERNA","ANULAR",$_BIT_MOD_ID,$_BIT_SQL_CAB,$_BIT_SQL_DET,$_BIT_PHP);
			BIT_DET_ADD($_BIT_ID,$qqq);
			//BIT	
			//FV_VEN_INI
			FxCOT_PARSE_CANTIDADES($_IR);
			FUN_COT_UPDATE($_IR);
			//FV_VEN_FIN
			ejt("DELETE FROM temp_compras WHERE cod_temc='$StrHWND_G'");
			$LStrMsg="La guia ha sido anulada";
			$LStrFoc="document.getElementById('$P_C').focus();";						
			$StrGT="S";
			//
			$LIMPIAR=1;
		}
	}
	if($LIMPIAR==1){
		$StrId="";
		$StrAlm="";
		$StrSer="";
		$StrNum="";
		$StrSer="";
		$StrFec=date("d-m-y");
		$StrCli="";	
		$StrSerR="";
		$StrNumR="";
		$StrComR="";
		$Pro_Des="";
		$Pro_Pre="";
		$Pro_Cod="";
		$Pro_Marca="";	
		$StrCUni="";
		$StrDesDNI="";	
		$DR_NOM="";
		$DR_DES="0";
		$DR_PRI="0";
		$StrCar="";
	}
	//////////////////////////////////
	if($StrGT=="S"){
		if(strlen($LStrMsg)>0){
			if(strlen($LStrFoc)==0){
				if($StrN_AUTO=="0"){
					$LStrMsg="onload=\"alert('$LStrMsg');\"";
				}else{
					$LStrMsg="onload=\"alert('$LStrMsg');AutoNumeracion(2);\"";
				}
			}else{
				if($StrN_AUTO=="0"){
					$LStrMsg="onload=\"alert('$LStrMsg');$LStrFoc;\"";
				}else{
					$LStrMsg="onload=\"alert('$LStrMsg');$LStrFoc;AutoNumeracion(2);\"";
				}
			}
		}else{
			if(strlen($LStrFoc)>0){
				if($StrN_AUTO=="0"){
					$LStrMsg="onload=\"$LStrFoc;\"";
				}else{
					$LStrMsg="onload=\"$LStrFoc;AutoNumeracion(2);\"";
				}
			}
		}
	}else{
		if($StrN_AUTO=="1"){
			$LStrMsg="onload=\"AutoNumeracion(2);document.getElementById('$P_C').focus();\"";
		}else{
			$LStrMsg="onload=\"document.getElementById('$P_C').focus();\"";
		}
	}
?>