Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/02/2009, 09:47
antmegev
 
Fecha de Ingreso: septiembre-2008
Mensajes: 58
Antigüedad: 15 años, 7 meses
Puntos: 0
ayuda con pasar a pdf

necesito mucha ayuda, es que baje del hosting de el jefe este pequeño sistema, pero al momento de verlo en el pdf ya no se ve bien, se corre la fecha y tambien
la cantidad, unidad, descripcion, etc, salen juntitas, y no salen separadas como en el hosting, me podrian decir porque ha ocurrido esto?
me arrojaba algunos errores, pero era que solo tenia que redirigir algunas cosas
aqui esta el codigo

<?php
include_once('config.php');
include_once('include/cantidadTexto.class.php');
include_once('include/myMySQL.class.php');
include_once( $GLOBAL_Path_local . $GLOBAL_MySQL_conector );
$MySQL = new MySQL( $GLOBAL_MySQL_host, $GLOBAL_MySQL_usr, $GLOBAL_MySQL_pwd, $GLOBAL_MySQL_db );
$cantidadLetra = new EnLetras();

$id_venta_activa = 0;
$b_imprime_factura = $_GET["b_imprime_factura"]?$_GET["b_imprime_factura"]:0;

$vc_select_cliente = $_POST["ctrl_select_cliente"]?$_POST["ctrl_select_cliente"]:0;

// Si recibimos valores en estas variables por POST, guardar en BD y setearlas a 0 inmediatamente
$in_carga_cantidad = $_POST["in_carga_cantidad"]?$_POST["in_carga_cantidad"]:0;
$in_carga_unidad = $_POST["in_carga_unidad"]?$_POST["in_carga_unidad"]:0;
$in_carga_descripcion = $_POST["in_carga_descripcion"]?$_POST["in_carga_descripcion"]:'';
$in_carga_precio_unitario = $_POST["in_carga_precio_unitario"]?$_POST["in_carga_precio_unitario"]:0;
$in_carga_importe = $_POST["in_carga_importe"]?$_POST["in_carga_importe"]:0;

$in_carga_dia = $_POST["in_carga_dia"]?$_POST["in_carga_dia"]:date('d');
$in_carga_mes = $_POST["in_carga_mes"]?$_POST["in_carga_mes"]:date('m');
$in_carga_anio = $_POST["in_carga_anio"]?$_POST["in_carga_anio"]:date('Y');

$arr_clientes = array();
$arr_venta = array();
$arr_venta_articulo = array();
$values = array();
$v = array();

$arr_ventas_pdf = array();
$arr_clientes_pdf = array();
$dec_importe_pdf = 0;

$vc_nombre_cliente = '';
$vc_domicilio = '';
$vc_ciudad = '';
$vc_telefono = '';
$vc_rfc = '';

$id_last_insert_id = 0;

$dec_precio_subtotal = 0;
$dec_precio_iva = 0;
$dec_precio_total = 0;

$id_coordenada = 0;


function textJustify($dec_num, $int_spaces) {
if ( strlen(number_format($dec_num, 2, ".", ",")) <= $int_spaces ) {
return str_repeat(" ", $int_spaces - strlen(number_format($dec_num, 2, ".", ",")) ) . number_format($dec_num, 2, ".", ",");
} else { return strlen(number_format($dec_num, 2, ".", ",")) ; }
}
function intJustify($dec_num, $int_spaces) {
if ( strlen(trim($dec_num)) <= $int_spaces ) {
return str_repeat(" ", $int_spaces - strlen(trim($dec_num)) ) . trim($dec_num);
} else { return strlen(trim($dec_num)); }
}
function rightTextJustify ( $txt_texto, $int_spaces ) {
$txt_texto = substr( $txt_texto, 0, $int_spaces);
return $txt_texto . str_repeat( " ", $int_spaces - strlen($txt_texto) );
}

$vc_query = "select id_venta, id_cliente, b_status from tb_venta order by id_venta desc limit 1";
$MySQL->query( $GLOBAL_MySQL_host, $vc_query, 0 );
$arr_venta = $MySQL->arr;

