File: /home/asjudine/www/facturacion_nueva_exportar.php
<?php
global $dbi;
$linea = '-';
require_once("../Conectarse.php");
//NUMERO CONSECUTIVO
//$maximo = mysql_query('SELECT MAX(consecutivo) FROM facturacion ');
//list($consecutivo)=mysql_fetch_row($maximo);
//if($consecutivo==0){$consecutivo=1;}
//else{$consecutivo++;}
$busca_facturacion = mysql_query("SELECT factura, fecha, valor, letra_tota, consecutivo FROM facturacion WHERE nit = '".$_GET["cedula"]."' and numero_contrato = '".$_GET["numcon"]."' ");
if (!$busca_facturacion) {
die('Invalid query: ' . mysql_error());
}
list($factura, $fecha, $valor, $letra, $consecutivo) = mysql_fetch_row($busca_facturacion);
$factu = mysql_query('SELECT MAX(factura) FROM facturacion ');
if (!$factu) {
die('Invalid query: ' . mysql_error());
}
list($ides) = mysql_fetch_row($factu);
$ides = $ides + 1 ;
$control = mysql_query('SELECT cedula, nombre, direccion, codigo_sucursal, valorcuota, fecha_ultimo_registro FROM cartera_serviasjudinet WHERE cedula = "'.$_GET["cedula"].'" and numerocontrato = "'.$_GET["numcon"].'" ');
if (!$control) {
die('Invalid query: ' . mysql_error());
}
list($nit, $razon, $direccion, $ciudad, $valorcuota, $fecha_ultimo_registro) = mysql_fetch_row($control);
$resultado1 = round($valorcuota / 1.19);
$resultado2 = round($resultado1 * 0.19);
$resultadofinal = $resultado1 + $resultado2;
$separa = explode("-",$fecha_ultimo_registro);
$ano = $separa[0];
$mes = $separa[1];
$dia = $separa[2];
switch($mes){
case 1:
$elmes = "ENERO";
break;
case 2:
$elmes = "FEBRERO";
break;
case 3:
$elmes = "MARZO";
break;
case 4:
$elmes = "ABRIL";
break;
case 5:
$elmes = "MAYO";
break;
case 6;
$elmes = "JUNIO";
break;
case 7:
$elmes = "JULIO";
break;
case 8:
$elmes = "AGOSTO";
break;
case 9:
$elmes = "SEPTIEMBRE";
break;
case 10:
$elmes = "OCTUBRE";
break;
case 11:
$elmes = "NOVIEMBRE";
break;
case 12:
$elmes = "DICIEMBRE";
break;
}
if ($ciudad > 0)
{
$sucurs = mysql_query('SELECT nombre FROM sucursal WHERE codigo = "' ."$ciudad". '" ');
if (!$sucurs) {
die('Invalid query sucurs: ' . mysql_error());
}
list($ciudad) = mysql_fetch_row($sucurs);
}
$mssql = mysql_query('SELECT vendedor FROM vendedores WHERE codigo = "' . "$ase". '" ');
if (!$mssql) {
die('Invalid query: ' . mysql_error());
}
list($asesor) = mysql_fetch_row($mssql);
$mssql1 = mysql_query('SELECT nombre FROM sucursal WHERE codigo = "' . "$sucu". '" ');
if (!$mssql1) {
die('Invalid query: ' . mysql_error());
}
list($sucursal) = mysql_fetch_row($mssql1);
$sql = mysql_query('SELECT * FROM sucursal order by nombre ');
if (!$sql) {
die('Invalid query 12: ' . mysql_error());
}
$row_sql = mysql_fetch_assoc($sql);
$totalRows_sql = mysql_num_rows($sql);
$sql7 = mysql_query('SELECT * FROM planes_contratos order by codigo_contrato ');
if (!$sql7) {
die('Invalid query: ' . mysql_error());
}
$row_sql7 = mysql_fetch_assoc($sql7);
$totalRows_sql7 = mysql_num_rows($sql7);
$sql4 = mysql_query('SELECT * FROM vendedores WHERE tipo = "AE" and estado = "1" order by vendedor ');
if (!$sql4) {
die('Invalid query: ' . mysql_error());
}
$row_sql4 = mysql_fetch_assoc($sql4);
$totalRows_sql4 = mysql_num_rows($sql4);
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Ingreso Personas Juridicas</title>
<style type="text/css">
<!--
.est_cont5 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
font-style: normal;
font-weight: normal;
background-color: #EDFAF4;
margin: 2px;
padding: 2px;
height: auto;
width: auto;
border: thin groove #E9AAF0;
color: #C72350;
}
.color_fondo_sc {
background-color: #DCE0E4;
}
.est_cont2 {
font-family: Geneva, Arial;
font-size: 12px;
font-style: normal;
font-weight: normal;
background-color: #FFFFFF;
height: 18px;
width: auto;
}
.est_cont8 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 13px;
font-style: normal;
font-weight: normal;
color: #2B39EC;
background-color: #FFFFFF;
height: 19px;
width: auto;
border: thin solid #FABF85;
}
.est_cont6 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 11px;
font-style: normal;
font-weight: normal;
color: #006262;
background-color: #EDFED3;
margin: 1px;
padding: 1px;
height: auto;
width: auto;
border: thin solid #D9B6F8;
}
.sol_cre1 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 12px;
font-style: normal;
font-weight: normal;
color: #0B3495;
background-color: #E6FAFF;
margin: 1px;
padding: 1px;
height: 15px;
width: auto;
border: thin outset #56AD95;
}
.col_cre2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
font-weight: bold;
color: #F92F0B;
background-color: #B3D9F0;
height: auto;
width: auto;
border: medium groove #FC9227;
}
.recaudo {font-family: "Courier New", Courier, monospace;
font-size: 12px;
font-style: normal;
font-weight: bold;
font-variant: normal;
color: #000000;
background-color: #B6CBDC;
margin: 4px;
padding: 8px;
width: auto;
border: medium outset #339966;
}
.sol_cre11 { font-family: "Times New Roman", Times, serif;
font-size: 12px;
background-color: #FFFFFF;
}
.est_cont51 { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
font-style: normal;
font-weight: normal;
background-color: #FFFFCC;
margin: 2px;
padding: 2px;
height: auto;
width: auto;
border: thin groove #E9AAF0;
color: #C72350;
}
.Estilo68 {
color: #CC0000;
font-weight: bold;
}
.Estilo69 {
color: #FF0000;
font-size: 24px;
}
.Estilo70 {font-size: 10px}
.Estilo71 {
font-size: 10;
font-weight: bold;
}
.Estilo72 {font-size: 10}
.Estilo73 {font-size: 10; font-family: Geneva, Arial; }
.Estilo74 {font-style: normal; font-weight: normal; background-color: #FFFFFF; height: 18px; width: auto; font-family: Geneva, Arial;}
-->
</style>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data" name="form1" class="color_fondo_sc" id="form1">
<div align="center" class="Estilo69" ><strong> INTER@SJUDINET LTDA</strong></div>
<table width="692" height="323" border="" align="center" cellpadding="" cellspacing="" class="sol_cre11">
<caption>
<div align="center"><br />
INTERAMERICANA DE SERVICIOS JURIDICOS LIMITADA<br />
<span class="Estilo70">Nit. 901.165.062-3 - I.V.A REGIMEN COMUN<br />
ACTIVIDAD ECONOMICA 6910 TARIFA 6.9 X 1000<br />
Resolución Dían No. 18762007847494 de 2018/04/18<br />
Calle 19 No. 6 - 68 - Piso 9 - Tels: 2438820 - 2438870 - Bogotá, D.C.</span> <br />
<br />
</div>
</caption>
<tr>
<td ><span class="Estilo71"> Bogotá D.C. </span></td>
<th width="408" align="center"> <span class="Estilo72"><strong>Fecha Factura </strong>
<input name="fecha" type="text" class="est_cont2" id="fecha" value="<?php echo $fecha ?>" size="10" maxlength="10" />
</span></th>
<td colspan="2" align="center"><div class="Estilo68 Estilo72">FACTURA DE VENTA</div></td>
<td width="120" align="center">
<input name="consecutivo" type="text" class="Estilo73" id="consecutivo" value="<?php echo $consecutivo ?>" size="10" maxlength="10" readonly=""/>
<input name="factu" type="text" class="Estilo73" id="factu" value= "PS - <?php echo $ides ?>" size="10" maxlength="10" readonly=""/> </td>
</tr>
<td width="78" ><div align="right" class="Estilo72"><strong>Vendido a</strong></div></td>
<td colspan="2"><div align="left" class="Estilo72">
<input name="razon" type="text" class="Estilo74" id="razon" value="<?php echo $razon ?>" size="65" maxlength="65" />
</div></td>
<td width="85" height="21"><div align="right" class="Estilo72"><strong>Nit</strong></div></td>
<td width="120"><div align="left" class="Estilo72">
<input name="nite" type="text" class="Estilo74" id="nite" value="<?php echo $nit ?>" size="20" maxlength="20" readonly=""/>
</div></td>
</tr>
<tr> </tr>
<tr>
<td><div align="right" class="Estilo72"><strong>Direccion </strong></div></td>
<td colspan="2"><div align="left" class="Estilo72">
<input name="diret" type="text" class="Estilo74" id="diret" value="<?php echo $direccion ?>" size="65" maxlength="65" />
</div></td>
<th scope="col"><div align="right" class="Estilo72"><strong>Ciudad</strong></div></th>
<td ><input name="ciudad" type="text" class="Estilo73" id="ciudad" value="<?php echo $ciudad ?>" size="15" maxlength="15" /></td>
</tr>
<tr>
<td colspan="4"><div align="CENTER" class="Estilo68 Estilo72">DETALLE </div></td>
<td ><div align="CENTER" class="Estilo68 Estilo72">VALOR </div></td>
</tr>
<tr >
<th colspan="4" align="center"> <span class="Estilo72">
<textarea name="detalle" cols="80" rows="5" >Facturación del mes <?php echo $elmes ?> del año <?php echo $ano ?></textarea>
</span> </th>
<th><input name="valor" type="text" class="Estilo73" id="valor" value="<?php echo $resultado1 ?>" size="20" maxlength="25" align="right" /></th>
</tr>
<tr>
<td ><div align="right" class="Estilo72"><strong>SON</strong></div></td>
<td colspan="3"><input name="son" type="text" class="Estilo73" id="son" value="<?php echo $letra ?>" size="84" maxlength="84" /></td>
</tr>
<tr>
<td colspan="3" rowspan="6" align="center" ><span class="Estilo72"><strong> Esta Factura de venta se asimila en todos sus efectos a una Letra de Cambio segun articulo 774 de Codigo de Comercio
.</strong></span></td>
</tr>
<td ><div align="right" class="Estilo72"><strong>I.V.A </strong></div></td>
<td><div align="center" class="Estilo72">
<input name="iva" type="text" class="Estilo74" id="iva" size="20" maxlength="25" aalign="right" value="<?php echo $resultado2 ?>" />
</div></td>
</tr>
<span class="Estilo72">
</tr>
</span>
<td ><div align="right" class="Estilo72"><strong>RETENCION </strong></div></td>
<td><div align="center" class="Estilo72">
<input name="retencion" type="text" class="Estilo74" id="retencion" value="" size="20" maxlength="25" align="right" />
</div></td>
</tr>
<tr>
<td ><div align="right" class="Estilo72"><strong>TOTAL </strong></div></td>
<td><div align="center" class="Estilo72">
<input name="total" type="text" class="Estilo74" id="total" size="20" maxlength="20" align="right" value="<?php echo $resultadofinal ?>" />
</div></td>
</tr>
</table>
<P align="center">
<input name="guardar" type="submit" class="Estilo68" value ="EXPORTAR" >
</P>
</form>
</body></html>
<?php
if(isset($_POST["guardar"]))
{
$total = $_POST["total"];
/*$micarpeta = 'archivosfacturacion';
if (!file_exists($micarpeta)) {
mkdir($micarpeta, 0777, true);
}
$salida = $micarpeta."/archivo.txt";
header('Content-Type: text/plain');
header('Content-Disposition: attachment;filename='.$salida);
header('Cache-Control: no-cache, no-store, must-relative');
header('Pragma: no-cache');
header('Expires: 0');
$output = fopen($salida, 'w') or die("Error al crear");
fread($output);
fwrite($output,$total);
fwrite($output, "\r\n");
fclose($output);
exit;
*/
$inser2= mysql_query("UPDATE facturacion SET estado = 1 WHERE nit = '".$_GET["cedula"]."' and numero_contrato = '".$_GET["numcon"]."' ");
if (! $inser2) {
die('Invalid inser2 : ' . mysql_error());
}
echo "<script>alert('Exportada Factura con exito');</script>";
echo "<script languaje='javascript'>window.close();</script>";
}
?>