<?php
ini_set("session.cookie_lifetime",60*60*10);
ini_set("session.gc_maxlifetime", 60*60*10);
session_start();	
//-------------------------	
include("cls_conexion.php");$CNN=new ClsMySQL();include("conexion23.php");	
if(strlen($_SESSION['SYS_USER_ID'])==0){JsDir("login.php");	return;}
//
if(vbval($_SESSION['SYS_USER_GI'])!=USU_GET_GI($_SESSION['SYS_USER_ID'])){
JsDir("cerrar.php");	
return;
}
//
$StrGT="";
$VP_RegXPag=10;
$LStrMsg="";
$LStrFoc="";
$LStrMM="";
$LStrPag=V($_POST['TxtPag']);	
//
$CLS="";

include("cotizacionez_fun.php");
//
$StrHWND_COT=$_SESSION['SYS_HW']."_KOT";
/////////////////////////////////////////

if($CLS=="S"){
	$StrId="";
	$StrNew="NO";
	$StrFec=date("d-m-y");
	$StrSer="";
	$StrNum="";
	$StrCliente="";
	$StrIdCliente="0";
	$StrRuc="";
	$StrN_INC="";
	$StrCod="";
	$StrDes="";
	$StrPre="";
	$StrCant="";
	$StrImp="";
	$StrTotal="";
	$StrContacto="";
	$StrNPed="";
	$StrDscto="";
	$StrCUni="";
	$Pro_TxtDes="";
	$Pro_TxtPre="";
	$Pro_TxtPreM="";
	$Pro_TxtCod="";
	$Pro_TxtMarca="";	
	$Str_DES="";
	$Str_VER="";
	$StrSto="";	
	$StrAcu="";
	$StrTdp="CONTADO";
	$StrMon="SOLES";
	$StrVue="0.0";
	$StrSal="0.0";
	$DR="0";
	$StrTReal="";
	$StrTDes="";
}
/////////////////////////////////////////
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=\"document.getElementById('CboAlm').focus();AutoNumeracion(2);\"";
}else{
$LStrMsg="onload=\"document.getElementById('CboAlm').focus();\"";
}
}
/////////////////////////////////////////
$PRO_NL=gn("nl","doc_nl","doc='P'");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Proformas</title>
<link rel="stylesheet" type="text/css" href="estiloss.css"  />
<link rel="stylesheet" type="text/css" href="basic.css"  />
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="jquery.maskedinput.min.js" type="text/javascript"></script>
<script type="text/javascript" src="fe/cotizacionez.js"></script>
<script type="text/javascript" src="fe/funciones.js"></script>
<script>
$(document).ready(function(){
   $("#TxtFec").mask("99-99-99");  
   CalcularVuelto(); 
});
</script>
<script>
var myVar=setInterval(function(){myTimer()},500);
function myTimer(){
t=GetHora();
tt=document.getElementById("TxtHora").value;
if(tt>0){
if(t-tt>=1){
document.getElementById("TxtHora").value=0;
fGetTabla();			
}
}
}
function myStopFunction(){
clearInterval(myVar);
}

//
function Verificar(){
	var DATA="";
	document.getElementById("TxtDAT").value="";
	frm = document.getElementById("Frm");
	if (!frm) return;
	for(i=0; i<frm.elements.length; i++)
	{
		if (frm.elements[i].type == "checkbox")	{
			if(frm.elements[i].name.substring(0,1)=="Z"){
				if(frm.elements[i].checked==true){
					var ok=frm.elements[i].name;
					ok=ok.substring(2,7);
					DATA=DATA+ok+",";
				}
			}
		}
	}	
	if(jLen(DATA)==0){
		alert("Ningun registro seleccionado, seleccione un registro marcando el check correspondiente");
		return 0;
	}else{		
		document.getElementById("TxtDAT").value=DATA;
		return 1;
	}
}
function ChK(){
	var DR=gv("TxtDR");
	if(jVal(DR)>0){
		alert("El presente registro ha sido tomando "+
			  "como referencia, por lo tanto NO SE PUEDE ELIMINAR");		
	}else{
		if(Verificar()==1){		
			document.getElementById("TxtAc").value="KCH";
			document.getElementById("Frm").submit();	
		}
	}
}
//

</script>