// Impide cambiar de cliente si la venta está activa
if ( isset( $arr_venta ) && $arr_venta[0]["b_status"] == -1 ) {
//echo 'pasaste por aqui';
$id_venta_activa = $arr_venta[0]["id_venta"]; $vc_select_cliente = $arr_venta[0]["id_cliente"];
}

// Si no recibimos los campos de POST en 0 entonces guardamos los resultados y seteamos a 0
if ( $in_carga_cantidad != 0 && $in_carga_unidad != 0 && $in_carga_descripcion != '' && $in_carga_precio_unitario > 0 && $in_carga_importe > 0 ) {
// solo agregamos reginstros a la venta
if ( $id_venta_activa > 0 && $vc_select_cliente > 0 ) {
$vc_query = " insert into tb_venta_articulo (id_venta, int_cantidad, int_unidad, vc_descripcion, dec_precio_unitario, dec_precio_importe, dtm_fecha_venta_articulo)
values ('$id_venta_activa', '$in_carga_cantidad', '$in_carga_unidad', '$in_carga_descripcion', '$in_carga_precio_unitario', '$in_carga_importe', NOW())
";
$MySQL->query( $GLOBAL_MySQL_host, $vc_query, 0 );

} else // si no, iniciamos una venta
{
if ( $vc_select_cliente > 0 ) {
$vc_query = "insert into tb_venta ( id_cliente, dtm_fecha_venta, b_status ) values ( '$vc_select_cliente', now(), '-1' )";
$MySQL->query( $GLOBAL_MySQL_host, $vc_query, 0 );
$id_last_insert_id = $MySQL->query( $GLOBAL_MySQL_host, "select last_insert_id() ", 1 );
$vc_query = " insert into tb_venta_articulo
(id_venta, int_cantidad, int_unidad, vc_descripcion, dec_precio_unitario, dec_precio_importe, dtm_fecha_venta_articulo)
values ('$id_last_insert_id', '$in_carga_cantidad', '$in_carga_unidad', '$in_carga_descripcion', '$in_carga_precio_unitario', '$in_carga_importe', NOW())";
$MySQL->query( $GLOBAL_MySQL_host, $vc_query, 0 );
$id_venta_activa = $id_last_insert_id;
}
}


}


$vc_query = " select id_cliente, concat( id_cliente, ' - ', vc_cliente ) as 'cliente',
vc_cliente, vc_domicilio, vc_ciudad, vc_telefono, vc_rfc
from tb_cliente where b_status = 1 ";
$MySQL->query( $GLOBAL_MySQL_host, $vc_query, 0 );

$arr_clientes = $MySQL->arr;

if ($vc_select_cliente > 0 && isset($arr_clientes) ) {
$vc_nombre_cliente=$arr_clientes[$vc_select_cliente-1]["vc_cliente"];
$vc_domicilio=$arr_clientes[$vc_select_cliente-1]["vc_domicilio"];
$vc_ciudad=$arr_clientes[$vc_select_cliente-1]["vc_ciudad"];
$vc_telefono=$arr_clientes[$vc_select_cliente-1]["vc_telefono"];
$vc_rfc=$arr_clientes[$vc_select_cliente-1]["vc_rfc"];
}

