<?php

if ($_POST) {
    switch ($_POST['opcion']) {
        case 'finanzas':
            include_once "../controller/cContratos.php";
            $cContratos = new cContratos();
            echo $cContratos->listaConvenios($_POST['fecha_inicio'], $_POST['fecha_fin'], $_POST['activo']);
            sleep(1);
            break;
        case 'nuevoConvenio':
            include_once "../controller/cContratos.php";
            $cContratos = new cContratos();
            $datos = $cContratos->getContratosVig($_POST['fecha_inicio'], $_POST['fecha_fin'], $_POST['activo']);
            ?>
				<table id="example" class="table table-hover table-striped" data-page-length='15'>
			        <thead>
			            <tr>
			            	<th>Clave persona</th>
			            	<th>Clave expedente</th>
			            	<th>Folio de Contrato</th>
			                <th>Nombre/Raz&oacute;n</th>
			                <th>Fecha del Contrato</th>
			                <th>Monto</th>
			                <th>Plazo(meses)</th>
			                <th>Acciones</th>
			            </tr>
			        </thead>
			        <tbody style="text-transform: uppercase;">
			        <?php 
            while ($row = $datos->NextRow()) {
?>
</h4>
		</div>
		<div class="modal-body">
			<div class="row">
				<div class="col-lg-12" id="cuerpoDetContrato">
					<div class="row">
						<div class="col-lg-10 col-lg-offset-1">
		<?php 
if ($rr == 0 && $rrr == 0) {
    ?>
			<h3>EL EXPEDIENTE NO CUENTA CON UN CONTRATO ASIGNADO</h3>
			 <?php 
} else {
    $r = $con->Fetch($query);
    $contr = new cContratos();
    $detalles = $contr->getDetallesContrato($r);
    ?>
		<table class="table" style="text-transform: uppercase">
			<tr>
				<th>FOLIO DE PRESTAMO</th>
				<td><?php 
    echo $detalles['id_contrato'];
    ?>
</td>
			</tr>
			<tr>
				<th>CLAVE DEL CLIENTE</th>
				<td><?php 
    echo $detalles['id_persona'];
    ?>
<?php

if ($_POST) {
    include_once "../controller/cContratos.php";
    $cContratos = new cContratos();
    switch ($_POST['tipo']) {
        case 'listaContratos':
            $cContratos->listaContratos($_POST['id_cliente']);
            break;
        default:
            # code...
            break;
    }
}
            <tr>
              <td>Clave Cliente</td>
              <th>Folio de Contrato</th>
                <th>Nombre/Raz&oacute;n</th>
                <th>Fecha del Contrato</th>
                <th>Monto</th>
                <th>Plazo(meses)</th>
                <th>Acciones</th>
            </tr>
        </thead>

        <tbody style="text-transform: uppercase;">
          <?php 
include_once '../controller/cContratos.php';
include_once '../controller/cUtilerias.php';
$contr = new cContratos();
$util = new cUtilerias();
$contratos = $contr->getContratosVig($inicio, $fin, "true");
while ($l = $contratos->NextRow()) {
    ?>
          <tr>
            <td><?php 
    echo $l['id_persona'];
    ?>
</td>
            <td><?php 
    echo $l['id_contrato'];
    ?>
</td>
            <td class="odd"><?php 
    echo $l['razon'] . $l['cliente'];
<?php

include "../controller/cContratos.php";
$regContrato = new cContratos();
echo $regContrato->validaClte($_POST['idExpClte'], $_POST['cantidad'], null, null, null, null, null);
<?php

include_once "../controller/cContratos.php";
include_once "../controller/cUtilerias.php";
$contra = new cContratos();
$tabla = $contra->showTablaAmortizacion($_POST['contrato']);
// print_r($tabla);
$det = $contra->getDetallesContrato($_POST['contrato']);
$util = new cUtilerias();
?>
 <!--mensaje de aviso de ubicacion-->
                <div class="row no-print">
                	<div class="col-lg-12">
                		<div class="alert alert-info">
                			USTED SE ENCUENTRA LISTANDO TABLA DE AMORTIZACION(ORIGINAL)
                		</div>
                	</div>
                </div>
 <div class="row">
 	<div class="col-lg-6">
 		<!-- <a href="../view/listaPrestamo.php" class="btn btn-danger">Regresar</a> -->
 		<?php 
if (isset($_POST['convenio'])) {
    echo "<a href='../view/listarConvenios.php' class='btn btn-danger'>Regresar</a>";
} else {
    echo "<a href='../view/listaPrestamo.php' class='btn btn-danger'>Regresar</a>";
}
?>
 		<a href="#" class="btn btn-success" onclick="imprimirTabla()">Imprimir</a>
 		<!-- <a href="#" class="btn btn-success" onclick="window.print()">Imprimir</a> -->
 	</div>
 <button class="btn btn-danger" onclick="imprimeContrato()">Imprimir</button>
<div style="background-color: white">
<div class="row">
	<div class="col-md-5">
		<img src="../logo.png" class="img-responsive" style="width: 30%;height: 30%"  />
	</div>
</div>
<div class="row">
<div class="col-lg-12">
<?php 
header('Content-Type: text/html; charset=utf-8');
include_once "../controller/cContratos.php";
$contrato = new cContratos();
$texto = $contrato->getTextoContratos($_POST['contrato']);
echo $texto;
?>
</div>
 </div>
 </div>
 <script>
 	
 </script>
<?php

include_once "../controller/cContratos.php";
$contr = new cContratos();
$r = $contr->getNumContratosVif($_POST['id']);
$m = $contr->getNumpagsAtrasados($_POST['id']);
if ($r != 0) {
    echo "EL CLIENTE TIENE CONTRATOS VIGENTES <br />";
    echo $r;
}
if ($m != 0) {
    echo "EL CLIENTE HA TENIDO PAGOS ATRASADOS EN SUS ANTERIORES CONTRATOS <br/> ";
}
if ($r == 0 && $m == 0) {
    echo "0";
}
							</table>
						</div>
					</div>
				</div>
				<div class="tab-pane" id="contrato">
					<div class="row">
						<div class="col-lg-10 col-lg-offset-1">
							<center>
								<h3>Detalles del Contrato</h3>
							</center>
							<?php 
if ($dalerta['contrato'] != '0.0') {
    ?>
							<table class="table table-striped" style="text-transform: uppercase">
								<?php 
    $contra = new cContratos();
    $dcontra = $contra->getDetallesContrato($dalerta['contrato']);
    ?>
								<tr>
									<th>Cliente</th>
									<td><?php 
    echo $dcontra['razon'] . "" . $dcontra['nombres'] . " " . $dcontra['a_pat'] . " " . $dcontra['a_mat'];
    ?>
</td>
								</tr>
								<tr>
									<th>Contrato</th>
									<td><?php 
    echo $dalerta['contrato'];
    ?>
</td>
<?php

include_once "../controller/cContratos.php";
$contr = new cContratos();
$detalles = $contr->getDetallesContrato($_POST['contrato']);
?>
<div class="row">
	<div class="col-lg-10 col-lg-offset-1">
		<table class="table" style="text-transform: uppercase">
			<tr>
				<th>FOLIO DE PRESTAMO</th>
				<td><?php 
echo $detalles['id_contrato'];
?>
</td>
			</tr>
			<tr>
				<th>CLAVE DEL CLIENTE</th>
				<td><?php 
echo $detalles['id_persona'];
?>
</td>
			</tr>
			<tr>
				<th>NOMBRE CLIENTE</th>
				<td><?php 
echo $detalles['razon'] . " " . $detalles['nombres'] . " " . $detalles['a_pat'] . " " . $detalles['a_mat'];
?>
</td>
			</tr>
			<tr>
             		<div class="col-lg-1">
             		<div class="form-group">
					<label style="visibility: hidden">visibe</label>
             			<p class="btn btn-primary" onclick="filtrar()">
             				FILTRAR
             			</p>
             		</div>
             		</div>
            	</div>
            </div>
            <div style="display: block;" class="grid-body " id="contenedorPP">
<div  class="dataTables_wrapper form-inline">
<?php 
include_once "../controller/cContratos.php";
$contratos = new cContratos();
$contratos->listaConvenios($inicio, $fin, 'true');
?>

    </div>
    </div>
    </div>
    </div>
    </div>
</div>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                            </div>
<?php

include_once "../controller/cContratos.php";
$contra = new cContratos();
$texto = $contra->getTextoContratos($_GET['contrato']);
require '../fpdf/fpdf.php';
class ImprimeTabla extends FPDF
{
    function Header()
    {
        $this->bgImage(10, 10);
    }
    function Footer()
    {
        // Position at 1.5 cm from bottom
        $this->SetY(-15);
        // Arial italic 8
        $this->SetFont('Arial', 'I', 8);
        // Page number
        $this->Cell(0, 10, 'Pagina ' . $this->PageNo() . '/{nb}', 0, 0, 'C');
    }
    function bgImage($x, $y)
    {
        //Text rotated around its origin
        $this->Image("../logo_wm.png", $x, $y, 160, 180, "png");
    }
}
$pdf = new ImprimeTabla();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times', '', 7);
        <div class="page-container row-fluid">

            <!-- BEGIN PAGE CONTAINER-->
            <div class="page-content"> 
<?php 
include_once "../controller/cContratos.php";
$checon = new cContratos();
$rep = $checon->contratarSObSol($_POST['idClte']);
//checa si tiene activado la opcion dce prestar sin obligados solidarios
$asig = $checon->checaExpAsignados($_POST['idClte']);
//checa si tiene expedientes asociados
$lugar = "contenedorP";
//lugar para escribir en ajax
$ruta = "../helper/fomularioContrato.php";
//archivo que se va a cargar en ajax
$idck = $_POST['idClte'];
//id del cliente que se va a mostrar en el formulario
if ($asig == FALSE) {
    if ($rep == 0) {
        include "../helper/pidePassAdmin.php";
    } else {
        include "../helper/fomularioContrato.php";
    }
} else {
    include "../helper/fomularioContrato.php";
}
?>
</div>
</div>
																		<tr>
																			<th>Nombre/Razon</th>
																			<th>Ciudad</th>
																			<th>Estado</th>
																			<th>CURP</th>
																			<th>RFC</th>
																			<th>Telefono</th>
																			<th>Tipo Expediente</th>
																			<th>Acciones</th>
																		</tr>
																	</thead>
																	<!--cuerpo de la tabla empleados-->
																	<tbody style="text-transform: uppercase;">
																		<?php 
include '../controller/cContratos.php';
$empl = new cContratos();
$emples = $empl->getExpedientesSinContrato($_POST['inicio'], $_POST['fin']);
while ($em = $emples->NextRow()) {
    ?>
																		<tr>
																			<td><?php 
    echo $em['razon'] . " " . $em['nombre'] . " " . $em['a_pat'] . " " . $em['a_mat'] . " ";
    ?>
</td>
																			<td><?php 
    echo $em['ciudad'];
    ?>
</td>
																			<td><?php 
    echo $em['estado'];
    ?>
        <thead>
            <tr>
                <td>Clave Cliente</td>
            	<th>Folio de Contrato</th>
                <th>Nombre/Raz&oacute;n</th>
                <th>Fecha del Contrato</th>
                <th>Monto</th>
                <th>Plazo(meses)</th>
                <th>Acciones</th>
            </tr>
        </thead>

        <tbody style="text-transform: uppercase;">
        	<?php 
include_once '../controller/cContratos.php';
$contr = new cContratos();
$contratos = $contr->getContratosVig($_POST['inicio'], $_POST['fin'], $_POST['activo']);
while ($l = $contratos->NextRow()) {
    ?>
        	<tr>
                <td><?php 
    echo $l['id_persona'];
    ?>
</td>
        		<td><?php 
    echo $l['id_contrato'];
    ?>
</td>
        		<td class="odd"><?php 
    echo $l['razon'] . $l['cliente'];
    ?>
            				<tr>
            					<th>Clave</th>
            					<th>Nombre/Razon</th>
            					<th>Ciudad</th>
            					<th>CURP</th>
            					<th>RFC</th>
            					<th>Telefono</th>
            					<th>Tipo Expediente</th>
            					<th>Acciones</th>
            				</tr>
            			</thead>
            			<!--cuerpo de la tabla empleados-->
            			<tbody style="text-transform: uppercase;">
            				<?php 
include '../controller/cContratos.php';
$empl = new cContratos();
$emples = $empl->getExpedientesSinContrato($inicio, $fin);
while ($em = $emples->NextRow()) {
    ?>
            					<tr>
            						<td><?php 
    echo $em['clave_agrupadora'];
    ?>
</td>
            						<td><?php 
    echo $em['razon'] . " " . $em['nombre'] . " " . $em['a_pat'] . " " . $em['a_mat'] . " ";
    ?>
</td>
            						<td><?php 
    echo $em['ciudad'];
    ?>
<?php

include "../controller/cContratos.php";
$regContrato = new cContratos();
//El monto a pagar quincenalmente por parte del cliente para un préstamo debe de ser como máximo la tercera parte de lo que ellos tengan de ingreso.
if ($_POST) {
    switch ($_POST['opcion']) {
        case 'newContrato':
            $totalpagar = $_POST['tabono'] * ($_POST['nmeses'] * $_POST['tipopago']);
            //total a pagar del credito
            //registra el prestamo en la base de datos
            $folio = $regContrato->newContrato($_POST['idExpClte'], 1, 1, $_POST['cantidad'], $_POST['nmeses'], $_POST['tabono'], $_POST['ffinicio'], $_POST['ffin'], $_POST['tipopago'], $totalpagar, $_POST['cat']);
            // $folio=1;
            echo $folio;
            break;
        case 'tablaAmortizacion':
            $total = $_POST['total'];
            $tasa = $_POST['tasa'];
            $tipopago = $_POST['tipop'];
            $nabon = $_POST['nabon'];
            $abono = $_POST['abono'];
            $fecha = $_POST['fecha'];
            $folioContrato = $_POST['folioContrato'];
            print_r($_POST);
            $regContrato->setTablaAmortizacion($total, $tasa, $tipopago, $nabon, $abono, $fecha, $folioContrato);
            // header('Location: ../view/listaPrestamo.php');
            break;
    }
}
// $tasa=$_POST['porcentajePrestamoOrdinario'];
// $folio=$regContrato->
	<div class="row">
		<div class="col-lg-12">
<table id="example" class="table table-hover dataTable" data-page-length='25'>
        <thead>
            <tr>
                <th>Nombre/Raz&oacute;n</th>
                <th>Estado</th>
                <th>Ciudad</th>
                <th>Acciones</th>
            </tr>
        </thead>
 
        <tbody style="text-transform: uppercase;">
        	<?php 
include '../controller/cContratos.php';
$cont = new cContratos();
$con = $cont->getContratosVig();
while ($l = $con->NextRow()) {
    ?>
        	<tr>
        		<td><?php 
    echo $l['razon'] . ' ' . $l['nombre'] . ' ' . $l['a_pat'] . ' ' . $l['a_mat'];
    ?>
</td>
        		<td><?php 
    echo $l['monto'];
    ?>
</td>
        		<td><?php 
    echo $l['fecha_inicio'];
    ?>
<?php

include_once "../controller/cContratos.php";
include_once "../controller/cUtilerias.php";
$util = new cUtilerias();
$contra = new cContratos();
require '../fpdf/fpdf.php';
class ImprimeTabla extends FPDF
{
    function Header()
    {
        $this->Image("../logo.png", 10, 6, 30);
        // Arial bold 15
        $this->SetFont('Arial', 'B', 10);
        // Move to the right
        $this->Cell(80);
        // Title
        $this->Cell(30, 5, 'TABLA DE AMORTIZACION', 0, 0, 'C');
        $this->Ln();
        $this->Cell(80);
        $this->SetFont('Arial', 'i', 10);
        $this->Cell(30, 5, "CLIENTE: " . strtoupper($_GET['cliente']), 0, 0, "C");
        $this->Ln();
        // $this -> Cell(30, 5, "FECHA DE IMPRESION: " . date("Y-m-d H:i:s"), 0, 0, "C");
        // Line break
        $this->Ln(20);
    }
    function Footer()
    {
        // Position at 1.5 cm from bottom
        $this->SetY(-15);
<div class="page-container row-fluid">
	<!-- BEGIN PAGE CONTAINER-->
	<div class="page-content">
	<?php 
include_once "../controller/cContratos.php";
include_once "../controller/cUtilerias.php";
$expe = new cContratos();
$util = new cUtilerias();
$clte = $expe->getDetallesContrato($_POST['contrato']);
//print_r($clte);
?>
<div class="row">
	<input type="hidden" name="" id="id_cliente" value="<?php 
echo $clte['id_cliente'];
?>
">
		<!-- Modal para registrar un convenio-->
		<div class="modal fade" id="modalContratoConvenioNvo" tabindex="-1" role="modal" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<h4 class="modal-title" id="myModalLabel">PAR&Aacute;METROS DEL CONVENIO PARA EL CLIENTE:
							<strong style="text-transform: uppercase"><?php 
echo $clte['razon'] . " " . $clte['nombres'] . " " . $clte['a_pat'] . " " . $clte['a_mat'];
?>
</strong> </h4>
					</div>
					<div class="modal-body">
						<!-- parametros de prestamo -->
	<form id="formConveExpe" name="formContratoExp" >
		<!-- id del clte-->