<?php

@session_start();
include_once "../controller/cPagos.php";
include_once "../model/mAlertasAutomaticas.php";
$pagos = new cPagos();
$alert = new AlertasMan();
// $m=$pagos->regPagAdmin($_POST['asientolastpago'],$_POST['monto'],$_POST['banco'], $_POST['sucursal'], $_POST['ctaBanco'], $_POST['moneda'],$_POST['insmone'], $_POST['paispago'], $_POST['hrPago'], $_POST['ficha'], 1,  $_POST['observaciones'],$_POST['imoratorio'],$_POST['ipago'],$_POST['cappag'],$_POST['igtscobr'],$_POST['imanejocta']);
// print_r($_POST);
$m = $pagos->regPagAdmin($_POST['asientolastpago'], $_POST['monto'], $_POST['banco'], $_POST['sucursal'], $_POST['ctaBanco'], $_POST['moneda'], $_POST['insmone'], $_POST['paispago'], $_POST['hrPago'], $_POST['ficha'], 1, $_POST['observaciones'], $_POST['imoratorio'], $_POST['ipago'], $_POST['cappag'], $_POST['igtscobr'], $_POST['imanejocta']);
/*-----ALERTAS---------------*/
$re = $alert->alertaInconsistenciasPago($_POST['monto'], $_POST['ctaBanco'], $_POST['ctaBanco'], 1, $_POST['asientolastpago'], $_POST['insmone']);
$gh = $alert->alertaMaxMovs($_POST['asientolastpago'], 1, $_POST['insmone'], $_POST['foliocontrato']);
$mm = $alert->alertaMontoMensual($_POST['asientolastpago'], 1, $_POST['insmone'], $_POST['foliocontrato']);
$fp = $alert->alertaFormaPagoDistinta($_POST['asientolastpago'], $_POST['insmone'], $_POST['monto'], $_POST['moneda'], $_POST['ficha']);
$mone = $alert->alertaMonedaDistinta($_POST['asientolastpago'], $_POST['insmone'], $_POST['monto'], $_POST['moneda'], $_POST['ficha']);
$opequinidols = $alert->alertaOpe500Dls($_POST['idClte'], $_POST['foliocontrato'], 1);
$opediez = $alert->alertaOpe10milDls($_POST['idClte'], $_POST['foliocontrato'], 1);
$opetres = $alert->alertaOpe300mil($_POST['idClte'], $_POST['foliocontrato'], 1);
$opequini = $alert->alertaOpe500mil($_POST['idClte'], $_POST['foliocontrato'], 1);
$opemillon = $alert->alertaOpe1millon($_POST['idClte'], $_POST['foliocontrato'], 1);
if ($opequinidols == '0' and $mone == '0' and $re == '0' and $gh == '0' and $mm == '0' and $opediez == '0' and $opetres == '0' and $opequini == '0' && $opemillon == '0' && $fp == '0') {
    echo "0";
} else {
    $i = 1;
    if ($re != '0') {
        echo $i . "->" . $re;
        echo "<br />";
        echo "<br />";
        $i++;
    }
<?php

session_start();
include_once "../model/mConexion.php";
include_once "../model/mAlertasAutomaticas.php";
include_once "../model/mBitacora.php";
$bit = new mBitacora();
$bit->entradaBitacoraExp($_SESSION["usuario"]["idUsuario"], "Cambiar Giro del Expediente", "el usuario ha cambiado el giro del Expediente", $_POST['id']);
$conn = new Database();
$al = new AlertasMan();
//cambia el giro del cliente
$id = $_POST['id'];
$giro = $_POST['giro'];
//cambia el giro
$query = "update clientes_todos set giro = '{$giro}' where id_cliente = {$id}";
$conn->Query($query);
//agrega al historial de giros el nuevo giro
$query = "insert into historial_giros_clte(id_perfil,giro) values({$id},'{$giro}')";
$conn->Query($query);
//genera la alerta manual inusual por cambio de giro
$al->regAlertaAuto($conn, "CAMBIO DE GIRO DEL CLIENTE", "", "", "", "", "", $_SESSION["usuario"]["idUsuario"], 3, 1, "EL EXPEDIENTE CAMBIÓ DE GIRO", $id);
$bit->entradaBitacoraExp($_SESSION["usuario"]["idUsuario"], "Alerta por Cambio Giro del Expediente", "el sistema ha lanzado una alerta de tipo inusual por el cambio de giro del Expediente", $_POST['id']);
$girosos = array('8800002', '6900003', '69999116', '9505001', '8219114', '4111035');
$i = 0;
$r = false;
while ($i < count($girosos) && ($r = false)) {
    if ($giro == $girosos[$i]) {
        $r = true;
        echo $r;
    }
    $i++;
<?php

if ($_POST) {
    include_once "../controller/cPagos.php";
    include_once "../model/mAlertasAutomaticas.php";
    $alert = new AlertasMan();
    $pagos = new cPagos();
    if (!isset($_POST['opcion'])) {
        //si opcion no se encuentra desde ejecutivofinanzas
        $m = $pagos->regPag($_POST['asientolastpago'], $_POST['monto'], $_POST['banco'], $_POST['sucursal'], $_POST['ctaBanco'], $_POST['moneda'], $_POST['insmone'], $_POST['paispago'], $_POST['hrPago'], $_POST['ficha'], 1, $_POST['observaciones'], $_POST['imoratorio'], $_POST['ipago'], $_POST['cappag'], $_POST['igtscobr'], $_POST['imanejocta'], $_POST['asientolastpago'], $_POST['txtPago_tardio']);
        if ($_POST['monto'] >= $_POST['totalDebeClte']) {
            $pagos->liquidar_contrato($_POST['foliocontrato'], '');
            $alertaPrepago = $alert->alertaPrepago($_POST['foliocontrato'], $_POST['id_usuario'], $_POST['insmone']);
            if ($alertaPrepago == '0') {
                echo "";
            } else {
                $i = 1;
                if ($alertaPrepago != '0') {
                    echo $i . "->" . $alertaPrepago;
                    echo "<br />";
                    echo "<br />";
                    $i++;
                }
            }
        }
        echo "";
        // echo 1;
    } else {
        //si opcion si se encuentra se registra desde el admin general
        $m = $pagos->regPag($_POST['asientolastpago'], $_POST['monto'], $_POST['banco'], $_POST['sucursal'], $_POST['ctaBanco'], $_POST['moneda'], $_POST['insmone'], $_POST['paispago'], $_POST['hrPago'], $_POST['ficha'], 1, $_POST['observaciones'], $_POST['imoratorio'], $_POST['ipago'], $_POST['cappag'], $_POST['igtscobr'], $_POST['imanejocta'], $_POST['asientolastpago'], 0);
        $pagos->liquidar_contrato($_POST['foliocontrato'], $_POST['txtMotivo']);
<?php

include_once "../model/mAlertasAutomaticas.php";
$alertas = new AlertasMan();
$cliente = $alertas->getDatosClte($_POST['id']);
$pep = $alertas->alertaListaNegra($_POST['id'], $cliente['a_pat'], $cliente['a_mat'], $cliente['nombre'], $cliente['razon']);
$ln = $alertas->alertaListaNegra($_POST['id'], $cliente['a_pat'], $cliente['a_mat'], $cliente['nombre'], $cliente['razon']);
$paises = $alertas->alertaPaisProhibido($_POST['id'], $cliente['nacionalidad']);
?>

<div class="row">
	<div class="col-lg-6 col-lg-offset-3">		
	<h4><strong>RESULTADOS EN PEP</strong> </h4>
	<br />
		<?php 
if ($pep == 0) {
    ?>
			EL CLIENTE NO CORRESPONDE A UNA PERSONA POLITICAMENTE EXPUESTA
		<?php 
} else {
    echo $pep;
}
?>
	</div>
	</div>
	<hr />
<div class="row">
	<div class="col-lg-6 col-lg-offset-3">
		
	<h4><strong>RESULTADOS EN LISTAS NEGRAS</strong> </h4>
	<br />
<?php

include_once "../model/mAlertasAutomaticas.php";
$alerg = new AlertasMan();
$r = $alerg->alertaPeP($_POST['id'], $_POST['a_pat'], $_POST['a_mat'], $_POST['nombre'], $_POST['razon']);
if ($r == '0') {
    $r = $alerg->alertaListaNegra($_POST['id'], $_POST['a_pat'], $_POST['a_mat'], $_POST['nombre'], $_POST['razon']);
    if ($r == '0') {
        echo 0;
    }
}
if ($r != '0') {
    ?>
<div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">ADVERTENCIA EXPEDIENTE DE ALTO RIESGO:</h4>
      </div>
      <div class="modal-body">
      	<div class="row">
       		<div class="col-lg-4">
       			<img src="../warning.png" class="img-responsive"  />
       		</div>
       		<div class="col-lg-6">
       			<h3 style="color:red">
       				<strong>
       				EL EXPEDIENTE ES DE ALTO RIESGO
       				</strong>
       			</h3>
       			<h4>
            echo "<td>\$" . $table[$i]['saldo_insoluto'] . "</td>";
            echo "<td>\$" . $table[$i]['capital_pagado'] . "</td>";
            echo "<td>" . $table[$i]['interes_tiempo'] . "%</td>";
            echo "<td>\$" . $table[$i]['interes'] . "</td>";
            echo "<td>\$" . $table[$i]['pago'] . "</td>";
            echo "<td>" . $table[$i]['fecha_corte'] . "</td>";
            echo "</tr>";
        }
        ?>
					</tbody>
			</div>
		<?php 
    } else {
        if ($_POST['operacion'] == 'alerta') {
            include_once "../model/mAlertasAutomaticas.php";
            $alertas = new AlertasMan();
            // print_r($_POST);
            $respuesta = $alertas->creditoSalario($_POST['id_cliente'], $_POST['id_usuario'], $_POST['abono']);
            if (!$respuesta) {
                echo -1;
                // echo "<script>alert('EL MONTO A PAGAR QUINCENALMENTE POR PARTE DEL CLIENTE ES MAYOR DE LA TERCERA PARTE DE SU INGRESO');</script>";
            } else {
                echo "monto permitido";
            }
        }
    }
}
if ($_GET) {
    $tabla = new Tabla();
    $pdf = new imprimeTabla();
    $pdf->AliasNbPages();
<?php

include_once "../model/mAlertasAutomaticas.php";
$auto = new AlertasMan();
$num = $auto->countContratosCliente($_POST['clave']);
if ($num == 0) {
    echo 0;
} else {
    $m = $auto->getContratosClienteAgrup($_POST['clave']);
    ?>
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">ADVERTENCIA DE EXPEDIENTE</h4>
      </div>
      <div class="modal-body">
        <h4>EL EXPEDIENTE TIENE LOS SIGUIENTES CONTRATOS RELACIONADOS</h4>
        <table class="table">
        	<thead>
        		<tr>
        			<td>CONTRATO</td>
        			<td>MONTO</td>
        			<td>FECHA INICIO</td>
        			<td>STATUS</td>
        		</tr>
        	</thead>
        	<tbody>
        		<?php 
    while ($l = $m->NextRow()) {
        ?>
<?php

include_once "../model/mConexion.php";
include_once "../model/mAlertasAutomaticas.php";
$alerta = new AlertasMan();
$dom = $alerta->alertaCambioDom($_POST['idDom'], $_POST['calle'], $_POST['via'], $_POST['numext'], $_POST['numint'], $_POST['col'], $_POST['cp'], $_POST['ciudad'], $_POST['estado'], $_POST['localidad'], $_POST['pais'], $_POST['referencia'], $_POST['id_usuario']);
if ($_POST['pais'] != "MX") {
    $pais = $alerta->alertaCambioPaisExtranjero($_POST['idDom'], $_POST['pais'], $_POST['id_usuario']);
} else {
    $pais = true;
}
$con = new Database();
$query = "UPDATE domicilios SET calle = '" . $_POST['calle'] . "', via = '" . $_POST['via'] . "', num = '" . $_POST['numext'] . "', num_int = '" . $_POST['numint'] . "', col = '" . $_POST['col'] . "', cp = '" . $_POST['cp'] . "', ciudad = '" . $_POST['ciudad'] . "', estado = '" . $_POST['estado'] . "', delegacion = '" . $_POST['localidad'] . "', pais = '" . $_POST['pais'] . "', referencia_domicilio = '" . $_POST['referencia'] . "', latitud = '', longitud = '' WHERE id_dom = " . $_POST['idDom'];
$con->Query($query);
if ($dom) {
    //son iguales no hubo cambio
    // echo 1;
    $respuesta = array('resultado' => 1);
    echo json_encode($respuesta);
    // echo "Datos guardados correctamente";
} else {
    //presento algun cambio
    $mensaje = "Hay un cambio de domicilio";
    if ($pais) {
        //no cambio el pais
        $respuesta = array('resultado' => 0, 'mensaje' => $mensaje);
        echo json_encode($respuesta);
    } else {
        //cambio el pais
        $mensaje = $mensaje . "\n" . "Cambio a pais extranjero";
        $respuesta = array('resultado' => 0, 'mensaje' => $mensaje);
<?php

include_once "../model/mAlertasAutomaticas.php";
$alertas = new AlertasMan();
$opediez = $alertas->alertaOpe10milDls($_POST['id'], $_POST['contrato'], 1);
$opetres = $alertas->alertaOpe300mil($_POST['id'], $_POST['contrato'], 1);
$opequini = $alertas->alertaOpe500mil($_POST['id'], $_POST['contrato'], 1);
$opemillon = $alertas->alertaOpe1millon($_POST['id'], $_POST['contrato'], 1);
if ($opediez == 0 && $opetres == 0 && $opequini == 0 && $opemillon == 0) {
    echo "0";
} else {
    echo $opediez . "<br />" . $opetres . "<br />" . $opequini . "<br />" . $opemillon;
}
<?php

include_once "../model/mAlertasAutomaticas.php";
$aler = new AlertasMan();
echo $aler->alertaCambioGiro($_POST['clave'], $_POST['giro']);
<?php

include_once "../model/mConexion.php";
$con = new Database();
include_once "../model/mAlertasAutomaticas.php";
$alertas = new AlertasMan();
$respuesta = $alertas->alertaOrigenRecursos($_POST['idClte'], $_POST['id_usuario'], $_POST['txtEmpresa']);
$query = "UPDATE `clientes_empleos`\n\tSET\n\t`empresa` = '" . $_POST['txtEmpresa'] . "',\n\t`puesto` = '" . $_POST['txtPueto'] . "',\n\t`telefono` = '" . $_POST['txtTelefonoTrabajo'] . "',\n\t`ext` = '" . $_POST['txtExtencion'] . "',\n\t`dom` = '" . $_POST['txtDomicilioTrabajo'] . "',\n\t`colonia` = '" . $_POST['txtColoniaTrabajo'] . "',\n\t`ciudad` = '" . $_POST['txtCiudadPoblacionTrabajo'] . "',\n\t`edo` = '" . $_POST['txtEstadoTrabajo'] . "',\n\t`ingreso` = " . $_POST['txtIngresoMensual'] . ",\n\t`tiempo_mens` = '" . $_POST['txtTiempoTrabajo'] . "',\n\t`email` = '" . $_POST['txtCorreoTrabajo'] . "',\n\t`cod_conv` = '" . $_POST['txtCodConvenio'] . "',\n\t`convenio` = '" . $_POST['txtConvenio'] . "',\n\t`expediente` = '" . $_POST['txtExpediente'] . "',\n\t`plaza` = '" . $_POST['txtPlaza'] . "',\n\t`num_emp` = '" . $_POST['txtNoEmpleado'] . "',\n\t`num_pension` = '" . $_POST['txtNoPencion'] . "',\n\t`sindicato` = '" . $_POST['txtSindicato'] . "',\n\t`zona_esc` = '" . $_POST['txtZonaEscolar'] . "',\n\t`filiacion` = '" . $_POST['txtFiliacion'] . "',\n\t`tipo_contrato` = '" . $_POST['txtTipoContrato'] . "',\n\t`num_plaza` = '" . $_POST['txtNoPlaza'] . "',\n\t`num_ficha` = '" . $_POST['txtNoFicha'] . "',\n\t`cve_centro_trab` = '" . $_POST['txtCveCentroTrab'] . "',\n\t`num_nomina` = '" . $_POST['txtNoNomina'] . "',\n\t`sucursal` = '" . $_POST['txtSucursal'] . "',\n\t`area` = '" . $_POST['txtArea'] . "'\n\tWHERE `id_clte` = " . $_POST['idClte'];
$con->Query($query);
// if(!$respuesta){
// 	// echo "El cliente cambio el origen de recursos\nDatos guardados correctamente";
// }
// else{
// 	// echo "Datos guardados correctamente";
// }
// echo $query;
<?php

include_once "../model/mAlertasAutomaticas.php";
$alerta = new AlertasMan();
$bandera = $alerta->alertaPersonaPEP($_POST['id'], $_POST['nombre'], $_POST['a_pat'], $_POST['a_mat'], $_POST['razon']);
// echo $bandera;
// $mensaje='';
if ($bandera > 0) {
    $mensaje = "EL EXPEDIENTE SE ENCUENTRA EN LA LISTA DE PERSONAS POLITICAMENTE EXPUESTAS, FAVOR DE NOTIFICAR AL OFICIAL DE CUMPLIMIENTO";
    $respuesta = array('mensaje' => $mensaje, 'bandera' => $bandera);
    echo json_encode($respuesta);
} else {
    $bandera = $alerta->alertaListNegra($_POST['id'], $_POST['nombre'], $_POST['a_pat'], $_POST['a_mat'], $_POST['razon']);
    if ($bandera > 0) {
        $mensaje = "EL EXPEDIENTE SE ENCUENTRA EN LISTA NEGRA, FAVOR DE NOTIFICAR AL OFICIAL DE CUMPLIMIENTO";
        $respuesta = array('mensaje' => $mensaje, 'bandera' => $bandera);
        echo json_encode($respuesta);
    }
}
// else{
// 	$bandera=$alerta->alertaListNegra($_POST['id'],$_POST['nombre'],$_POST['a_pat'],$_POST['a_mat'],$_POST['razon']);
// 	if($bandera==true){
// 		$mensaje= "EL EXPEDIENTE SE ENCUENTRA EN LISTA NEGRA, FAVOR DE NOTIFICAR AL OFICIAL DE CUMPLIMIENTO";
// 	}
// }
// if($bandera==true){
// 	$respuesta=array('mensaje'=>$mensaje);
// 	echo json_encode($respuesta);
// }
// else{
// 	$respuesta=array('bandera'=>'se permite');