function Header() { $this->AddFont('Amble-Regular'); $this->SetFont('Amble-Regular', '', 10); $fecha = date('Y-m-d', time()); $this->SetX(1); $this->SetY(1); $this->Cell(20, 5, $fecha, 0, 0, 'C', 0); $this->Cell(150, 5, "CLIENTE", 0, 1, 'R', 0); $this->SetFont('Arial', 'B', 16); $sql = pg_query("select ruc_empresa,nombre_empresa,propietario,telefono1,telefono2,direccion,correo,sitio_web,autorizacion_factura,autorizacion_factura,imagen from empresa where id_empresa = '" . $_SESSION['empresa_dow'] . "'"); while ($row = pg_fetch_row($sql)) { $this->Cell(190, 8, maxCaracter("EMPRESA: " . utf8_decode($row[1]), 50), 0, 1, 'C', 0); $this->Image('../empresa/img/' . $row[10], 5, 8, 40, 30); $this->SetFont('Amble-Regular', '', 10); $this->Cell(180, 5, maxCaracter("PROPIETARIO: " . utf8_decode($row[2]), 50), 0, 1, 'C', 0); $this->Cell(70, 5, maxCaracter("TEL.: " . utf8_decode($row[3]), 50), 0, 0, 'R', 0); $this->Cell(60, 5, maxCaracter("CEL.: " . utf8_decode($row[4]), 50), 0, 1, 'C', 0); $this->Cell(170, 5, maxCaracter("DIR.: " . utf8_decode($row[5]), 55), 0, 1, 'C', 0); $this->Cell(170, 5, maxCaracter("E-MAIL.: " . utf8_decode($row[6]), 55), 0, 1, 'C', 0); $this->Cell(170, 5, maxCaracter("SITIO WEB.: " . utf8_decode($row[7]), 55), 0, 1, 'C', 0); $this->Text(160, 30, maxCaracter("Nro Aut SRI.: " . utf8_decode($row[8]), 55), 0, 1, 'C', 0); $this->Text(150, 35, maxCaracter("Fecha Aut SRI.: " . utf8_decode($row[9]), 55), 0, 1, 'C', 0); $this->Text(70, 44, "OBLIGADO A LLEVAR CONTABILIDAD : SI", 0, 'C', 0); $this->SetFont('Amble-Regular', 'U', 14); $this->Text(85, 49, "LIBRO DIARIO", 0, 'C', 0); $this->Text(85, 49, "LIBRO DIARIO", 0, 'C', 0); } $this->SetDrawColor(0, 0, 0); $this->SetLineWidth(0.5); $this->Line(1, 53, 210, 53); $this->Ln(16); }
function Header() { $this->AddFont('Amble-Regular'); $this->SetFont('Amble-Regular', '', 10); $fecha = date('Y-m-d', time()); $this->SetX(1); $this->SetY(1); $this->Cell(20, 5, $fecha, 0, 0, 'C', 0); $this->Cell(150, 5, "CLIENTE", 0, 1, 'R', 0); $this->SetFont('Arial', 'B', 16); $sql = pg_query("select numero_serie,forma_pago,tarifa0,tarifa12,iva,descuento,total from cliente,factura_venta where cliente.id_cliente = factura_venta.id_cliente and id_factura_venta = '{$_GET['id']}'"); while ($row = pg_fetch_row($sql)) { $this->nro_fac = $row[0]; } $sql = pg_query("select ruc_empresa,nombre_empresa,propietario,telefono1,telefono2,direccion,correo,sitio_web,autorizacion_sri,ascesor_legar,imagen from empresa where id_empresa = '11001854f72c12c2b36'"); while ($row = pg_fetch_row($sql)) { $this->Image('../empresa/img/' . $row[10], 0, 8, 60, 30); $this->SetY(40); $this->SetX(1); $this->Cell(100, 36, '', 1, 1, 'C', 0); $this->SetY(40); $this->SetX(1); $this->SetFont('Arial', 'B', 11); $this->Cell(100, 8, maxCaracter(strtoupper(utf8_decode($row[1])), 30), 0, 1, 'C', 0); $this->SetX(1); $this->SetFont('Amble-Regular', '', 10); $this->Cell(35, 6, maxCaracter(utf8_decode("Dirección Matriz: "), 38), 0, 0, 'L', 0); $this->Cell(55, 6, maxCaracter(utf8_decode($row[5]), 25), 0, 1, 'L', 0); $this->SetX(1); $this->Cell(35, 6, maxCaracter(utf8_decode("Dirección Sucursal: "), 38), 0, 0, 'L', 0); $this->Cell(55, 6, maxCaracter(utf8_decode($row[5]), 38), 0, 1, 'L', 0); $this->SetX(1); $this->Cell(100, 6, maxCaracter(utf8_decode("Contribuyente especial Nro: 1115375970"), 38), 0, 1, 'L', 0); $this->SetX(1); $this->Cell(100, 6, "OBLIGADO A LLEVAR CONTABILIDAD : SI", 0, 1, 'C', 0); $this->SetY(6); $this->SetX(105); $this->Cell(100, 70, '', 1, 1, 'C', 0); $this->SetY(8); $this->SetX(105); $this->SetFont('Amble-Regular', '', 11); $this->Cell(100, 6, maxCaracter("RUC.: " . utf8_decode("1792107865001"), 50), 0, 1, 'L', 0); $this->SetX(105); $this->SetFont('Amble-Regular', '', 14); $this->Cell(100, 8, maxCaracter(utf8_decode("FACTURA"), 50), 0, 1, 'L', 0); $this->SetFont('Amble-Regular', '', 11); $this->SetX(105); $this->Cell(100, 6, maxCaracter("NRO.: " . utf8_decode($this->nro_fac), 50), 0, 1, 'L', 0); $this->SetX(105); $this->Cell(100, 6, maxCaracter(utf8_decode("NÚMERO DE AUTORIZACIÓN.: "), 55), 0, 1, 'L', 0); $this->SetX(105); $this->Cell(100, 6, maxCaracter(utf8_decode($row[8]), 50), 0, 1, 'L', 0); $this->SetX(105); $this->Cell(50, 6, maxCaracter(utf8_decode("FECHA DE AUTORIZACIÓN"), 55), 0, 0, 'L', 0); $this->Cell(50, 6, maxCaracter(utf8_decode($row[9]), 30), 0, 1, 'L', 0); $this->SetX(105); $this->Cell(100, 6, maxCaracter(utf8_decode("AMBIENTE: PRUEBAS"), 55), 0, 1, 'L', 0); $this->SetX(105); $this->Cell(100, 6, maxCaracter(utf8_decode("EMISIÓN: NORMAL"), 55), 0, 1, 'L', 0); $this->SetX(105); $this->Cell(100, 6, maxCaracter(utf8_decode("CLAVE DE ACCESO"), 55), 0, 1, 'L', 0); $this->Image('../../empresa/barras.jpg', 106, 65, 94, 8); /*$this->Cell(80, 5, maxCaracter("PROPIETARIO: ".utf8_decode($row[2]),50),0,1, 'C',0); $this->Cell(70, 5, maxCaracter("TEL.: ".utf8_decode($row[3]),50),0,0, 'R',0); $this->Cell(60, 5, maxCaracter("CEL.: ".utf8_decode($row[4]),50),0,1, 'C',0); $this->Cell(170, 5, maxCaracter("E-MAIL.: ".utf8_decode($row[6]),55),0,1, 'C',0); $this->Cell(170, 5, maxCaracter("SITIO WER.: ".utf8_decode($row[7]),55),0,1, 'C',0); */ } $this->SetDrawColor(0, 0, 0); $this->SetLineWidth(0.5); $this->Line(1, 77, 210, 77); $this->Ln(20); }
$pdf->Ln(2); $pdf->SetX(1); $pdf->Cell(25, 6, utf8_decode('Comprobante'), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode('Tipo Documento'), 1, 0, 'C', 0); $pdf->Cell(45, 6, utf8_decode('Nro Factura'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Total'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Valor Pago'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Saldo'), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode('Fecha Pago'), 1, 1, 'C', 0); $repetido = 1; $contador = 1; } $pdf->Cell(25, 6, utf8_decode($row3[4]), 0, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode($row3[8]), 0, 0, 'C', 0); $pdf->Cell(45, 6, substr($row3[7], 8, 30), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row3[9]), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row3[9] - $row3[10]), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row3[10]), 0, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode($row3[5]), 0, 1, 'C', 0); $sub = $sub + ($row3[9] - $row3[10]); } } if ($contador > 0) { $pdf->SetX(1); $pdf->Cell(207, 0, utf8_decode(""), 1, 1, 'R', 0); $pdf->Cell(180, 6, utf8_decode("Totales"), 0, 0, 'R', 0); $pdf->Cell(30, 6, maxCaracter(number_format($sub, 2, ',', '.'), 20), 0, 1, 'C', 0); $pdf->Ln(3); } } $pdf->Output();
$pdf->SetX(1); $pdf->Cell(22, 6, utf8_decode($row1[14]), 0, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode($row1[1]), 0, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode(substr($row1[0], 8)), 0, 0, 'C', 0); $sub = $sub + ($row1[10] - $row1[8] - $row1[9]); $pdf->Cell(15, 6, $row1[10] - $row1[8] - $row1[9], 0, 0, 'C', 0); $desc = $desc + $row1[9]; $pdf->Cell(17, 6, $row1[9], 0, 0, 'C', 0); $pdf->Cell(16, 6, $row1[6], 0, 0, 'C', 0); $pdf->Cell(17, 6, $row1[7], 0, 0, 'C', 0); $ivaT = $ivaT + $row1[8]; $pdf->Cell(15, 6, $row1[8], 0, 0, 'C', 0); $total = $total + $row1[10]; $pdf->Cell(15, 6, $row1[10], 0, 0, 'C', 0); $pdf->Cell(20, 6, $row1[3], 0, 0, 'C', 0); $pdf->Cell(20, 6, $row1[5], 0, 0, 'C', 0); $pdf->Ln(6); } } } $pdf->SetX(1); $pdf->Ln(8); $pdf->Cell(188, 6, utf8_decode("Subtotal"), 0, 0, 'R', 0); $pdf->Cell(20, 6, maxCaracter(number_format($sub, 2, ',', '.'), 20), 0, 1, 'C', 0); $pdf->Cell(188, 6, utf8_decode("Descuento"), 0, 0, 'R', 0); $pdf->Cell(20, 6, maxCaracter(number_format($desc, 2, ',', '.'), 20), 0, 1, 'C', 0); $pdf->Cell(188, 6, utf8_decode("Iva Total"), 0, 0, 'R', 0); $pdf->Cell(20, 6, maxCaracter(number_format($ivaT, 2, ',', '.'), 20), 0, 1, 'C', 0); $pdf->Cell(188, 6, utf8_decode("Total"), 0, 0, 'R', 0); $pdf->Cell(20, 6, maxCaracter(number_format($total, 2, ',', '.'), 20), 0, 1, 'C', 0); $pdf->Output();
$repetido = 0; $contador = 0; $consulta = pg_query("select id_usuario,ci_usuario,nombre_usuario,apellido_usuario,telefono_usuario,direccion_usuario from usuario;"); while ($row = pg_fetch_row($consulta)) { $repetido = 0; $total = 0; $sql1 = pg_query("select comprobante,fecha_actual,codigo,articulo,cantidad,precio_compra,sub_total from ordenes_produccion,usuario,productos where ordenes_produccion.id_usuario = usuario.id_usuario and ordenes_produccion.cod_productos = productos.cod_productos and fecha_actual between '" . $_GET['inicio'] . "' and '" . $_GET['fin'] . "' and usuario.id_usuario='{$row['0']}'"); if (pg_num_rows($sql1)) { if ($repetido == 0) { $pdf->SetX(1); $pdf->SetFillColor(187, 179, 180); $pdf->Cell(70, 6, maxCaracter(utf8_decode('RUC/CI: ' . $row[1]), 35), 1, 0, 'L', 1); $pdf->Cell(135, 6, maxCaracter(utf8_decode('NOMBRE: ' . $row[2] . ' ' . $row[3]), 35), 1, 1, 'L', 1); $pdf->SetX(1); $pdf->Cell(70, 6, maxCaracter(utf8_decode('TELF:' . $row[4]), 35), 1, 0, 'L', 1); $pdf->Cell(135, 6, maxCaracter(utf8_decode('DIRECCIÓN:' . $row[5]), 35), 1, 1, 'L', 1); $pdf->Ln(2); $pdf->SetX(1); $pdf->Cell(25, 6, utf8_decode('Comprobante'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Fecha'), 1, 0, 'C', 0); $pdf->Cell(35, 6, utf8_decode('Código'), 1, 0, 'C', 0); $pdf->Cell(45, 6, utf8_decode('Producto'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Cantidad'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('P. Costo'), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode('T. Costo'), 1, 1, 'C', 0); $pdf->Ln(1); $repetido = 1; } while ($row1 = pg_fetch_row($sql1)) { $pdf->Cell(25, 6, utf8_decode($row1[0]), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row1[1]), 0, 0, 'C', 0);
} $yy = $yy + 5; } else { $pdf->Text(25, $yy, maxCaracter(utf8_decode($row[1]), 30), 0, 0, 'L', 0); $pdf->Text(180, $yy, maxCaracter(utf8_decode($row[1]), 30), 0, 0, 'L', 0); } $pdf->Text(95, $yy, maxCaracter(utf8_decode($row[2]), 6), 0, 0, 'L', 0); $pdf->Text(245, $yy, maxCaracter(utf8_decode($row[2]), 6), 0, 0, 'L', 0); $pdf->Text(120, $yy, maxCaracter($temp_1, 6), 0, 0, 'L', 0); $pdf->Text(270, $yy, maxCaracter($temp_1, 6), 0, 0, 'L', 0); $yy = $yy + 5; } /////////pie $subtotal = truncateFloat($iva12, 2); $descuento_venta = truncateFloat($descuento_venta, 2); $iva_venta = truncateFloat($iva_venta, 2); $iva0 = truncateFloat($iva0, 2); $total_venta = truncateFloat($total_venta, 2); $pdf->Text(120, 173, maxCaracter($subtotal, 5), 0, 1, 'L', 0); $pdf->Text(120, 179, maxCaracter($iva0, 5), 0, 1, 'L', 0); $pdf->Text(120, 185, maxCaracter($iva_venta, 5), 0, 1, 'L', 0); $pdf->Text(98, 186, '12', 0, 1, 'L', 0); $pdf->Text(120, 191, maxCaracter($descuento_venta, 5), 0, 1, 'L', 0); $pdf->Text(120, 197, maxCaracter($total_venta, 10), 0, 1, 'L', 0); $pdf->Text(275, 173, maxCaracter($subtotal, 5), 0, 1, 'L', 0); $pdf->Text(275, 179, maxCaracter($iva0, 5), 0, 1, 'L', 0); $pdf->Text(275, 185, maxCaracter($iva_venta, 5), 0, 1, 'L', 0); $pdf->Text(249, 186, '12', 0, 1, 'L', 0); $pdf->Text(275, 191, maxCaracter($descuento_venta, 5), 0, 1, 'L', 0); $pdf->Text(275, 197, maxCaracter($total_venta, 10), 0, 1, 'L', 0); $pdf->Output();
$pdf->RotatedImage('../images/circle.png', 260, 42, 30, 10, 45); $pdf->RotatedText(269, 41, 'ANULADO!', 45); } ////////detalles $sql = pg_query("select cantidad,articulo,precio_venta,total_venta from detalle_factura_venta,productos where id_factura_venta = '" . $_GET['id'] . "' and detalle_factura_venta.cod_productos = productos.cod_productos"); $yy = 76; $pdf->SetTextColor(0, 0, 0); while ($row = pg_fetch_row($sql)) { $pdf->Text(15, $yy, maxCaracter(utf8_decode($row[0]), 3), 0, 1, 'L', 0); $pdf->Text(25, $yy, maxCaracter(utf8_decode($row[1]), 50), 0, 0, 'L', 0); $pdf->Text(95, $yy, maxCaracter(utf8_decode($row[2]), 6), 0, 0, 'L', 0); $pdf->Text(120, $yy, maxCaracter(utf8_decode($row[3]), 6), 0, 0, 'L', 0); $pdf->Text(165, $yy, maxCaracter(utf8_decode($row[0]), 3), 0, 1, 'L', 0); $pdf->Text(180, $yy, maxCaracter(utf8_decode($row[1]), 50), 0, 0, 'L', 0); $pdf->Text(245, $yy, maxCaracter(utf8_decode($row[2]), 6), 0, 0, 'L', 0); $pdf->Text(270, $yy, maxCaracter(utf8_decode($row[3]), 6), 0, 0, 'L', 0); $yy = $yy + 5; } /////////pie $subtotal = $iva12 + $iva0; $pdf->Text(120, 173, maxCaracter($subtotal, 3), 0, 1, 'L', 0); $pdf->Text(120, 179, maxCaracter(utf8_decode($descuento_venta), 3), 0, 1, 'L', 0); $pdf->Text(120, 185, maxCaracter(utf8_decode($iva_venta), 3), 0, 1, 'L', 0); $pdf->Text(120, 191, maxCaracter(utf8_decode($iva0), 3), 0, 1, 'L', 0); $pdf->Text(120, 197, maxCaracter(utf8_decode($total_venta), 3), 0, 1, 'L', 0); $pdf->Text(275, 173, maxCaracter($subtotal, 3), 0, 1, 'L', 0); $pdf->Text(275, 179, maxCaracter(utf8_decode($descuento_venta), 3), 0, 1, 'L', 0); $pdf->Text(275, 185, maxCaracter(utf8_decode($iva_venta), 3), 0, 1, 'L', 0); $pdf->Text(275, 191, maxCaracter(utf8_decode($iva0), 3), 0, 1, 'L', 0); $pdf->Text(275, 197, maxCaracter(utf8_decode($total_venta), 3), 0, 1, 'L', 0); $pdf->Output();
$pdf->SetX(1); $pdf->Cell(53, 5, maxCaracter(utf8_decode($row[0]), 30), 0, 0, 'C', 0); $pdf->Cell(40, 5, maxCaracter(utf8_decode($row[1]), 20), 0, 0, 'L', 0); $pdf->Cell(40, 5, maxCaracter(utf8_decode($row[2]), 20), 0, 0, 'C', 0); $pdf->Cell(25, 5, maxCaracter(utf8_decode($row[3]), 20), 0, 0, 'C', 0); if ($row[6] == '2' || $row[6] == '4') { $pdf->Cell(25, 5, maxCaracter(utf8_decode('-' . $row[4]), 20), 0, 0, 'C', 0); } else { $pdf->Cell(25, 5, maxCaracter(utf8_decode($row[4]), 20), 0, 0, 'C', 0); } $pdf->Cell(25, 5, maxCaracter(utf8_decode($row[5]), 20), 0, 0, 'C', 0); $pdf->Ln(5); } } else { $sql = pg_query("SELECT K.detalle, K.origen, k.destino, K.fecha_kardex, K.cantidad, K.saldo, K.estado from kardex K where k.fecha_kardex between '{$_GET['inicio']}' and '{$_GET['fin']}' and k.cod_productos = '{$_GET['id']}' order by k.id_kardex asc"); while ($row = pg_fetch_row($sql)) { $pdf->SetX(1); $pdf->Cell(53, 5, maxCaracter(utf8_decode($row[0]), 30), 0, 0, 'C', 0); $pdf->Cell(40, 5, maxCaracter(utf8_decode($row[1]), 20), 0, 0, 'L', 0); $pdf->Cell(40, 5, maxCaracter(utf8_decode($row[2]), 20), 0, 0, 'C', 0); $pdf->Cell(25, 5, maxCaracter(utf8_decode($row[3]), 20), 0, 0, 'C', 0); if ($row[6] == '2' || $row[6] == '4') { $pdf->Cell(25, 5, maxCaracter(utf8_decode('-' . $row[4]), 20), 0, 0, 'C', 0); } else { $pdf->Cell(25, 5, maxCaracter(utf8_decode($row[4]), 20), 0, 0, 'C', 0); } $pdf->Cell(25, 5, maxCaracter(utf8_decode($row[5]), 20), 0, 0, 'C', 0); $pdf->Ln(5); } } $pdf->Output();
$pdf->Cell(30, 6, utf8_decode($row1[10]), 0, 1, 'C', 0); $pdf->SetX(1); $pdf->Ln(1); $pdf->SetX(1); $pdf->Cell(205, 0, utf8_decode(''), 1, 1, 'R', 0); $pdf->Cell(175, 6, utf8_decode('Saldo Pendiente'), 0, 0, 'R', 0); $pdf->Cell(30, 6, utf8_decode($total), 0, 1, 'C', 0); $pdf->Ln(5); } } $consulta2 = pg_query("select * from factura_venta where id_cliente='{$_GET['id']}' and forma_pago='Credito'"); while ($row2 = pg_fetch_row($consulta2)) { $total = 0; $pdf->SetX(1); $pdf->Cell(80, 6, maxCaracter(utf8_decode('Factura #:' . $row2[5]), 35), 1, 0, 'L', 1); $pdf->Cell(125, 6, maxCaracter('Serie #:' . substr($row2[5], 0, 7), 35), 1, 1, 'L', 1); $pdf->Ln(1); $pdf->SetX(1); $pdf->Cell(50, 6, utf8_decode('Comprobante'), 1, 0, 'C', 0); $pdf->Cell(50, 6, utf8_decode('Tipo Doc.'), 1, 0, 'C', 0); $pdf->Cell(45, 6, utf8_decode('Fecha Mov.'), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode('Valor'), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode('Saldo'), 1, 1, 'C', 0); $repetido = 1; $consulta3 = pg_query("select * from pagos_venta where id_factura_venta='{$row2['0']}'"); while ($row3 = pg_fetch_row($consulta3)) { $pdf->SetX(1); $pdf->Cell(50, 6, utf8_decode($row3[2]), 0, 0, 'C', 0); $pdf->Cell(50, 6, utf8_decode("Factura Venta"), 0, 0, 'C', 0); $pdf->Cell(45, 6, utf8_decode($row3[4]), 0, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode($row3[8] - $row3[9]), 0, 0, 'C', 0);
while ($row1 = pg_fetch_row($sql1)) { $id_fac = $row1[0]; $num_fac = $row1[1]; $total = $row1[3]; $fecha = $row1[4]; $cliente = $row1[2]; } $sql2 = pg_query("SELECT * FROM gastos where fecha_actual between '{$_GET['inicio']}' and '{$_GET['fin']}' and id_factura_venta='{$id_fac}' order by id_factura_venta asc"); while ($row2 = pg_fetch_row($sql2)) { $pdf->SetX(1); $pdf->Cell(20, 6, substr($num_fac, 8, 30), 0, 0, 'C', 0); $pdf->Cell(22, 6, utf8_decode($fecha), 0, 0, 'C', 0); $pdf->Cell(40, 6, maxCaracter(utf8_decode($cliente), 18), 0, 0, 'L', 0); $pdf->Cell(15, 6, utf8_decode($total), 0, 0, 'C', 0); $pdf->Cell(40, 6, maxCaracter(utf8_decode($row2[6]), 20), 0, 0, 'L', 0); $pdf->Cell(20, 6, utf8_decode($row2[4]), 0, 0, 'C', 0); $pdf->Cell(15, 6, utf8_decode($row2[7]), 0, 0, 'C', 0); $pdf->Cell(15, 6, utf8_decode($row2[8]), 0, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode($row2[9]), 0, 1, 'C', 0); $tot = $tot + $total; $acumlado = $acumlado + $row2[7]; } } $pdf->SetX(1); $pdf->Cell(207, 0, utf8_decode(""), 1, 1, 'R', 0); $pdf->Cell(83, 6, utf8_decode("Totales Venta"), 0, 0, 'R', 0); $pdf->Cell(20, 6, maxCaracter(number_format($tot, 2, ',', '.'), 20), 0, 0, 'C', 0); $pdf->Cell(85, 6, utf8_decode("Totales Gastos"), 0, 0, 'R', 0); $pdf->Cell(20, 6, maxCaracter(number_format($acumlado, 2, ',', '.'), 20), 0, 1, 'C', 0); $pdf->Ln(3); $pdf->Output();
$pdf->SetX(3); $pdf->Cell(30, 5, "REGISTRADO.: ", 0, 0, 'L', 0); $pdf->Cell(90, 5, maxCaracter(utf8_decode($row[37]) . " " . utf8_decode($row[38]), 40), 0, 0, 'L', 0); $pdf->Cell(30, 5, "TEL/CEL.: ", 0, 0, 'L', 0); $pdf->Cell(52, 5, maxCaracter(utf8_decode($row[40] . " - " . $row[41]), 22), 0, 1, 'L', 0); $pdf->Ln(2); $pdf->SetX(3); $pdf->Cell(30, 5, "ACCESORIOS: ", 0, 0, 'L', 0); $pdf->SetX(33); $pdf->MultiCell(170, 4, maxCaracter(utf8_decode($row[6]), 280), 0, 'L', 0); $pdf->SetY(236); $pdf->SetX(3); $pdf->Cell(30, 5, "OBSERVACIONES: ", 0, 1, 'L', 0); $pdf->SetY(236); $pdf->SetX(33); $pdf->MultiCell(170, 4, maxCaracter(utf8_decode($row[5]), 280), 0, 'L', 0); $pdf->SetY(255); $pdf->SetX(3); $pdf->Cell(30, 5, "NOTAS: ", 0, 1, 'L', 0); $pdf->SetY(255); $pdf->SetX(33); $pdf->MultiCell(170, 4, maxCaracter(utf8_decode("El diagnóstico del equipo tiene un precio mínimo de \$10.00 (Diez Dólares) \nToda máquina reparada y no retirada en tres meses será subastada \nFavor revisar que en su orden consten todos los componentes que usted deja. No se admitiran reclamos posteriores\nPyS Systems no se responsabiliza por la pérdida de la información"), 400), 0, 'L', 0); $pdf->SetY(280); $pdf->SetX(3); $pdf->Cell(100, 5, "__________________________________________", 0, 0, 'C', 0); $pdf->Cell(102, 5, "__________________________________________", 0, 1, 'C', 0); $pdf->SetX(3); $pdf->Cell(100, 5, "ENTREGE CONFORME", 0, 0, 'C', 0); $pdf->Cell(102, 5, "RECIBI CONFORME", 0, 1, 'C', 0); } $pdf->Output();
$pdf->Text(95, $yy, maxCaracter(utf8_decode($row[4]), 6), 0, 0, 'L', 0); $pdf->Text(120, $yy, maxCaracter($temp_1, 6), 0, 0, 'L', 0); $yy = $yy + 5; } /////////pie $subtotal = truncateFloat($iva12, 2); $descuento_venta = truncateFloat($descuento_venta, 2); $iva_venta = truncateFloat($iva_venta, 2); $iva0 = truncateFloat($iva0, 2); $total_venta = truncateFloat($total_venta, 2); $pdf->Text(120, 113, maxCaracter($subtotal, 5), 0, 1, 'L', 0); $pdf->Text(120, 119, maxCaracter($iva0, 5), 0, 1, 'L', 0); $pdf->Text(120, 125, maxCaracter($iva_venta, 5), 0, 1, 'L', 0); $pdf->Text(98, 126, '12', 0, 1, 'L', 0); $pdf->Text(120, 131, maxCaracter($descuento_venta, 5), 0, 1, 'L', 0); $pdf->Text(120, 137, maxCaracter($total_venta, 10), 0, 1, 'L', 0); $pdf->Output(); require '../dompdf/dompdf_config.inc.php'; session_start(); $codigo = '<html> <head> </head> <style> @page { margin-top: 2em; margin-left: 3em; margin-bottom: 1em; margin-right: 2em; } </style>
$pdf->Ln(5); } $pdf->SetX(1); $pdf->Ln(5); $sql = pg_query("select F.descuento,F.tarifa0,F.tarifa12,F.iva,F.total from factura_compra F,detalle_factura_compra D,productos P where F.id_factura_compra=D.id_factura_compra and D.id_productos=P.id_productos and D.id_factura_compra='{$_GET['id']}' LIMIT 1"); while ($row = pg_fetch_row($sql)) { $pdf->Cell(173, 6, utf8_decode("Descuento"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[0], 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Tarifa 0"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[1], 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Tarifa 12"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[2], 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Iva 12%"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[3], 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Total"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[4], 2), 20), 0, 1, 'C', 0); } ////////// // $sql=pg_query("select * from series_compra,factura_compra,productos where factura_compra.id_factura_compra=series_compra.id_factura_compra and productos.cod_productos=series_compra.cod_productos and series_compra.id_factura_compra='$_GET[id]'"); // if(pg_num_rows($sql)){ // $pdf->AddPage(); // $pdf->Cell(205, 7, utf8_decode("NÚMEROS DE SERIE"),0,1, 'C',0); // $pdf->Cell(50, 5, utf8_decode("Cod. Producto"),1,0, 'C',0); // $pdf->Cell(95, 5, utf8_decode("Descripción"),1,0, 'C',0); // $pdf->Cell(30, 5, utf8_decode("Nro. Serie"),1,0, 'C',0); // $pdf->Cell(30, 5, utf8_decode("Nro. Factura"),1,1, 'C',0); // while($row=pg_fetch_row($sql)){ // $pdf->Cell(50, 6, maxCaracter(utf8_decode($row[28]),20),0,0, 'C',0); // $pdf->Cell(95, 6, maxCaracter(utf8_decode($row[30]),60),0,0, 'C',0); // $pdf->Cell(30, 6, maxCaracter(utf8_decode($row[3]),20),0,0, 'C',0); // $pdf->Cell(30, 6, maxCaracter(utf8_decode($row[17]),20),0,1, 'C',0);
$pdf->Cell(25, 6, utf8_decode($row1[4]), 0, 1, 'C', 0); $saldo = $row1[13]; } $pdf->Ln(2); $pdf->Cell(205, 0, utf8_decode(''), 1, 1, 'R', 0); $pdf->Cell(187, 6, utf8_decode('Total Saldo'), 0, 0, 'R', 0); $pdf->Cell(20, 6, number_format($saldo, 2, ',', '.'), 0, 0, 'C', 0); } } else { $sql = pg_query("select * from factura_compra,proveedores,usuario,empresa where factura_compra.id_proveedor=proveedores.id_proveedor and factura_compra.id_usuario=usuario.id_usuario and factura_compra.id_empresa=empresa.id_empresa and num_serie='{$_GET['id']}' and proveedores.id_proveedor='{$_GET['proveedor']}'"); while ($row = pg_fetch_row($sql)) { $pdf->SetX(1); $pdf->SetFillColor(187, 179, 180); $pdf->Cell(50, 6, maxCaracter(utf8_decode('RUC/CI:' . $row[23]), 35), 1, 0, 'L', 1); $pdf->Cell(80, 6, maxCaracter(utf8_decode('NOMBRES:' . $row[24]), 35), 1, 0, 'L', 1); $pdf->Cell(75, 6, maxCaracter(utf8_decode('SECCIÓN:' . $row[52]), 50), 1, 1, 'L', 1); $pdf->Ln(3); $pdf->SetX(1); $pdf->Cell(30, 6, utf8_decode('Comprobante'), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode('Tipo Documento'), 1, 0, 'C', 0); $pdf->Cell(50, 6, utf8_decode('Nro. Factura'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Total'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Valor Pago'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Saldo'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Fecha Pago'), 1, 1, 'C', 0); } $sql = pg_query("select * from pagos_pagar where num_factura='{$_GET['id']}' and comprobante='{$_GET['comprobante']}'"); $meses = 0; $id_pv = 0; while ($row = pg_fetch_row($sql)) { $pdf->Cell(30, 6, utf8_decode($row[3]), 0, 0, 'C', 0);
$pdf->Cell(25, 6, utf8_decode($row2[6]), 0, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode($row2[2]), 0, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode($row2[5]), 0, 1, 'C', 0); $sub = $sub + $row2[1]; $saldo = $saldo + $row2[6]; /*$sql3=pg_query("select * from detalles_pagos_internos where id_cuentas_cobrar='$row2[0]'"); while($row3=pg_fetch_row($sql3)){ $pdf->Cell(25, 6, utf8_decode(''),0,0, 'C',0); $pdf->Cell(26, 6, utf8_decode(''),0,0, 'C',0); $pdf->Cell(35, 6, '',0,0, 'C',0); $pdf->Cell(20, 6, utf8_decode(''),0,0, 'C',0); $pdf->Cell(20, 6, utf8_decode($row3[3]),0,0, 'C',0); $pdf->Cell(25, 6, utf8_decode($row3[4]),0,0, 'C',0); $pdf->Cell(30, 6, utf8_decode($row2[2]),0,0, 'C',0); $pdf->Cell(20, 6, utf8_decode($row2[5]),0,1, 'C',0); }*/ } } } } if ($contador > 0) { $pdf->SetX(1); $pdf->Cell(207, 0, utf8_decode(""), 1, 1, 'R', 0); $pdf->Cell(106, 6, utf8_decode("Totales"), 0, 0, 'R', 0); $pdf->Cell(21, 6, maxCaracter(number_format($sub, 2, ',', '.'), 20), 1, 0, 'C', 0); $pdf->Cell(25, 6, maxCaracter(number_format($saldo, 2, ',', '.'), 20), 1, 1, 'C', 0); $pdf->Ln(3); } } } $pdf->Output();
$pdf->Cell(40, 6, utf8_decode("Total Facturas"), 1, 1, 'C', 0); $sql = pg_query("select id_cliente, identificacion, nombres_cli from clientes where id_director = '{$_GET['id']}' order by id_cliente asc;"); $cont1 = 0; $cont2 = 0; while ($row = pg_fetch_row($sql)) { $temp = 0; $temp1 = 0; $sql1 = pg_query("select count(id_factura_venta) as contador, SUM(total_venta::float) as total_venta from factura_venta where id_cliente ='{$row['0']}' and estado ='Activo'"); while ($row1 = pg_fetch_row($sql1)) { $temp = $row1[0]; if ($row1[1] == "") { $temp1 = "\$ 0"; } else { $temp1 = "\$ " . $row1[1]; } $cont1 = $cont1 + $row1[0]; $cont2 = $cont2 + $row1[1]; } $pdf->SetX(1); $pdf->Cell(40, 6, utf8_decode($row[1]), 0, 0, 'C', 0); $pdf->Cell(50, 6, utf8_decode($row[2]), 0, 0, 'C', 0); $pdf->Cell(40, 6, utf8_decode($temp), 0, 0, 'C', 0); $pdf->Cell(40, 6, utf8_decode($temp1), 0, 1, 'C', 0); } $pdf->SetX(1); $pdf->Cell(207, 0, utf8_decode(""), 1, 1, 'R', 0); $pdf->Cell(85, 6, utf8_decode("Totales"), 0, 0, 'R', 0); $pdf->Cell(25, 6, maxCaracter(number_format($cont1, 2, ',', '.'), 20), 0, 0, 'C', 0); $pdf->Cell(25, 6, maxCaracter(number_format($cont2, 2, ',', '.'), 20), 0, 1, 'C', 0); $pdf->Ln(3); $pdf->Output();
$total_si = $row[6] / $iva_base; $total_sit = $total_si / $row[3]; $total_si = truncateFloat($total_si, 2); $total_sit = truncateFloat($total_sit, 2); $pdf->Cell(40, 5, maxCaracter(utf8_decode($row[9]), 20), 0, 0, 'L', 0); $pdf->Cell(80, 5, maxCaracter(utf8_decode($row[11]), 20), 0, 0, 'L', 0); $pdf->Cell(20, 5, maxCaracter(utf8_decode($row[3]), 80), 0, 0, 'C', 0); $pdf->Cell(20, 5, maxCaracter(utf8_decode($total_sit), 20), 0, 0, 'C', 0); //precio $pdf->Cell(20, 5, maxCaracter(utf8_decode($row[5]), 20), 0, 0, 'C', 0); ///descuento $pdf->Cell(25, 5, maxCaracter(utf8_decode($total_si), 20), 0, 0, 'C', 0); //total $pdf->Ln(5); } $pdf->SetX(1); $pdf->Ln(5); $sql = pg_query("select factura_compra.descuento_compra,factura_compra.tarifa0,factura_compra.tarifa12,factura_compra.iva_compra,factura_compra.total_compra from factura_compra,detalle_factura_compra,productos where factura_compra.id_factura_compra=detalle_factura_compra.id_factura_compra and detalle_factura_compra.cod_productos=productos.cod_productos and detalle_factura_compra.id_factura_compra='{$_GET['id']}' LIMIT 1"); while ($row = pg_fetch_row($sql)) { $pdf->Cell(173, 6, utf8_decode("Tarifa 0"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($temp1, 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Tarifa 12"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($temp2, 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Iva 12%"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($temp3, 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Descuento"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($temp4, 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Total"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($temp5, 2), 20), 0, 1, 'C', 0); } $pdf->Output();
$pdf->Ln(5); $sql = pg_query("select factura_compra.descuento_compra,factura_compra.tarifa0,factura_compra.tarifa12,factura_compra.iva_compra,factura_compra.total_compra from factura_compra,detalle_factura_compra,productos where factura_compra.id_factura_compra=detalle_factura_compra.id_factura_compra and detalle_factura_compra.cod_productos=productos.cod_productos and detalle_factura_compra.id_factura_compra='{$_GET['id']}' LIMIT 1"); while ($row = pg_fetch_row($sql)) { $pdf->Cell(173, 6, utf8_decode("Descuento"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[0], 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Tarifa 0"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[1], 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Tarifa 12"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[2], 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Iva 12%"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[3], 2), 20), 0, 1, 'C', 0); $pdf->Cell(173, 6, utf8_decode("Total"), 0, 0, 'R', 0); $pdf->Cell(35, 6, maxCaracter(truncateFloat($row[4], 2), 20), 0, 1, 'C', 0); } ////////// $sql = pg_query("select * from series_compra,factura_compra,productos where factura_compra.id_factura_compra=series_compra.id_factura_compra and productos.cod_productos=series_compra.cod_productos and series_compra.id_factura_compra='{$_GET['id']}'"); if (pg_num_rows($sql)) { $pdf->AddPage(); $pdf->Cell(205, 7, utf8_decode("NÚMEROS DE SERIE"), 0, 1, 'C', 0); $pdf->Cell(50, 5, utf8_decode("Cod. Producto"), 1, 0, 'C', 0); $pdf->Cell(95, 5, utf8_decode("Descripción"), 1, 0, 'C', 0); $pdf->Cell(30, 5, utf8_decode("Nro. Serie"), 1, 0, 'C', 0); $pdf->Cell(30, 5, utf8_decode("Nro. Factura"), 1, 1, 'C', 0); while ($row = pg_fetch_row($sql)) { $pdf->Cell(50, 6, maxCaracter(utf8_decode($row[28]), 20), 0, 0, 'C', 0); $pdf->Cell(95, 6, maxCaracter(utf8_decode($row[30]), 60), 0, 0, 'C', 0); $pdf->Cell(30, 6, maxCaracter(utf8_decode($row[3]), 20), 0, 0, 'C', 0); $pdf->Cell(30, 6, maxCaracter(utf8_decode($row[17]), 20), 0, 1, 'C', 0); } } $pdf->Output();
} $sql2 = pg_query("SELECT * FROM gastos where fecha_actual between '{$_GET['inicio']}' and '{$_GET['fin']}' and id_factura_venta='{$id_fac}' order by id_factura_venta asc"); $pdf->SetX(1); $pdf->Cell(25, 6, utf8_decode('Nro. Factura'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Fecha Factura'), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode('Total Venta'), 1, 0, 'C', 0); $pdf->Cell(45, 6, utf8_decode('Descripción'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Fecha Pago'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Valor Pago'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Saldo'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Acumulado'), 1, 1, 'C', 0); $valor_pagado = 0; while ($row2 = pg_fetch_row($sql2)) { $pdf->SetX(1); $pdf->Cell(25, 6, substr($num_fac, 8, 30), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($fecha), 0, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode($total), 0, 0, 'C', 0); $pdf->Cell(45, 6, maxCaracter(utf8_decode($row2[6]), 20), 0, 0, 'L', 0); $pdf->Cell(20, 6, utf8_decode($row2[4]), 0, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode($row2[7]), 0, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode($row2[8]), 0, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode($row2[9]), 0, 1, 'C', 0); $valor_pagado = $valor_pagado + $row2[7]; } $pdf->SetX(1); $pdf->Cell(207, 0, utf8_decode(""), 1, 1, 'R', 0); $pdf->Cell(180, 6, utf8_decode("Utilida por factura"), 0, 0, 'R', 0); $pdf->Cell(30, 6, maxCaracter(number_format($total - $valor_pagado, 2, ',', '.'), 20), 0, 1, 'C', 0); $pdf->Ln(3); } $pdf->Output();
$pdf->Cell(30, 6, utf8_decode("Precio Minorista"), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode("Precio Mayorista"), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode("Stock"), 1, 1, 'C', 0); if ($_GET['marca'] == "" && $_GET['categoria'] == "") { $sql = pg_query("select codigo,cod_barras,articulo,iva_minorista,iva_mayorista,stock,categoria,marca from productos "); } else { if ($_GET['marca'] == "" && $_GET['categoria'] != "") { $sql = pg_query("select codigo,cod_barras,articulo,iva_minorista,iva_mayorista,stock,categoria,marca from productos where categoria='{$_GET['categoria']}'"); } else { if ($_GET['marca'] != "" && $_GET['categoria'] == "") { $sql = pg_query("select codigo,cod_barras,articulo,iva_minorista,iva_mayorista,stock,categoria,marca from productos where marca='{$_GET['marca']}'"); } else { if ($_GET['marca'] != "" && $_GET['categoria'] != "") { $sql = pg_query("select codigo,cod_barras,articulo,iva_minorista,iva_mayorista,stock,categoria,marca from productos where categoria='{$_GET['categoria']}' and marca='{$_GET['marca']}'"); } else { } } } } $pdf->SetFont('Amble-Regular', '', 9); $pdf->SetX(5); while ($row = pg_fetch_row($sql)) { $pdf->SetX(1); $pdf->Cell(30, 5, utf8_decode($row[0]), 0, 0, 'L', 0); $pdf->Cell(95, 5, maxCaracter(utf8_decode($row[2]), 50), 0, 0, 'L', 0); $pdf->Cell(30, 5, utf8_decode($row[3]), 0, 0, 'C', 0); $pdf->Cell(30, 5, utf8_decode($row[4]), 0, 0, 'C', 0); $pdf->Cell(20, 5, utf8_decode($row[5]), 0, 0, 'C', 0); $pdf->Ln(5); } $pdf->Output();
while ($row1 = pg_fetch_row($sql1)) { if ($repetido == 0) { $pdf->SetX(1); $pdf->Cell(35, 6, utf8_decode('Cod, Cuenta'), 1, 0, 'C', 0); $pdf->Cell(45, 6, utf8_decode('Descripción'), 1, 0, 'C', 0); $pdf->Cell(40, 6, utf8_decode('Tipo Ref.'), 1, 0, 'C', 0); $pdf->Cell(45, 6, utf8_decode('# Ref.'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Débito'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Crédito'), 1, 1, 'C', 0); $repetido = 1; $contador = 1; } $pdf->Cell(35, 6, maxCaracter(utf8_decode($row1[1]), 15), 0, 0, 'L', 0); $pdf->Cell(45, 6, maxCaracter(utf8_decode($row1[2]), 20), 0, 0, 'L', 0); $pdf->Cell(40, 6, maxCaracter(utf8_decode($row1[3]), 20), 0, 0, 'L', 0); $pdf->Cell(45, 6, maxCaracter(utf8_decode($row1[4]), 22), 0, 0, 'L', 0); $pdf->Cell(20, 6, maxCaracter(utf8_decode($row1[5]), 15), 0, 0, 'C', 0); $pdf->Cell(20, 6, maxCaracter(utf8_decode($row1[6]), 15), 0, 1, 'C', 0); $repetido = 1; } } if ($contador > 0) { $pdf->SetX(1); $pdf->Cell(205, 0, utf8_decode(''), 1, 1, 'R', 1); $pdf->Cell(166, 6, utf8_decode('Totales:'), 0, 0, 'R', 0); $pdf->Cell(20, 6, number_format($pdf->total, 2, ',', '.'), 0, 0, 'C', 0); $pdf->Cell(20, 6, number_format($pdf->total1, 2, ',', '.'), 0, 1, 'C', 0); $pdf->Cell(120, 6, utf8_decode('CONCEPTO: '), 0, 0, 'R', 0); $pdf->Cell(85, 6, maxCaracter($pdf->concepto, 40), 0, 0, 'L', 0); } $pdf->Output();
$pdf->SetTextColor(0, 0, 0); while ($row = pg_fetch_row($sql)) { $temp_1 = number_format($row[3], 2, ',', '.'); $pdf->Text(5, $yy, maxCaracter(utf8_decode($row[0]), 3), 0, 1, 'L', 0); $array = ceil_caracter($row[1], 35); if (sizeof($array) > 1) { $zz = $yy; for ($i = 0; $i < sizeof($array); $i++) { $pdf->Text(20, $zz, utf8_decode($array[$i]), 0, 0, 'J', 0); $zz = $zz + 3; } $yy = $yy + 4; } else { $pdf->Text(20, $yy, maxCaracter(utf8_decode($row[1]), 30), 0, 0, 'L', 0); } $pdf->Text(150, $yy, maxCaracter(utf8_decode($row[2]), 6), 0, 0, 'L', 0); $pdf->Text(180, $yy, maxCaracter($temp_1, 6), 0, 0, 'L', 0); $yy = $yy + 4; } /////////pie $subtotal = truncateFloat($iva12, 2); $descuento_venta = truncateFloat($descuento_venta, 2); $iva_venta = truncateFloat($iva_venta, 2); $iva0 = truncateFloat($iva0, 2); $total_venta = truncateFloat($total_venta, 2); $pdf->Text(180, 177, maxCaracter($subtotal, 5), 0, 1, 'L', 0); $pdf->Text(180, 182, maxCaracter($iva0, 5), 0, 1, 'L', 0); $pdf->Text(180, 187, maxCaracter($iva_venta, 5), 0, 1, 'L', 0); // $pdf->Text(180, 192, maxCaracter($descuento_venta,5),0,1, 'L',0); $pdf->Text(180, 192, maxCaracter($total_venta, 10), 0, 1, 'L', 0); $pdf->Output();
} $pdf = new PDF('P', 'mm', 'a4'); $pdf->AddPage(); $pdf->SetMargins(0, 0, 0, 0); $pdf->AliasNbPages(); $pdf->AddFont('Amble-Regular', '', 'Amble-Regular.php'); $pdf->SetFont('Amble-Regular', '', 10); $pdf->SetFont('Arial', 'B', 9); $pdf->SetX(5); $pdf->SetFont('Amble-Regular', '', 9); $total = 0; $sql = pg_query("select P.id_proveedor,P.identificacion,F.id_factura_compra,numero_serie from proveedor P,factura_compra F where P.id_proveedor='{$_GET['id']}' and F.id_proveedor=P.id_proveedor"); while ($row = pg_fetch_row($sql)) { $sql1 = pg_query("select D.id_detalle_factura_compra,P.codigo,P.descripcion,P.precio_minorista,P.precio_mayorista,P.stock,D.precio,D.total,D.cantidad from detalle_factura_compra D,productos P where D.id_productos=P.id_productos and D.id_factura_compra='{$row['2']}' order by id_detalle_factura_compra asc"); while ($row1 = pg_fetch_row($sql1)) { $pdf->SetX(1); $pdf->Cell(35, 5, maxCaracter(utf8_decode($row[3]), 20), 0, 0, 'L', 0); $pdf->Cell(30, 5, maxCaracter(utf8_decode($row1[1]), 12), 0, 0, 'L', 0); $pdf->Cell(60, 5, maxCaracter(utf8_decode($row1[2]), 40), 0, 0, 'L', 0); $pdf->Cell(30, 5, maxCaracter(utf8_decode($row1[6]), 10), 0, 0, 'C', 0); $pdf->Cell(30, 5, maxCaracter(utf8_decode($row1[7]), 10), 0, 0, 'C', 0); $pdf->Cell(20, 5, maxCaracter(utf8_decode($row1[8]), 10), 0, 0, 'C', 0); $total = $total + $row1[7]; $pdf->Ln(5); } } $pdf->SetX(1); $pdf->Ln(5); $pdf->Cell(185, 5, "Totales:", 0, 0, 'R', 0); $pdf->Cell(20, 5, number_format($total, 2, ',', '.'), 0, 1, 'C', 0); $pdf->Output();
$pdf->Ln(3); } $sql2 = pg_query("select D.cod_productos, P.codigo, P.articulo, D.p_costo, D.p_venta, D.disponibles, D.existencia, D.diferencia from inventario I, detalle_inventario D, productos P where D.cod_productos = P.cod_productos and I.id_inventario = D.id_inventario and D.id_inventario='{$_GET['id']}'"); $pdf->SetX(1); $pdf->Cell(30, 6, utf8_decode('Código'), 1, 0, 'C', 0); $pdf->Cell(55, 6, utf8_decode('Producto'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Precio Costo'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Precio Venta'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Stock'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Existencia'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Diferencia'), 1, 1, 'C', 0); $total1 = 0; $total2 = 0; while ($row = pg_fetch_row($sql2)) { $pdf->SetX(1); $total1 = $total1 + $row[3]; $total2 = $total2 + $row[4]; $pdf->Cell(30, 6, maxCaracter(utf8_decode($row[1]), 15), 0, 0, 'C', 0); $pdf->Cell(55, 6, maxCaracter(utf8_decode($row[2]), 30), 0, 0, 'L', 0); $pdf->Cell(25, 6, utf8_decode($row[3]), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row[4]), 0, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode($row[5]), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row[6]), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row[7]), 0, 1, 'C', 0); } $pdf->SetX(1); $pdf->Cell(205, 0, utf8_decode(''), 1, 1, 'R', 1); $pdf->Cell(86, 6, utf8_decode('Totales:'), 0, 0, 'R', 0); $pdf->Cell(25, 6, number_format($total1, 2, ',', '.'), 0, 0, 'C', 0); $pdf->Cell(25, 6, number_format($total2, 2, ',', '.'), 0, 1, 'C', 0); $pdf->Output();
$pdf->Cell(60, 6, utf8_decode('Producto'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Cantidad'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Precio Costo'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('Precio Venta'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Total'), 1, 1, 'C', 0); $temp1 = $row[8]; $temp2 = $row[9]; $temp3 = $row[10]; $temp4 = $row[11]; $temp5 = $row[12]; } $sql = pg_query("select *from detalle_egreso,productos where detalle_egreso.cod_productos=productos.cod_productos and id_egresos='{$_GET['comprobante']}'"); while ($row = pg_fetch_row($sql)) { $pdf->Cell(25, 6, utf8_decode($row[1]), 0, 0, 'C', 0); $pdf->Cell(30, 6, maxCaracter(utf8_decode($row[9]), 15), 0, 0, 'L', 0); $pdf->Cell(60, 6, maxCaracter(utf8_decode($row[11]), 25), 0, 0, 'L', 0); $pdf->Cell(20, 6, utf8_decode($row[3]), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row[4]), 0, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode($row[17]), 0, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode($row[6]), 0, 1, 'C', 0); } $pdf->SetX(1); $pdf->Cell(205, 0, utf8_decode(''), 1, 1, 'R', 1); $pdf->Cell(186, 6, utf8_decode('Tarifa 0:'), 0, 0, 'R', 0); $pdf->Cell(20, 6, number_format($temp1, 2, ',', '.'), 0, 1, 'C', 0); $pdf->SetX(1); $pdf->Cell(186, 6, utf8_decode('Tarifa 12:'), 0, 0, 'R', 0); $pdf->Cell(20, 6, number_format($temp2, 2, ',', '.'), 0, 1, 'C', 0); $pdf->SetX(1); $pdf->Cell(186, 6, utf8_decode('Iva:'), 0, 0, 'R', 0); $pdf->Cell(20, 6, number_format($temp3, 2, ',', '.'), 0, 1, 'C', 0);
$sub = 0; $contador = 0; $pv = 0; $pc = 0; $util = 0; $sql1 = pg_query("select * from factura_venta where fecha_actual between '{$_GET['inicio']}' and '{$_GET['fin']}' and estado='Activo'"); while ($row1 = pg_fetch_row($sql1)) { $pv = 0; $pc = 0; $util = 0; $sql2 = pg_query("select * from detalle_factura_venta D, productos P where D.id_productos=P.id_productos and id_factura_venta='{$row1['0']}'"); while ($row2 = pg_fetch_row($sql2)) { $pv = $pv + $row2[3] * $row2[4]; $pc = $pc + $row2[3] * $row2[15]; $util = $util + ($row2[3] * $row2[4] - $row2[3] * $row2[15]); } $pdf->SetX(1); $pdf->Cell(50, 6, maxCaracter($row1[5], 30), 0, 0, 'C', false); $pdf->Cell(40, 6, utf8_decode('Factura'), 0, 0, 'C', false); $pdf->Cell(25, 6, utf8_decode($pv), 0, 0, 'C', false); $pdf->Cell(25, 6, utf8_decode($pc), 0, 0, 'C', false); $pdf->Cell(20, 6, utf8_decode($util), 0, 0, 'C', false); $pdf->Cell(25, 6, utf8_decode($row1[6]), 0, 0, 'C', false); $pdf->Cell(20, 6, utf8_decode($row1[10]), 0, 1, 'C', false); $total = $total + $util; } $pdf->Ln(2); $pdf->Cell(205, 0, utf8_decode(''), 1, 1, 'R', 0); $pdf->Cell(187, 6, utf8_decode('Total Utilidad'), 0, 0, 'R', 0); $pdf->Cell(20, 6, number_format($total, 2, ',', '.'), 0, 0, 'C', 0); $pdf->Output();
$pdf->Cell(30, 6, utf8_decode($row1[15]), 1, 1, 'L', true); $pdf->Ln(3); $pdf->SetX(1); $pdf->Cell(25, 6, utf8_decode('Cod. Producto'), 1, 0, 'C', 0); $pdf->Cell(60, 6, utf8_decode('Descripción'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Cantidad'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('P. Venta'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('T. P. Venta'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('P. Compra'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('T. P. Compra'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('Utilidad'), 1, 1, 'C', 0); $sql2 = pg_query("select * from detalle_factura_venta D, productos P where D.id_productos=P.id_productos and id_factura_venta='{$row1['0']}'"); while ($row2 = pg_fetch_row($sql2)) { $pdf->SetX(1); $pdf->Cell(25, 6, maxCaracter($row2[10], 13), 0, 0, 'L', 0); $pdf->Cell(60, 6, maxCaracter($row2[12], 30), 0, 0, 'L', 0); $pdf->Cell(20, 6, $row2[3], 0, 0, 'C', 0); $pdf->Cell(20, 6, $row2[4], 0, 0, 'C', 0); $pdf->Cell(20, 6, $row2[3] * $row2[4], 0, 0, 'C', 0); $pdf->Cell(20, 6, $row2[15], 0, 0, 'C', 0); $pdf->Cell(20, 6, $row2[3] * $row2[15], 0, 0, 'C', 0); $pdf->Cell(20, 6, $row2[3] * $row2[4] - $row2[3] * $row2[15], 0, 0, 'C', 0); $sub = $sub + ($row2[3] * $row2[4] - $row2[3] * $row2[15]); $pdf->Ln(6); } $contador = 1; if ($contador > 0) { $pdf->Ln(2); $pdf->Cell(187, 6, utf8_decode('Total Utilidad por factura'), 0, 0, 'R', 0); $pdf->Cell(20, 6, number_format($sub, 2, ',', '.'), 0, 0, 'C', 0); $total = $total + $sub;
$proveedor = $row[24]; $fecha_compra = $row[5]; $num_fac_compra = $row[11]; } $sql = pg_query("select * from detalle_factura_compra,productos where detalle_factura_compra.cod_productos=productos.cod_productos and id_factura_compra='{$id_factura_compra}' and productos.cod_productos='{$id_producto}'"); while ($row = pg_fetch_row($sql)) { $precio_compra = $row[4]; } $pdf->SetFillColor(216, 216, 231); $pdf->Cell(100, 8, utf8_decode("RUC/CI:: " . $ci_cliente), 1, 0, 'L', true); $pdf->Cell(105, 8, utf8_decode("CLIENTE: " . $nombre_cliente), 1, 1, 'L', true); $pdf->Ln(2); $pdf->SetX(1); $pdf->Cell(30, 6, utf8_decode('Nro. Factura'), 1, 0, 'C', 0); $pdf->Cell(25, 6, utf8_decode('F. Venta'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('P. Venta'), 1, 0, 'C', 0); $pdf->Cell(40, 6, utf8_decode('Producto'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('N. Compra'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('F. Compra'), 1, 0, 'C', 0); $pdf->Cell(30, 6, utf8_decode('Proveedor'), 1, 0, 'C', 0); $pdf->Cell(20, 6, utf8_decode('P. Compra'), 1, 1, 'C', 0); $pdf->SetX(1); $pdf->Cell(30, 6, substr($num_fac_venta, 8, 30), 0, 0, 'C', 0); $pdf->Cell(25, 6, $fecha_venta, 0, 0, 'C', 0); $pdf->Cell(20, 6, $precio_venta, 0, 0, 'C', 0); $pdf->Cell(20, 6, maxCaracter($descripcion, 30), 0, 0, 'C', 0); $pdf->Cell(40, 6, substr($num_fac_compra, 8, 30), 0, 0, 'C', 0); $pdf->Cell(20, 6, $fecha_compra, 0, 0, 'C', 0); $pdf->Cell(30, 6, maxCaracter($proveedor, 20), 0, 0, 'C', 0); $pdf->Cell(20, 6, $precio_compra, 0, 0, 'C', 0); $pdf->Output();
$agrupados = array(); for ($i = 0; $i < count($codigo_producto); $i++) { $agrupados[$i]['codigo'] = $codigo_producto[$i]; $agrupados[$i]['nombre_producto'] = $nombre_producto[$i]; $agrupados[$i]['cantidad_producto'] = $cantidad_producto[$i]; $agrupados[$i]['stock_producto'] = $stock_producto[$i]; } array_multisort($agrupados, SORT_ASC); //print "<pre>"; print_r($agrupados); "</pre>\n"; $pdf->SetFont('Amble-Regular', '', 9); $pdf->SetX(5); for ($cont_vector = 0; $cont_vector < count($codigo_producto); $cont_vector++) { $pdf->SetX(1); $pdf->SetTextColor(0, 0, 0); $pdf->Cell(30, 5, utf8_decode($agrupados[$cont_vector]['codigo']), 0, 0, 'L', 0); $pdf->Cell(95, 5, maxCaracter(utf8_decode($agrupados[$cont_vector]['nombre_producto']), 50), 0, 0, 'L', 0); $pdf->Cell(30, 5, utf8_decode($agrupados[$cont_vector]['cantidad_producto']), 0, 0, 'C', 0); $pdf->Cell(30, 5, utf8_decode($agrupados[$cont_vector]['stock_producto']), 0, 0, 'C', 0); $faltante = $agrupados[$cont_vector]['stock_producto'] - $agrupados[$cont_vector]['cantidad_producto']; if ($faltante > 0) { $pdf->SetTextColor(240, 11, 11); $pdf->Cell(20, 5, utf8_decode('0'), 0, 0, 'C', 0); } else { $pdf->SetTextColor(240, 11, 11); $pdf->Cell(20, 5, utf8_decode(abs($faltante)), 0, 0, 'C', 0); } $pdf->Ln(5); $pdf->SetTextColor(0, 0, 0); } $pdf->Output(); ?>