// imprime factura
if ( $b_imprime_factura == 1 && $vc_select_cliente > 0 && $id_venta_activa > 0 ) {
include_once('include/pdfclass/class.ezpdf.php');
$pdf = new Cezpdf();
$pdf->selectFont('pdfclass/fonts/Helvetica.afm');
$pdf->addJpegFromFile('facturacarpi.jpg',25,50,550);

$vc_query = "select * from tb_cliente where id_cliente = '$vc_select_cliente' limit 1";
$MySQL->query( $GLOBAL_MySQL_host, $vc_query, 0 );
$arr_clientes_pdf = $MySQL->arr[0];

$vc_query = "select * from tb_venta_articulo where id_venta = '$id_venta_activa'";
$MySQL->query( $GLOBAL_MySQL_host, $vc_query, 0 );
$arr_ventas_pdf = $MySQL->arr;

$dec_importe_pdf = $MySQL->query( $GLOBAL_MySQL_host, " select sum(dec_precio_importe) from tb_venta_articulo where id_venta = '$id_venta_activa' ", 1 );
$dec_importe_pdf = $dec_importe_pdf?$dec_importe_pdf:0;

$MySQL->query( $GLOBAL_MySQL_host, " update tb_venta set b_status = '0', dec_precio_total = '$dec_importe_pdf' * 1.15 where id_venta = '$id_venta_activa' limit 1 ", 0 );

// --------- IMPRESION DE LA FACTURA --------- IMPRESION DE LA FACTURA --------- IMPRESION DE LA FACTURA --------- IMPRESION DE LA FACTURA ---------

$pdf->selectFont('include/pdfclass/Courier.afm');
//$pdf->addJpegFromFile('facturacarpi.jpg',25,50,550);
$pdf->ezSetY(667);
$pdf->ezText(
str_repeat( " ", 12 ) .
rightTextJustify( $arr_clientes_pdf['vc_cliente'], 50 ) .
str_repeat( " ", 6 ) .
$in_carga_dia .
str_repeat( " ", 5 ) .
$in_carga_mes .
str_repeat( " ", 5 ) .
$in_carga_anio
);
$pdf->ezSetY(651);
$pdf->ezText( str_repeat( " ", 12 ) . rightTextJustify( $arr_clientes_pdf['vc_domicilio'], 50 ) );
$pdf->ezSetY(632);
$pdf->ezText( str_repeat( " ", 12 ) . rightTextJustify( $arr_clientes_pdf['vc_ciudad'], 50 ) );s
$pdf->ezSetY(614);
$pdf->ezText(
str_repeat( " ", 12 ) . rightTextJustify( $arr_clientes_pdf['vc_telefono'], 15 ) .
str_repeat( " ", 1 ) . rightTextJustify( $arr_clientes_pdf['vc_rfc'], 16 ) .
str_repeat( " ", 8 ) . intJustify( $arr_clientes_pdf['id_cliente'], 6 )
);

if ( isset ( $arr_ventas_pdf ) ) {
$id_coordenada = 570;
foreach ( $arr_ventas_pdf as $v ) {
$pdf->ezSetY($id_coordenada);
$pdf->ezText( str_repeat( " ", 3 ) .
intJustify( $v["int_cantidad"], 8 ) .
str_repeat( " ", 1 ) .
intJustify( $v["int_unidad"], 6 ) .
str_repeat( " ", 2 ) .
rightTextJustify( $v["vc_descripcion"], 43 ) .
textJustify( $v['dec_precio_unitario'], 11 ) .
str_repeat( " ", 2 ) .
textJustify( $v['dec_precio_importe'], 11 ) );
$id_coordenada = $id_coordenada - 20;
}
}

$pdf->ezSetY(264);
$pdf->ezText( str_repeat( " ", 162 ) . textJustify( $dec_importe_pdf, 14 ) );
$pdf->ezSetY(238);
$pdf->ezText( str_repeat( " ", 162 ) . textJustify( $dec_importe_pdf * 0.15, 14 ) );
$pdf->ezSetY(212);
$pdf->ezText( str_repeat( " ", 162 ) . textJustify( $dec_importe_pdf * 1.15, 14 ) );

// orp, dividimos el texto del importa para imprimirlo en el espacio de la factura
list($vc_pesos, $vc_centavos) = explode(' Pesos', $cantidadLetra->ValorEnLetras($dec_importe_pdf * 1.15," Pesos"));
$vc_pesos.=' Pesos'; $vc_centavos=trim($vc_centavos);

$pdf->ezSetY(245);
$pdf->ezText( str_repeat( " ", 18 ) . $vc_pesos);
$pdf->ezSetY(230);
$pdf->ezText( str_repeat( " ", 18 ) . $vc_centavos);
$pdf->ezStream();

// --------- IMPRESION DE LA FACTURA --------- IMPRESION DE LA FACTURA --------- IMPRESION DE LA FACTURA --------- IMPRESION DE LA FACTURA ---------

die;
}

?>