<style type="text/css">
<!--
.estilo888 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #003366;
font-weight: bold;
}
#TAB_CAPTION .estilo888 {
color: #000;
}
-->
</style>
<style type="text/css">
<!--
.estilo777 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #003366;
}
-->
</style>
<style type="text/css">
<!--
body {
background-color: #CCC;
background-image: url();
}
#Layer1 {
position:absolute;
left:345px;
top:115px;
width:123px;
height:35px;
z-index:1;
}
.centrarFrm{
width:1040px;
height:800px;
position:absolute;
left:<?php echo "50%";?>;
top:<?php echo "30%";?>;
background-color:#006699;
margin:<?php echo "-200px";?> 0 0 <?php echo "-520px";?>;
}
#Layer2 {
position:absolute;
left:409px;
top:205px;
width:82px;
height:24px;
z-index:1;
}
.Estilo1 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FFFFFF;
}
.s22 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; color: #FFFFFF; font-size: 12px; }
.sFA {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF3;
font-size: 12px;
}
.Estilo3 {color: #FFFFFF; font-size: 12px; font-family: Arial, Helvetica, sans-serif;}
.s4 {color: #000099}
.Estilo5 {color: #000000}
#Frm center #DivFRM #layer .Estilo1 strong {
color: #900;
}
#Frm center #DivFRM #layer3 .s2 table tr td {
color: #000;
}
#Frm center #DivFRM #layer3 .s2 table tr td table tr td {
color: #FFF;
}
#Frm center #DivFRM #layer3 .s2 table {
color: #000;
}

-->
</style>

</head>
<body  <?php echo $LStrMsg;?> onunload="myStopFunction();">
<form id="Frm" name="Frm" method="post" action="cotizacionez.php" autocomplete="off">
<input name="TxtDR" type="hidden" id="TxtDR" value="<?php echo $DR;?>" />
<center> 
<div Id="DivFRM"  class="centrarFrm"  >

<div class="s1 " style="position:absolute; left: 33px; top: 85px; width: 995px;">

<input name="CmdB" type="button" id="CmdG" value="Modificar (precios)"

onclick="fGuardar();" style="width:150px" tabindex="31"/>
<input name="CmdB" type="button" id="CmdZ" 
value="Menu" onclick="fBuscar('menu.php');"  tabindex="39"/>
<input name="CmdX" type="button" value="Cerrar" onclick="window.close();" />
</div>


<div id="layer3" style="position:absolute; left: 34px; top: 289px; width: 969px; height: 304px; overflow:auto">
<div align="left" class="s22">
<table width="969" height="45" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="119" height="17" bgcolor="#999999" style="color:#000000">CODIGO</td>
<td width="444" bgcolor="#999999" style="color:#000000">DESCRIPCION</td>
<td width="125" bgcolor="#999999" style="color:#000000">LINEA</td>
<td width="43" bgcolor="#999999" align="right" style="color:#000000">CANT</td>
<td width="44" bgcolor="#999999" align="right" style="color:#000000">PIEZAS</td>
<td width="56" bgcolor="#999999" align="right" style="color:#000000">PRECIO</td>

<td width="60" bgcolor="#999999" align="right" style="color:#000000">IMPORTE</td>
<td width="20" bgcolor="#999999" align="center" style="color:#000000">&nbsp;</td>
<td width="16" bgcolor="#999999" align="center" style="color:#000000">&nbsp;</td>
<td width="20" bgcolor="#999999" align="center" style="color:#000000">

