<?php require_once('../Connections/cn_conexion.php'); ?>
<?php include_once("../includes/funciones.php");?>
<?php
$consulta=$_POST["consulta_carta"];
$sumagastos=$_POST["sumagastos"];
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_cn_conexion, $cn_conexion);
$query_rs_detcaja = "".$consulta."";
$rs_detcaja = mysql_query($query_rs_detcaja, $cn_conexion) or die(mysql_error());
$row_rs_detcaja = mysql_fetch_assoc($rs_detcaja);
$totalRows_rs_detcaja = mysql_num_rows($rs_detcaja);
?>
<?php
if($sumagastos>0){
	$rotuloprincipal="PENDIENTE DE PAGO";
	$text1="Reembolso de gastos de caja Nº: ".$row_rs_detcaja['num_caja'].", con un saldo pendiente de pago de S/. ".number_format($sumagastos,2)."";
	$text2="Si gira un cheque sirvase hacerlo a nombre de ESTUDIO YORI ABOGA DOS a abonar a la cuenta corriente  Scotiabank MN Nº: 0010232950 del Estudio.";
	}else{
		$rotuloprincipal="";
		$text1="Rendición de cuenta Nº: ".$row_rs_detcaja['num_caja'].", con un saldo a favor de ustedes de S/. ".number_format((-1)*$sumagastos,2)." el cual sera abonado a su cuenta para futuros gastos.";
		$text2="";
		}
?>
<?php
require('../fpdf/fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->Image('../imagenes/logo.gif' , 10 ,10, 63 , 13,'gif', 'http://www.yoriabogados.com.pe');

$pdf->SetFont('Arial','B',25);
$pdf->Cell(0,40,utf8_decode($rotuloprincipal),0,1,'C');

$pdf->SetFont('Arial','B',11);
$pdf->SetXY(30,50);
$sTxt="Para:";
$pdf->multiCell(50, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->SetXY(80,50);
$sTxt=$row_rs_detcaja['nom_cliente'];
$pdf->multiCell(100, 5, utf8_decode($sTxt), 0, "L", 0); 

$pdf->SetXY(30,55);
$sTxt="Dirección";
$pdf->multiCell(50, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->SetXY(80,55);
$sTxt=$row_rs_detcaja['dir_cliente'];
$pdf->multiCell(100, 5, utf8_decode($sTxt), 0, "L", 0); 

$pdf->SetXY(30,60);
$sTxt="ATN:";
$pdf->multiCell(50, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->SetXY(80,60);
$sTxt=$row_rs_detcaja['contacto'];;
$pdf->multiCell(100, 5, utf8_decode($sTxt), 0, "L", 0); 

$pdf->SetXY(30,65);
$sTxt="DE:";
$pdf->multiCell(50, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->SetXY(80,65);
$sTxt="PATRICIA SALAS";
$pdf->multiCell(100, 5, utf8_decode($sTxt), 0, "L", 0); 

$pdf->SetXY(30,70);
$sTxt="FECHA:";
$pdf->multiCell(50, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->SetXY(80,70);
$sTxt=date("d-m-Y");;
$pdf->multiCell(100, 5, utf8_decode($sTxt), 0, "L", 0); 

$pdf->Ln(30);

$pdf->SetFont('Arial','B',12);
$sTxt="Se envia:";
$pdf->SetX(30);
$pdf->multiCell(150, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->Ln();
$pdf->SetX(30);
$sTxt=$text1;
$pdf->multiCell(150, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->SetX(30);
$sTxt=$text2;
$pdf->multiCell(150, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->Ln();
$pdf->SetX(30);
$sTxt="Atte:";
$pdf->multiCell(150, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->SetFont('Arial','B',10);
$pdf->Ln(10);
$pdf->SetX(30);
$sTxt="Patricia Salas Ponce";
$pdf->multiCell(150, 5, utf8_decode($sTxt), 0, "L", 0); 
$pdf->SetX(30);
$sTxt="Administradora";
$pdf->multiCell(150, 5, utf8_decode($sTxt), 0, "L", 0); 

$pdf->Image('../imagenes/pie.jpg' , 45 ,280, 120 , 8,'jpg', 'http://www.yoriabogados.com.pe');


$pdf->Output();
?>