</td>
</tr>
<?php
$s="SELECT * FROM temp_compras2 WHERE cod_temc='$StrHWND_COT' ORDER BY temc_index";
$result = grs($s);
$X_IMPORTE=0;
$X_ST=0;
$X_IG=0;
$X_TO=0;
$SEPARADOR=gs("aux_des","auxiliares","aux_tip='SIM'");
if(strlen($SEPARADOR)==0){$SEPARADOR="-";}
$TOT_NL=0;
while ($row = $result->fetch_row()){
	$TOT_NL++;
	$X_ID=$row[1];
	$X_CO=VV($row[6]);
	$X_DE=VV($row[7]);
	$X_MA=VV(gs("LINEA","vproductos","ID=$X_ID"));
	$X_CA=VV($row[2]);
	$X_CAU=VV($row[9]);
	$X_PR=NF(VV($row[3]),3);	
	$X_IM=NF(VV($row[4]),3);	
	//$X_DT=NF(VV($row[8]),1);
	$X_IMPORTE=$X_IMPORTE+$X_IM;
	$X_IM=number_format($X_IM,3,'.','');
	$CH="ZH".vbr("00000".$row[5],5);	
?>
    <tr>
    <td style="color:#000000" bgcolor="#FFFFFF"><?php echo $X_CO.$SEPARADOR.$X_CAU;?></td>
    <td style="color:#000000" bgcolor="#FFFFFF"><?php echo $X_DE;?></td>
    <td style="color:#000000" bgcolor="#FFFFFF"><?php echo $X_MA;?></td>
    <td style="color:#000000" bgcolor="#FFFFFF" align="right"><?php echo $X_CA;?></td>
    <td style="color:#000000" bgcolor="#FFFFFF" align="right"><?php echo $X_CAU;?></td>
    <td style="color:#000000" bgcolor="#FFFFFF" align="right"><?php echo $X_PR;?></td>
    <td style="color:#000000" bgcolor="#FFFFFF" align="right" ><?php echo $X_IM;?></td>
    <td style="color:#000000" bgcolor="#FFFFFF" align="center">
    
    
    </td>
    <td bgcolor="#FFFFFF" align="center">
    <a href="javascript:void(0)" onclick="fEditar('<?php echo $row[5];?>');" >
    <img src="img/b_edit.png"  border="0"/>
    </a>
    </td>
    <td width="20" bgcolor="#FFFFFF" align="center">&nbsp;</td>
    </tr>
<?php
}
?>
<tr>
<td colspan="6" bgcolor="#CCCCCC" align="right" style="color:#000000">TOT.IMPORTE</td> 
<td bgcolor="#CCCCCC"
align="right">
<input type="text" name="T_Importe" 
id="T_Importe"  
value="<?php echo number_format($X_IMPORTE,2,'.','');?>"
style="width:60px; border:none; text-align:right;position:inherit" 
readonly="readonly"
/>
<?php
	$StrTReal=$X_IMPORTE - vbval($StrTDes);
?>
</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
<td bgcolor="#CCCCCC" align="center">&nbsp;</td>
</tr>
<tr>
  <td colspan="10" bgcolor="#CCCCCC" align="right">&nbsp;</td>
  </tr>
<tr>
  <td colspan="10" bgcolor="#CCCCCC" align="right">
  <table width="100%" border="0">
    <tr>
      <td width="11%" style="color:#000">TOTAL IMPORTE</td>
      <td width="11%"  style="color:#000">TOT. DSCTO</td>
      <td width="12%" style="color:#000">TIPO DE PAGO</td>
      <td width="9%"  style="color:#000">A CUENTA</td>
      <td width="12%"  style="color:#000">MONEDA</td>
      <td width="12%" style="color:#000">MODALIDAD</td>
      <td width="9%" style="color:#000">VUELTO (S/.)</td>
      <td width="24%" style="color:#000">SALDO (S/.)</td>
     
    </tr>
    <tr>
<td>
<input type="text" name="TxtTReal" 
id="TxtTReal"   tabindex="27"
style="width:100px; text-align:right;position:inherit; "
onkeydown="return SoloNum(this,event,'TxtTDes');"
onfocus="selecciona_value(this);"
onkeyup="TReal();" value="<?php echo NF($StrTReal,2);?>" 
/>
</td>
<td>
<input type="text" name="TxtTDes" 
id="TxtTDes"   tabindex="27"
style="width:100px; text-align:right;position:inherit"
onkeydown="return SoloNum(this,event,'CboTdp');"
onfocus="selecciona_value(this);"
onkeyup="TDes();"
value="<?php echo NF(vbval($StrTDes),2);?>" 
/>
</td>
<td><select name="CboTdp" id="CboTdp" 
style="width:110px;position:inherit" 
onkeydown="return SoloTextoEx(event,'TxtACuenta');"
onchange="CalcularVuelto();"
tabindex="26" >
  <?php
echo FCBO_("tipp_nombre","tipos_pagos","tipp_nombre IN ('CONTADO','CREDITO')",$StrTdp,"N","N");
?>
</select></td>
<td>
<input type="text" name="TxtACuenta" 
id="TxtACuenta"   tabindex="27"
style="width:80px; text-align:right;position:inherit"
onkeydown="return SoloNum(this,event,'CboMon');"
onfocus="selecciona_value(this);"
onkeyup="CalcularVuelto();"
value="<?php echo $StrAcu;?>" 
/>
</td>
<td><select name="CboMon" id="CboMon" 
style="width:110px;position:inherit" 
onkeydown="return SoloTextoEx(event,'CboMod');"  
tabindex="28" onchange="CalcularVuelto();">
  <?php
echo FCBOOD_("mon_nombre","monedas","",$StrMon,"N","S","mon_nombre");
?>
</select></td>
<td><select name="CboMod" id="CboMod" 
style="width:110px;position:inherit" 
onkeydown="return SoloTextoEx(event,'CmdG');"  
tabindex="28" onchange="CalcularVuelto();">
  <?php
echo FCBOO_("au_item","auxiliar","au_tab='MODA'",$StrMod,"N","N","au_orden");
?>
</select></td>
<td><input type="text" name="TxtVuelto" 
id="TxtVuelto"  style="width:80px; text-align:right;position:inherit"
onkeydown="return SoloNum(this,event,'CboMon');"
onfocus="selecciona_value(this);" tabindex="29"
onkeyup="VUELTO();"
readonly="readonly"
value="<?php echo $StrVue;?>" 
/></td>
<td><input type="text" name="TxtSal" 
id="TxtSal"  style="width:80px; text-align:right;position:inherit"
readonly="readonly" tabindex="30"
value="<?php echo $StrSal;?>" 
/></td>
</tr>
</table></td>
</tr>
</table>
</div>
</div>
<div id="layer" style="position:absolute; left: 116px; top: 21px; width: 412px; height: 45px; z-index: 100;">
<div align="left" class="Estilo1">
<input type="button" name="CmdUP" id="CmdUP" value="UP" 
onclick="fLoad();" 
style="position:absolute; left: 83px; top: -282px; width: 49px; visibility:hidden"/>
<input name="TxtHW" type="hidden" id="TxtHW" value="<?php echo $StrHWND_COT;?>"/>

<input name="TxtId" type="hidden" id="TxtId" value="<?php echo $StrId;?>"/>
<input name="TxtDAT" type="hidden" id="TxtDAT" value="" />
<input name="TxtAc" type="hidden" id="TxtAc" value="" />

<input name="TxtPRO_NL" type="hidden" id="TxtPRO_NL" value="<?php echo $PRO_NL;?>" />
<input name="TxtTOT_NL" type="hidden" id="TxtTOT_NL" value="<?php echo $TOT_NL;?>" />

<input name="TxtDIR" type="hidden" id="TxtDIR" value="" />
<input name="TxtHora" type="hidden" id="TxtHora" value="0" />
<input name="TxtPag" type="hidden" id="TxtPag" value="<?php echo $LStrPag; ?>" />
<input name="TxtRuc_" type="hidden" id="TxtRuc_"  />
<input name="SerNum" type="hidden" id="SerNum"/>      
<input name="TxtIdCliente" type="hidden" id="TxtIdCliente" value="<?php echo $StrIdCliente; ?>"   />        
<strong>PROFORMAS (Modificar precios)</strong></div>
<div id="DivDatosProd">
<input name="Pro_TxtId" type="hidden" id="Pro_TxtId" value="<?php echo $StrPro_ID; ?>"/>
<input name="Pro_TxtDes" type="hidden" id="Pro_TxtDes" value="<?php echo $Pro_TxtDes; ?>"/>
<input name="Pro_TxtPre" type="hidden" id="Pro_TxtPre" value="<?php echo $Pro_TxtPre; ?>"/>
<input name="Pro_TxtPreM" type="hidden" id="Pro_TxtPreM" value="<?php echo $Pro_TxtPreM; ?>"/>
<input name="Pro_TxtCod" type="hidden" id="Pro_TxtCod" value="<?php echo $Pro_TxtCod; ?>"/>
<input name="Pro_TxtMarca" type="hidden" id="Pro_TxtMarca" value="<?php echo $Pro_TxtMarca; ?>"/>
<input name="FEC_SERVER" type="hidden" id="FEC_SERVER" value="<?php echo date("d-m-y");?>"/>  
</div>
</div>
<div id="LblTit" style="position:absolute; left: 52px; top: 15px; width: 64px; z-index: 100;">
<div align="left" class="Estilo1">
<img src="img/cotizaciones.png" width="64" height="53" / ></div>
</div>
<div id="layer8" 
style="position:absolute; left: 0px; top: 0px; width: 1040px; height: 79px; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000; z-index: 0;">
<div align="left" class="Estilo1">        
</div>
</div>

<div class="s1" style="position:absolute; left: 147px; top: 158px; width: 54px;">FECHA </div>


<input name="TxtFec" type="text" id="TxtFec"
style="left: 146px; top: 177px; width: 74px;background-color:#CCC" 
value="<?php echo $StrFec;?>"   readonly="readonly"
onkeydown="return SoloFec(this,event,'CboCom');" 
tabindex="2" />

<input name="TxtRuc" type="text" id="TxtRuc" 
style="left: 876px; top: 177px; width: 125px; background-color:#CCC" 
value="<?php echo $StrRuc;?>"  
tabindex="8" readonly="readonly" />

<input name="TxtNum" type="text" id="TxtNum" 
style="left: 401px; top: 177px; width: 76px;background-color:#CCC" 
value="<?php echo $StrNum;?>"   readonly="readonly"
tabindex="5" />

<div class="s1" style="left: 33px; top: 118px; width: 186px; height: 25px;">
DOCUMENTO PRINCIPAL
<?php
if($Str_PRI==1){
echo " (SI)";
}else{
echo " (NO)";
}
?>

</div>


<div class="s1" style="position:absolute; left: 33px; top: 158px; width: 123px;">PUNTO EMISION</div>
<input name="CboAlm" type="text" id="CboAlm" 
style="left: 33px; top: 177px; width: 100px; background-color:#CCC" 
value="<?php echo $StrAlm; ?>"   readonly="readonly"
tabindex="1" />



<div class="s1" style=" left: 235px; top: 158px; width: 109px;">COMPROBANTE</div>

<input name="CboCom" type="text" id="CboCom" 
style="left: 233px; top: 177px; width: 100px; background-color:#CCC" 
value="PROFORMA"   readonly="readonly"
tabindex="3" />

<div class="s1" style="left: 403px; top: 158px; width: 64px;">NUMERO</div>


<div class="s1" style="left: 543px; top: 157px; width: 61px;">CLIENTE</div>

<input type="text" name="TxtCliente" id="TxtCliente" 
value="<?php echo $StrCliente;?>" 
style="left: 543px; top: 177px; width: 327px; background-color:#CCC" readonly="readonly" 
tabindex="7"
/>
<div class="s1" style="left: 878px; top: 158px; width: 118px;">RUC </div>


<div class="s1" style="left:31px; top: 259px; width: 214px; height: 25px;">

<input name="ChN_INC" tabindex="16" type="checkbox" 
id="ChN_INC" value="1"  
<?php
if($StrN_INC=="1"){
echo "checked=\"checked\"";
}
?>
/>
EL PRECIO NO INCLUYE IGV</div>
<div class="s1" style="left: 486px; top: 159px; width: 49px;">T. C</div>

<input name="TxtTC" type="text" id="TxtTC" 
style="left: 486px; top: 177px; width: 43px; background-color:#CCC; text-align:right" 
value="<?php echo $StrTC;?>"  �
tabindex="6" readonly="readonly" />
<div class="s1" style=" left: 345px; top: 159px; width: 47px;">SERIE</div>

<input name="TxtSer" type="text" id="TxtSer" 
style="left: 346px; top: 177px; width: 47px;background-color:#CCC" 
value="<?php echo $StrSer;?>"   readonly="readonly"
tabindex="4" />
<div class="s1" style="left: 33px; top:205px; width: 189px;">CONTACTO</div>

<input name="TxtCon" type="text" id="TxtCon" 
class="ps" style="left: 33px; top: 225px; width: 305px;background-color:#CCC" 
value="<?php echo $StrContacto;?>"  
readonly="readonly"    
tabindex="9" />

<input name="CboVen" type="text" id="CboVen" 
class="ps" style="left: 349px; top: 225px; width: 305px;background-color:#CCC" 
value="<?php echo $StrVen;?>"  
readonly="readonly"    
tabindex="10" />

<div class="s1"  style="left: 349px; top:205px; width: 128px;">VENDEDOR</div>
</div>
</center>	
</form>
</body>
</html>