function jsaCerrarCaja($oficial, $pwd, $caja)
{
    $xBtn = new cHButton();
    $xCaja = new cCaja($caja);
    $cUsr = new cSystemUser($oficial, false);
    $sucess = $cUsr->getCompareData("contrasenna", $pwd);
    $msg = "";
    if ($sucess == true) {
        $IOficial = $cUsr->getID();
        $xCaja->init($caja);
        if ($xCaja->setCloseBox($IOficial, 0) == true) {
            $url = $xCaja->getLinkDeCorte();
            $msg = $xBtn->getBasic("TR.Imprimir Corte", "var xG = new Gen(); xG.w({url:'{$url}'});", "imprimir", "printcorte", false);
        } else {
            //TODO: Checar el problema con esto
            if (MODO_DEBUG == true) {
                setLog($xCaja->getMessages(OUT_TXT));
            }
            $msg = "<p class='warn'>CLAVE DE ERROR " . $err . "</p>";
        }
    } else {
        $msg = "<p class='warn'>ERROR</p>";
    }
    return $msg;
}
function jsaGetUInfo($user)
{
    $xUsr = new cSystemUser($user, false);
    $xUsr->init();
    $VD = $xUsr->getDatosInArray();
    //getSAFEUserInfoByName($user);
    $tab = new TinyAjaxBehavior();
    if (isset($VD["idusuarios"])) {
        //$tab -> add(TabSetValue::getBehavior('idNombreCompleto', $VD["nombres"] ));
        //$tab -> add(TabSetValue::getBehavior('idApellidoPaterno', $VD["apellidopaterno"] ));
        //$tab -> add(TabSetValue::getBehavior('idApellidoMaterno', $VD["apellidomaterno"] ));
        $tab->add(TabSetValue::getBehavior('idNivelAcceso', $VD["niveldeacceso"]));
        $tab->add(TabSetValue::getBehavior('idSucursal', $VD["sucursal"]));
        $tab->add(TabSetValue::getBehavior('idUsuario', $VD["idusuarios"]));
        $tab->add(TabSetValue::getBehavior('idPuesto', $VD["puesto"]));
        $tab->add(TabSetValue::getBehavior('idsocio', $xUsr->getClaveDePersona()));
    } else {
        $tab->add(TabSetValue::getBehavior('idUsuario', 0));
    }
    return $tab->getString();
}
 /**
  * Valida la Cuenta de Captacion
  * @param boolean $ForzarCorreccion
  */
 function setValidar($ForzarCorreccion = false)
 {
     $arrUp = array();
     $DC = $this->getDatosInArray();
     $socio = $this->mSocioTitular;
     $cuenta = $this->mNumeroCuenta;
     $grupo = $this->mGrupoAsociado;
     $sucursal = $DC["sucursal"];
     $user = $DC["idusuario"];
     $oficial = $DC["oficial_de_captacion"];
     $credito = $DC["numero_solicitud"];
     $FApertura = $DC["fecha_apertura"];
     $FAfecta = $DC["fecha_afectacion"];
     //Fecha Valida
     $FechaValida = true;
     $msg = "VALIDAR CUENTA {$cuenta}\r\n";
     //Datos propios de la Inversion
     $FVencInv = $DC["inversion_fecha_vcto"];
     $DiasInv = $DC["dias_invertidos"];
     $TCuenta = $DC["tipo_cuenta"];
     //Cuenta de Intereses
     $CtaInts = $DC["cuenta_de_intereses"];
     //Datos producto
     $xDT = new cInformacionProductoCaptacion($TCuenta);
     $DT = $xDT->init();
     //validar socios
     $xSoc = new cSocio($socio);
     if ($xSoc->existe($socio) == false) {
         $msg .= "CRITICO\tSOCIO\tEl Socio {$socio} no EXISTE \r\n";
         if ($ForzarCorreccion == true) {
             $xSoc->add("SOCIO_CUENTA_{$cuenta}");
             $msg .= "NUEVO\tSOCIO\tAgregado el Socio {$socio}\r\n";
         }
     }
     //validar grupo
     if ($grupo == false or $grupo == 0) {
         $arrUp["numero_grupo"] = DEFAULT_GRUPO;
         $msg .= "ERROR\tGRUPO\tEl Grupo {$grupo} No es Valido, se actualiza al default \r\n";
     } else {
         //Controlar Grupo
         $xGrp = new cGrupo($grupo);
         if ($xGrp->existe($grupo) == false) {
             $msg .= "CRITICO\tGRUPO\tEl Grupo {$grupo} no EXISTE \r\n";
             if ($ForzarCorreccion == true) {
                 $xGrp->add("GRUPO_CUENTA_{$cuenta}", "", false, false, 10, 1, $grupo, $sucursal);
                 $msg .= "NUEVO\tGRUPO\tSe Agrego el Grupo {$grupo} \r\n";
             }
         }
     }
     //Restaurar Credito
     if ($credito != DEFAULT_CREDITO) {
         $arrUp["numero_solicitud"] = DEFAULT_CREDITO;
     }
     //
     //Controlar Usuario
     $xUsr = new cSystemUser($user);
     if ($xUsr->existe($user) == false) {
         $msg .= "CRITICO\tUSUARIO\tEl Usuario {$user} no EXISTE \r\n";
         if ($ForzarCorreccion == true) {
             $xUsr->add("usr{$user}", "", 2, "USR_CTA_{$cuenta}", "", "", "", false, "baja", "", $sucursal, $user);
             $msg .= "NUEVO\tUSUARIO\tSe Agrego el Usuario {$user} \r\n";
         }
     }
     //Controlar Oficial de Captacion
     if ($xUsr->existe($oficial) == false) {
         $msg .= "ERROR\tOFICIAL\tEl Oficial de Captacion {$oficial} no EXISTE \r\n";
         if ($ForzarCorreccion == true) {
             $xUsr->add("usr{$oficial}", "", 2, "OFICIAL_CTA_{$cuenta}", "", "", "", false, "baja", "", $sucursal, $oficial);
             $msg .= "NUEVO\tOFICIAL\tSe Agrego el OFICIAL {$oficial} \r\n";
         }
     }
     if ($FApertura == '0000-00-00') {
         $msg .= "WARN\tLa fecha de Apertura {$FApertura} es INVALIDA\r\n";
         $arrUp["fecha_apertura"] = fechasys();
         $FechaValida = false;
     }
     if ($FAfecta == '0000-00-00') {
         $msg .= "WARN\tLa fecha de Afectacion {$FAfecta} es INVALIDA\r\n";
         $arrUp["fecha_afectacion"] = fechasys();
         $FechaValida = false;
     }
     //Validar las fechas
     if ($FechaValida == true) {
         if (strtotime($FApertura) > strtotime($FAfecta)) {
             $msg .= "WARN\tLa fecha de Apertura {$FApertura} es mayor a la de operaciones {$FAfecta}\r\n";
             $arrUp["fecha_apertura"] = $FAfecta;
         }
     }
     //Validar las funciones del Subproducto
     if ($ForzarCorreccion == true) {
         //Guardar Cambios
         $this->setUpdate($arrUp);
         return $msg;
     }
 }
 function setPolizaPorRecibo($recibo, $generador = false)
 {
     $sucess = false;
     $QL = new MQL();
     $xLogg = new cCoreLog();
     //$arrEquivEfvo			=
     //if (GENERAR_CONTABILIDAD == true){
     $xLogg->add("=======\tGENERAR POLIZA POR RECIBO NUM {$recibo}\r\n", $xLogg->DEVELOPER);
     $xT = new cCatalogoOperacionesDeCaja();
     $centro_de_costo = DEFAULT_CENTRO_DE_COSTO;
     //($generador == GENERAR_POLIZAS_AL_CIERRE) AND
     if (setNoMenorQueCero($recibo) > 0) {
         $xRec = new cReciboDeOperacion(false, false, $recibo);
         if ($xRec->init() == true) {
             $sucess = true;
             //Obten datos del recibo para la Poliza
             $sqlRec = "SELECT\r\n\t\t\t\t\t\t\t`operaciones_recibos`.*,\r\n\t\t\t\t\t\t\t`operaciones_recibostipo`.`tipo_poliza_generada`,\r\n\t\t\t\t\t\t`operaciones_recibostipo`.`afectacion_en_flujo_efvo`\r\n\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t`operaciones_recibos` `operaciones_recibos`\r\n\t\t\t\t\t\t\t\tINNER JOIN `operaciones_recibostipo`\r\n\t\t\t\t\t\t\t\t`operaciones_recibostipo`\r\n\t\t\t\t\t\t\t\tON `operaciones_recibos`.`tipo_docto` =\r\n\t\t\t\t\t\t\t\t`operaciones_recibostipo`.\r\n\t\t\t\t\t\t\t\t`idoperaciones_recibostipo`\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t(`operaciones_recibos`.`idoperaciones_recibos` = {$recibo})\r\n\t\t\t\t\t\tLIMIT 0,1 ";
             $dRec = obten_filas($sqlRec);
             $tipo_de_pago = $xRec->getTipoDePago();
             //Corrige los cargos de la PolizaS
             $total_poliza = 0;
             $SQLSumCargos = "SELECT SUM(monto) AS 'total' FROM contable_polizas_proforma\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE contable_operacion = '" . TM_CARGO . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND numero_de_recibo={$recibo} ";
             $TMPCargos = mifila($SQLSumCargos, "total");
             $SQLSumAbonos = "SELECT SUM(monto) AS 'total' FROM contable_polizas_proforma\r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE contable_operacion = '" . TM_ABONO . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND numero_de_recibo={$recibo} ";
             $TMPAbonos = mifila($SQLSumAbonos, "total");
             if ($TMPCargos > $TMPAbonos) {
                 $diferencia = $TMPAbonos - $TMPCargos;
                 $diferencia = $diferencia < 0 ? $diferencia * -1 : $diferencia;
                 $total_poliza = $TMPCargos;
                 setPolizaProforma($recibo, $xT->getTipoOperacionByTipoPago($tipo_de_pago), $diferencia, 1, 1, TM_ABONO);
                 $xLogg->add("OK\tCUADRAR\tABONO\tOperacion Agregada por DESCUADRE en {$tipo_de_pago} por {$diferencia}\r\n", $xLogg->DEVELOPER);
                 //$xLogg->add( , $xLogg->DEVELOPER);
             } elseif ($TMPCargos < $TMPAbonos) {
                 $diferencia = $TMPCargos - $TMPAbonos;
                 $diferencia = $diferencia < 0 ? $diferencia * -1 : $diferencia;
                 $total_poliza = $TMPAbonos;
                 setPolizaProforma($recibo, $xT->getTipoOperacionByTipoPago($tipo_de_pago), $diferencia, 1, 1, TM_CARGO);
                 $xLogg->add("OK\tCUADRAR\tCARGOS\tOperacion Agregada por DESCUADRE en {$tipo_de_pago} por {$diferencia}\r\n", $xLogg->DEVELOPER);
             } else {
                 $total_poliza = $TMPCargos;
             }
             //tipos de Poliza 1=ingreso, 2=egreso, 3 Diario, 4=orden 5
             $xD = new cFecha(0, $xRec->getFechaDeRecibo());
             $numero_de_recibo = $recibo;
             $tipo_de_poliza = $xRec->getOTipoRecibo()->getTipoPolizaContable();
             $fecha_de_poliza = $xRec->getFechaDeRecibo();
             $ejercicio_de_poliza = $xD->anno();
             $periodo_de_poliza = $xD->mes();
             $recibo_fiscal = strlen($xRec->getReciboFiscal()) > 2 ? ";RF:" . $xRec->getReciboFiscal() : "";
             $observacion_recibo = $xRec->getObservaciones();
             $cheque = strlen($xRec->getNumeroDeCheque()) > 2 ? ";Ch:" . $xRec->getNumeroDeCheque() : "";
             $concepto_poliza = substr("R:" . $numero_de_recibo . $recibo_fiscal . $cheque . ";" . $xRec->getObservaciones(), 0, 80);
             $flujo_efectivo = $xRec->getOTipoRecibo()->getAfectacionEnEfvo();
             $socio = $xRec->getCodigoDeSocio();
             $propietario = $xRec->getCodigoDeUsuario();
             $xLogg->add("=====\tRECIBO TIPO: " . $xRec->getTipoDeRecibo() . " SUMA: " . $xRec->getTotal() . " \r\n", $xLogg->DEVELOPER);
             //------------------ Agregar Poliza
             $xPol = new cPoliza($tipo_de_poliza, false, $ejercicio_de_poliza, $periodo_de_poliza);
             $xPol->add($concepto_poliza, $fecha_de_poliza, false, 0, 0, $propietario, $centro_de_costo, $recibo);
             $numero_de_poliza = $xPol->get();
             $xLogg->add("=====\tPOLIZA NUM: {$numero_de_poliza} | TIPO: {$tipo_de_poliza} | EJERCICIO: {$ejercicio_de_poliza} | PERIODO: {$periodo_de_poliza}\r\n", $xLogg->DEVELOPER);
             $sucess = $xPol->mRaiseError == true ? false : true;
             //------------------ Leer la PROFORMA
             $sqlMvtosToPoliza = "SELECT\r\n\t\t\t\t\t`contable_polizas_proforma`.*,\r\n\t\t\t\t\t`operaciones_tipos`.*\r\n\t\t\r\n\t\t\t\t\tFROM\r\n\t\t\t\t\t`operaciones_tipos` `operaciones_tipos`\r\n\t\t\t\t\t\tINNER JOIN `contable_polizas_proforma`\r\n\t\t\t\t\t\t`contable_polizas_proforma`\r\n\t\t\t\t\t\tON `operaciones_tipos`.`idoperaciones_tipos` =\r\n\t\t\t\t\t\t`contable_polizas_proforma`.`tipo_de_mvto`\r\n\t\t\t\t\t\tAND `contable_polizas_proforma`.`numero_de_recibo` = {$numero_de_recibo}\r\n\t\t\t\t\tORDER BY\r\n\t\t\t\t\t\t`contable_polizas_proforma`.`contable_operacion` DESC,\r\n\t\t\t\t\t\t`contable_polizas_proforma`.`socio`,\r\n\t\t\t\t\t\t`contable_polizas_proforma`.`tipo_de_mvto`\t\t\t\t\r\n\t\t\t\t\t";
             if ($sucess == true) {
                 $rs = $QL->getDataRecord($sqlMvtosToPoliza);
                 foreach ($rs as $rw) {
                     $cuenta = CUENTA_DE_CUADRE;
                     $nombre = "";
                     $socio = $rw["socio"];
                     if (CONTABLE_CUENTAS_POR_SOCIO == true) {
                         $xSoc = new cSocio($socio, true);
                         $nombre = $xSoc->getNombreCompleto();
                     }
                     $documento = $rw["documento"];
                     $monto_movimiento = $rw["monto"];
                     $tipoOp = $rw["tipo_de_mvto"];
                     $tipo_movimiento = $rw["contable_operacion"];
                     $RecUsr = $rw["idusuario"];
                     $cuenta_bancaria = $rw["banco"];
                     $cargo_movimiento = 0;
                     $abono_movimiento = 0;
                     if ($tipo_movimiento == TM_CARGO) {
                         $cargo_movimiento = $monto_movimiento;
                         $abono_movimiento = 0;
                     } else {
                         $cargo_movimiento = 0;
                         $abono_movimiento = $monto_movimiento;
                     }
                     $formula = $rw["cuenta_contable"];
                     //Corregir de urgencia: OK: 06Oct2011
                     $sForms = new cValorarFormulas();
                     $cuenta = $sForms->getCuentaContable($socio, $documento, $formula, $RecUsr, $xRec->getNumeroDeCheque(), $cuenta_bancaria);
                     $xLogg->add($sForms->getMessages(), $xLogg->DEVELOPER);
                     //tipo de cuenta es Abonos a efectivo
                     if ($cuenta != "NO_CONTABILIZAR") {
                         $xCuenta = new cCuentaContable($cuenta);
                         $xCuenta->init();
                         $cuenta = $xCuenta->get();
                         //Carga los datos del Oficial
                         if ($xCuenta->getEsCuentaDeCirculante() == true) {
                             $xOf = new cSystemUser($RecUsr);
                             $xOf->init();
                             $nombre = $xOf->getNombreCompleto();
                             $xLogg->add("OK\tCUENTA_ADD\tLa Cuenta {$cuenta} de Carga por Usuario [ {$nombre} ]\r\n", $xLogg->DEVELOPER);
                         } else {
                             $xLogg->add("OK\tCUENTA\tLa Cuenta de Trabajo es {$cuenta} Originado del Socio {$socio}\r\n", $xLogg->DEVELOPER);
                         }
                         //verifica para dar de alta a la cuenta
                         $Existentes = $xCuenta->getCountCuenta();
                         if ($Existentes == false) {
                             $xLogg->add("WARN\tCUENTA_ADD\tLa Cuenta de Trabajo {$cuenta} NO EXISTE, se AGREGA\r\n", $xLogg->DEVELOPER);
                             $cuenta = $xCuenta->add($nombre);
                             if ($xCuenta->mRaiseError == true) {
                                 //$msg				.= "ERROR\tLa Cuenta de Trabajo $cuenta NO EXISTE\r\n";
                                 //$msg		= $xCuenta->getMessages();
                             }
                         }
                         $xCuenta->init();
                         $xPol->addMovimiento($cuenta, $cargo_movimiento, $abono_movimiento, "{$socio}", "{$documento}:{$tipoOp}", false, $fecha_de_poliza);
                         //$xLogg->add("WARN\tNO_CONT\tAGREGAR $cuenta, $cargo_movimiento, $abono_movimiento\r\n" , $xLogg->DEVELOPER);
                         $xLogg->add($xCuenta->getMessages(), $xLogg->DEVELOPER);
                     } else {
                         $xLogg->add("WARN\tNO_CONT\tEl Movimiento de {$socio} | {$documento} | {$tipoOp} de Monto {$monto_movimiento} se OMITE\r\n", $xLogg->DEVELOPER);
                     }
                 }
                 $xPol->setFinalizar();
             }
             //sucess
             $xLogg->add($xPol->getMessages(), $xLogg->DEVELOPER);
             $this->mIDDePoliza = $xPol->getCodigo();
         }
     }
     //END VALUE.- GENERAR AL FINAL
     //}		//END VALUE.- GENERAR CONTABILIDAD
     $this->mMessages .= $xLogg->getMessages();
     return $xLogg->getMessages();
 }
<?php

@session_start();
include_once "../core/core.error.inc.php";
include_once "../core/go.login.inc.php";
include_once "../core/core.init.inc.php";
include_once "../core/core.deprecated.inc.php";
include_once "../core/core.security.inc.php";
//$_SESSION["SN_b80bb7740288fda1f201890375a60c8f"]
$xUsr = new cSystemUser($_SESSION["SN_b80bb7740288fda1f201890375a60c8f"]);
$xUsr->setEndSession();
header('location:../inicio.php');
exit;
 function getImportarDesdeAsociada($tipo)
 {
     $result = true;
     $svc = new MQLService("", "");
     $cmd = $svc->getEncryptData($tipo);
     $xTu = new cSystemUser(TASK_USR, false);
     $xTu->init();
     $ctx = $xTu->getCTX();
     $data = $svc->getEncryptData($this->mCodigo);
     $host = SVC_ASOCIADA_HOST;
     switch ($tipo) {
         case TPERSONAS_GENERALES:
             $dpersona = $svc->getService($host . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
             if (is_array($dpersona)) {
                 $xSoc = new cSocios_general($dpersona);
                 if (setNoMenorQueCero($xSoc->codigo()->v()) > 0) {
                     $xSoc->query()->insert()->save();
                     $result = true;
                 }
             }
             break;
         case TPERSONAS_DIRECCIONES:
             $ddomicilio = $svc->getService($host . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
             if (is_array($ddomicilio)) {
                 $xDom = new cSocios_vivienda($ddomicilio);
                 if (setNoMenorQueCero($xDom->idsocios_vivienda()->v())) {
                     $xDom->query()->insert()->save();
                     $result = true;
                 }
             }
             break;
         case TPERSONAS_ACTIVIDAD_ECONOMICA:
             $dtrabajo = $svc->getService($host . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
             if (is_array($dtrabajo)) {
                 $xTrab = new cSocios_aeconomica($dtrabajo);
                 if (setNoMenorQueCero($xTrab->idsocios_aeconomica()->v())) {
                     $xTrab->query()->insert()->save();
                     $result = true;
                 }
             }
             break;
         case TCATALOGOS_EMPRESAS:
             $dempresa = $svc->getService($host . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
             if (is_array($dempresa)) {
                 $xEmp = new cSocios_aeconomica_dependencias($dempresa);
                 if (setNoMenorQueCero($xEmp->idsocios_aeconomica_dependencias()->v())) {
                     $xEmp->query()->insert()->save();
                     $result = true;
                 }
             }
             break;
     }
     return $result;
 }
 function setProcesarProgramacion($id, $arrVars = false, $data = false, $fecha = false)
 {
     $xF = new cFecha();
     $xT = new cTipos();
     $xLog = new cCoreLog();
     $arrVars = $arrVars == false ? $this->mArrVars : $arrVars;
     //idprograma, nombre_del_aviso, forma_de_creacion, programacion, destinatarios, microformato, tipo_de_medios, intent_check, intent_command
     $sql = "SELECT *\tFROM sistema_programacion_de_avisos WHERE idprograma={$id} LIMIT 0,1";
     $d = $data == false ? obten_filas($sql) : $data;
     $mOb = new cSistema_programacion_de_avisos();
     $mOb->setData($d);
     $emails = array();
     $tels = array();
     $enviar = false;
     $fecha = $fecha == false ? fechasys() : $fecha;
     $nombredia = $xF->getDayName();
     $diadelmes = date("j", $xF->getInt());
     $EnviarNota = true;
     $EnviarMail = true;
     $EnviarSMS = false;
     $xLoc = new cLocal();
     //procesar cuerpo del contenido
     $arrVars["fecha"] = !isset($arrVars["fecha"]) ? $fecha : $arrVars["fecha"];
     $arrVars["fecha_dia_siguiente"] = $xF->setSumarDias(1, $fecha);
     $arrVars["fecha_inicio_de_semana"] = $xF->getFechaDeInicioDeSemana($fecha);
     $arrVars["fecha_inicio_de_mes"] = $xF->getDiaInicial($fecha);
     //Dia de la semana inicial
     $arrVars["hora"] = date("H");
     $arrVars["usuario"] = $xLoc->getNombreUsuario();
     $arrVars["clave_de_usuario"] = !isset($arrVars["clave_de_usuario"]) ? getUsuarioActual() : $arrVars["clave_de_usuario"];
     //interpretar DIA
     if (strtoupper($mOb->forma_de_creacion()->v()) == SYS_ALERTA_POR_EVENTO) {
         $enviar = true;
     } else {
         //if($mOb->programacion())
         $programacion = strtoupper($mOb->programacion()->v());
         $periodo = explode(":", $programacion);
         //INTERPRETAR DIA
         if ($periodo[0] == "PROGRAMACION_SEMANAL") {
             if (strpos($nombredia, $programacion) !== false) {
                 $enviar = true;
             }
         } else {
             if ($periodo[0] == "PROGRAMACION_DIARIA") {
                 $enviar = true;
             } else {
                 if (isset($periodo[1])) {
                     $dias = explode(",", $periodo[1]);
                     foreach ($dias as $dias => $iddia) {
                         $mes = $xF->mes();
                         $anno = $xF->anno();
                         if (date("Y-m-d", strtotime("{$anno}-{$mes}-{$iddia}")) == $fecha) {
                             $enviar = true;
                         }
                     }
                 }
             }
         }
     }
     //1.- extraer emails
     $destinatarios = explode("|", $mOb->destinatarios()->v());
     foreach ($destinatarios as $key => $cnt) {
         if (trim($cnt) != "") {
             //1.1 Desfragmentar destinos
             $DS = explode(":", $cnt);
             $mdestino = isset($DS[0]) ? strtoupper($DS[0]) : "";
             switch ($mdestino) {
                 case "OFICIALES":
                     if (isset($DS[1])) {
                         $oficiales = explode(",", $DS[1]);
                         foreach ($oficiales as $ofc => $ofkey) {
                             $xOf = new cOficial($ofkey);
                             $xOf->init();
                             $mail = $xOf->getEmail();
                             $emails[] = $mail;
                             $xLog->add("OK\tOFICIAL\tAgregar mail {$mail}  \r\n", $xLog->DEVELOPER);
                         }
                     }
                     break;
                 case "EMPRESAS":
                     if (isset($DS[1])) {
                         $empresas = explode(",", $DS[1]);
                         foreach ($empresas as $emp => $empkey) {
                             $xEmp = new cEmpresas($empkey);
                             $xEmp->init();
                             //$mail		= $xEmp->getEmailsDeEnvio();
                             //$emails[]	= $mail;
                             $emails = array_merge($emails, $xEmp->getEmailsDeEnvio());
                             $xLog->add("OK\tEMPRESAS\tAgregar mail de la empresa {$empkey}  \r\n", $xLog->DEVELOPER);
                         }
                     }
                     break;
                 case "PERSONAS":
                     if (isset($DS[1])) {
                         $personas = explode(",", $DS[1]);
                         foreach ($personas as $ofc => $ofkey) {
                             $xSoc = new cSocio($ofkey);
                             $xSoc->init();
                             $mail = $xSoc->getCorreoElectronico();
                             $emails[] = $mail;
                             $xLog->add("OK\tPERSONA\tAgregar mail {$mail}  \r\n", $xLog->DEVELOPER);
                             if ($xT->cNumeroTelefonico($xSoc->getTelefonoPrincipal()) != false) {
                                 $EnviarSMS = true;
                                 $tels[] = $xT->cNumeroTelefonico($xSoc->getTelefonoPrincipal());
                             }
                         }
                     }
                     break;
                 case "CORREO":
                     if (isset($DS[1])) {
                         $personas = explode(",", $DS[1]);
                         foreach ($personas as $ofc => $ofkey) {
                             if (filter_var($ofkey, FILTER_VALIDATE_EMAIL)) {
                                 $emails[] = $ofkey;
                             }
                             $xLog->add("OK\tCORREO\tAgregar mail {$ofkey}  \r\n", $xLog->DEVELOPER);
                         }
                     }
                     break;
             }
             //1.1.1 Validar oficiales, empresas, personas
             //if(strpos("OFICIALES:", $needle))
         }
     }
     $this->mMessages .= $xLog->getMessages();
     $texto = $mOb->microformato()->v();
     foreach ($arrVars as $variable => $valor) {
         $texto = str_replace("{" . $variable . "}", $valor, $texto);
     }
     if ($enviar == true) {
         $url = $mOb->intent_command()->v(OUT_TXT);
         //2 procesado del comando
         if (trim($url) == "") {
             $titulo = strtoupper($mOb->nombre_del_aviso()->v());
             $xNot = new cNotificaciones();
             //enviar mail normal
             if ($EnviarSMS == true) {
                 foreach ($tels as $pitm => $ptel) {
                     $xNot->sendSMS($ptel, $texto);
                 }
             }
             if ($EnviarMail == true) {
                 foreach ($emails as $itm => $pmail) {
                     $xNot->sendMail($titulo, $texto, $pmail);
                 }
             }
         } else {
             //execute command
             //rpttesoreria/corte_de_caja.rpt.php?on=2014-5-3&off=2014-5-3&cajero=todas&dependencia=todas
             $smail = "";
             $xHO = new cHObject();
             foreach ($arrVars as $variable => $valor) {
                 $url = str_replace("{" . $variable . "}", $valor, $url);
             }
             foreach ($emails as $id => $rmail) {
                 //$smail	.= ($smail == "") ? "email$id=$rmail" : "&email$id=$rmail";
                 $smail .= "&email{$id}={$rmail}";
             }
             //Iniciar session en contexto &on=$fecha&off=$fecha
             $xSysUser = new cSystemUser();
             $xSysUser->init();
             $url = $url . $smail . "&ctx=" . $xSysUser->getCTX();
             if (MODO_DEBUG == true) {
                 setLog($url);
             }
             $xHO->navigate($url);
         }
     } else {
         $this->mMessages .= "OK\tNo e envia el reporte\r\n";
     }
     setLog($this->mMessages);
     $this->mObProgAv = $mOb;
     //return $this->mObProgAv;
 }
 /**
  * Funcion que Retorna una Ficha Descriptiva por el recibo
  * @param boolean $fieldset
  * @param string $trTool
  * @param string $wTable
  * @return string
  */
 function getFicha($fieldset = false, $trTool = "", $extend = false)
 {
     $this->init();
     $xLg = new cLang();
     $personaAsoc = $this->getPersonaAsociada();
     //$fichaEmpresa	= "";
     if ($this->mReciboIniciado == false) {
         $exoFicha = "<div class='error'>" . $xLg->get(MSG_NO_DATA) . "</div>";
     } else {
         $xLg = new cLang();
         $tool = $trTool;
         if ($extend == true) {
             $xUsr = new cSystemUser($this->getCodigoDeUsuario());
             $xUsr->init();
             $xSoc = new cSocio($this->getCodigoDeSocio());
             $xSoc->init();
             $tool .= "<tr><th class='izq'>" . $xLg->getT("TR.persona") . "</th>";
             $tool .= "<td>" . $xSoc->getNombreCompleto() . "</td>";
             $tool .= "<th class='izq'>" . $xLg->getT("TR.Documento") . "</th>";
             $tool .= "<td>" . $this->getCodigoDeDocumento() . "</td>";
             $tool .= "<tr><th class='izq'>" . $xLg->getT("TR.Elabora") . "</th>";
             $tool .= "<td>" . $xUsr->getNombreCompleto() . "</td>";
             if ($this->isDeEmpresa() == true) {
                 $xEmp = new cEmpresas($personaAsoc);
                 $xEmp->init();
                 $tool .= "<th class='izq'>" . $xLg->getT("TR.Empresa") . "</th>";
                 $tool .= "<td>" . $xEmp->getNombre() . "</td>";
             }
             $tool .= "</tr>";
         }
         if ($this->isDivisaExtranjera() == true) {
             $tool .= "<tr><th class='izq'>" . $xLg->getT("TR.Moneda") . "</th>";
             $tool .= "<td>" . $this->getMoneda() . "</td>";
             $tool .= "<th class='izq'>" . $xLg->getT("TR.Original") . "</th>";
             $tool .= "<td>" . $this->getUnidadesOriginales() . "</td>";
             $tool .= "</tr>";
         }
         $xF = new cFecha(0);
         $exoFicha = "\n\t\t\t\t<table id=\"ficharecibo\">\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th class='izq'>Numero de Recibo</th>\n\t\t\t\t\t\t<td class='mny'>" . $this->mCodigoDeRecibo . "</td>\n\t\t\t\t\t\t<th class='izq'>Tipo de Recibo</th>\n\t\t\t\t\t\t<td>" . $this->mTipoDescripcion . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th class='izq'>Fecha de Recibo</th>\n\t\t\t\t\t\t<td>" . $xF->getFechaCorta($this->mFechaDeOperacion) . "</td>\n\t\t\t\t\t\t<th class='izq'>Recibo Fiscal</th>\n\t\t\t\t\t\t<td>" . $this->mReciboFiscal . "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th class='izq'>Tipo de Pago</th>\n\t\t\t\t\t\t<td>" . strtoupper($this->mTipoDePago) . "</td>\n\t\t\t\t\t\t<th class='izq'>Total</th>\n\t\t\t\t\t\t<td>" . getFMoney($this->mTotalRecibo) . "</td>\n\n\t\t\t\t\t</tr>\n\n\t\t\t\t\t{$tool}\n\t\t\t\t</tbody>\n\t\t\t\t</table>";
         if ($fieldset == true) {
             $exoFicha = "<fieldset>\n\t\t\t\t\t\t\t\t<legend>&nbsp;&nbsp;INFORMACI&Oacute;N DEL RECIBO&nbsp;&nbsp;</legend>\n\t\t\t\t\t\t\t\t{$exoFicha}\n\t\t\t\t\t\t\t</fieldset>";
         }
     }
     return $exoFicha;
 }
$jxc->exportFunction('jsaGetCreditosPorMinistrar', array('idDateValue'), "#tcalendar-task");
$jxc->exportFunction('jsaEliminarLog', array('idDateValue'), "#tcalendar-task");
$jxc->exportFunction('jsaGetLog', array('idDateValue'), "#tcalendar-task");
$jxc->exportFunction('jsaGetRecibosEmitidos', array('idDateValue'), "#tcalendar-task");
$jxc->exportFunction('jsaSetCumplido', array('id-KeyEditable'));
$jxc->exportFunction('jsaGetIngresosDeldia', array('idDateValue'), "#tcalendar-task");
$jxc->exportFunction('jsaGetIngresosDelMes', array('idDateValue'), "#tcalendar-task");
$jxc->exportFunction('jsaGetIngresosMensualesPorDependencias', array('idDateValue'), "#tcalendar-task");
$jxc->exportFunction('jsaRespaldarDB', array('idDateValue'), "#avisos");
$jxc->exportFunction('jsaActualizarIdioma', array('idDateValue'), "#avisos");
//jsaRespaldarDB
$jxc->process();
$x = new jsBasicForm("", iDE_CREDITO, ".");
$xHP->init();
$xFRM = new cHForm("frmcalendartask");
$xUsr = new cSystemUser();
$alerts = "";
$xUsr->init();
if ($xUsr->getNivel() >= USUARIO_TIPO_CAJERO or OPERACION_LIBERAR_ACCIONES == true) {
    //$xFRM->addToolbar($xBtn->getBasic("Ingresos del Dia", "jsGetChart()", "grafico", "idcharts", false) );
}
$xFRM->addToolbar($xBtn->getBasic("TR.Tareas", "jsGetInformes()", "tarea", "idtareas", false));
$xFRM->addToolbar("<input type=\"date\"  id=\"idDateValue\" value=\"" . $xF->get(FECHA_FORMATO_MX) . "\" />");
if ($xUsr->getNivel() != USUARIO_TIPO_OFICIAL_AML) {
    if ($xUsr->getNivel() >= USUARIO_TIPO_OFICIAL_CRED or MODO_DEBUG == true or OPERACION_LIBERAR_ACCIONES == true) {
        $xFRM->addToolbar($xBtn->getBasic("TR.Letras Creditos Simples", "jsaGetLetrasAVencer()", "reporte", "idletrav", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Letras Pendientes", "jsaGetLetrasAVencerTodas()", "reporte", "idletrave", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Creditos Simples", "jsaGetCreditosSimplesMinistrados()", "lista", "idsimplev", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Creditos Por Autorizar", "jsaGetCreditosPorAutorizar()", "lista", "idcredaut", false));
        $xFRM->addToolbar($xBtn->getBasic("TR.Creditos Por Ministrar", "jsaGetCreditosPorMinistrar()", "lista", "idcrednpoaut", false));
        $xFRM->OButton("TR.Recibos Emitidos", "jsaGetRecibosEmitidos()", $xBtn->ic()->REPORTE);
$xCaja = new cCaja();
$xCaja->initByFechaUsuario($fecha_final, $cajero);
if (isset($_REQUEST["fechaMX"])) {
    $fecha_inicial = $xF->getFechaISO($_REQUEST["fechaMX"]);
    $fecha_final = $xF->getFechaISO($_REQUEST["fechaMX"]);
}
if (count($mails) <= 0) {
    if (MODULO_CAJA_ACTIVADO == true) {
        if ($xF->getInt($fecha_final) > $xF->getInt(fechasys())) {
            if ($xCaja->getEstatus() == TESORERIA_CAJA_ABIERTA) {
                $xHP->goToPageError(70102);
            }
        }
    }
}
$xUsr = new cSystemUser($cajero);
$xUsr->init();
$nombre = $xUsr->getNombreCompleto();
$ByDependencia = (isset($_GET["dependencia"]) and $_GET["dependencia"] != SYS_TODAS) ? " AND `socios`.`iddependencia`=" . $_GET["dependencia"] : "";
$xRPT = new cReportes();
$title = $xHP->getTitle();
$xRPT->setTitle($title);
$xRPT->setOut($out);
$xRPT->setSenders($mails);
$bheader = $xRPT->getHInicial($xHP->getTitle(), $fecha_inicial, $fecha_final, $nombre);
$xRPT->addContent($bheader);
$xRPT->setBodyMail($bheader);
$xRPT->setResponse();
$xRPT->addContent($xCaja->getResumenDeCaja());
//setlog( $xCaja->getMessages() );
if (count($mails) > 0) {
}
$xFRM->addHTML("<p class='aviso'>" . $xColonia->getMessages(OUT_HTML) . "</p>");
$xFRM->addHTML("<h3>DATOS FISCALES</h3>");
$xFRM->addHTML("<p class='aviso'>RFC evaluado : " . $xSoc->getRFC(true) . "</p>");
$xFRM->addHTML("<p class='aviso'>RFC evaluado/ret: " . $xSoc->getRFC(true, true) . "</p>");
$xFRM->addHTML("<p class='aviso'>RFC : " . $xSoc->getRFC() . "</p>");
//Iniciar por CURP
if ($xSoc->initByIDLegal("RACD-890730- KC3") == true) {
    $xFRM->addHElem("<p>El Nombre es por CURP ES " . $xSoc->getNombreCompleto() . "</p>");
    $xID = new cIDLegal($xSoc->getCURP());
    $xFRM->addHElem("<p>La fecha por CURP es " . $xID->getFechaCreacion() . "</p>");
}
$xLoc = new cDomicilioLocalidad(false);
$xLoc->setBuscar("MERXICA", 4, 1, "MX");
$xFRM->addAviso($xLoc->getNombre());
//$xC		= new cSocios_general();
/*$query		= $xC->query()->select();
$query->where("codigo > 0");
$rs	= $query->exec();
foreach ($rs as $rows){
	$xC->setData($rows);
	echo $xC->nombrecompleto()->v();
}*/
$xFRM->addHElem("<hr />");
$xUS = new cSystemUser(TASK_USR, false);
$xUS->init();
$xFRM->addHElem("<p class='aviso'>USER SYSTEM: " . $xUS->getNombreCompleto() . "</p>");
echo $xFRM->get();
echo $xP->setBodyEnd();
echo $xP->end();
//=====================================================================================================
$cuenta = parametro("cuenta", DEFAULT_CUENTA_CORRIENTE, MQL_INT);
$cuenta = parametro("idcuenta", $cuenta, MQL_INT);
$jscallback = parametro("callback");
$tiny = parametro("tiny");
$form = parametro("form");
$action = parametro("action", SYS_NINGUNO);
$xHP->init();
if ($action == SYS_UNO) {
    //		$oficial	= trim(substr($_POST["cOficialDeApertura"], 0, 15));
    //		$pwd		= trim( md5( substr($_POST["cOficialClave"],0,20) ) );
    $oficial_s = parametro("oficial", "", MQL_RAW);
    $pwd = parametro("password", "", MQL_RAW);
    $fondos = parametro("fondodecaja", 0, MQL_FLOAT);
    $pwd = strtolower($pwd);
    //Definir bien los PWD
    $cUsr = new cSystemUser($oficial_s, false);
    $sucess = $cUsr->getCompareData("contrasenna", $pwd);
    $cUsr->init();
    if ($sucess == true) {
        $IOficial = $cUsr->getID();
        if ($fondos <= 0) {
            $msg .= "ERROR\tFondos menores a los establecido {$fondos} \r\n";
        } else {
            $cCj = new cCaja();
            $ropen = $cCj->setOpenBox($IOficial, $fondos);
            if ($ropen == true) {
                $msg .= "OK\tLa Caja esta abierta\r\n";
            } else {
                if (MODO_DEBUG == true) {
                    setLog($cCj->getMessages());
                }
function getCuentaPorCajero($cajero = false)
{
    $xUsr = new cSystemUser($cajero);
    $xUsr->init();
    return $xUsr->getCuentaContableDeCaja();
}
 function getNombreUsuario()
 {
     $xUsr = new cSystemUser();
     return $xUsr->getNombreCompleto();
 }
function jsaActualizarUsuario($idusuario)
{
    $xUser = new cSystemUser($idusuario);
    $xUser->setActualizarPorPersona();
    return $xUser->getMessages(OUT_HTML);
}
            $scripts = "<script>\n\t\t\tTINY.box.show({iframe:'../frmtesoreria/{$frm}?r={$recibo}',boxid:'frameless',width:400,height:540,fixed:false,maskid:'bluemask',maskopacity:40,closejs:function(){ jsRevalidarRecibo() }})\n\t\t\t</script>";
        }
    } else {
        $eventOnLoad = "window.print();";
    }
}
echo $xHP->setBodyinit($eventOnLoad);
echo $scripts;
//pegar script como variable, eventonload
//<----------------------------------------------------------
$variable_numero_de_recibo = $recibo;
$variable_monto_del_recibo = number_format($totaloperacion, 2, '.', ',');
$variable_monto_del_recibo_en_letras = convertirletras($totaloperacion);
$variable_fecha_del_recibo = "";
$variable_tipo_de_pago = "";
$xCajero = new cSystemUser($DRec["idusuario"]);
$variable_nombre_del_cajero = $xCajero->getNombreCompleto();
$variable_observacion_del_recibo = $DRec["observacion_recibo"];
$variable_datos_de_pago = $xRec->getDatosDeCobro();
$xSuc = new cSucursal($DRec["sucursal"]);
$xSuc->init();
$DSuc = $xSuc->getDatosInArray();
$variable_lugar = $DSuc["municipio"] . ", " . $DSuc["estado"];
$variable_marca_de_tiempo = date("Ymd:His");
$tipoDocto = "";
$estatDocto = "";
$letras = "";
/* -----------------Verifica si es solicitud, si es imprime el saldo actual */
if ($origen == TESORERIA_RECIBOS_ORIGEN_CRED or $origen == TESORERIA_RECIBOS_ORIGEN_MIXTO) {
    $DD = $xRec->getInfoDoctoInArray();
    if ($DD != false and is_array($DD)) {
 function setUsuario($usuario = false)
 {
     $usuario = $usuario == false ? getUsuarioActual() : $usuario;
     $Usr = new cSystemUser($usuario);
     $this->mArr["variable_nombre_del_cajero"] = $Usr->getNombreCompleto();
     $this->mArr["variable_oficial"] = $Usr->getNombreCompleto();
     $this->mArr["variable_testigo_del_acto"] = $Usr->getNombreCompleto();
 }
 function getBuscarEnListaNegra($nombre = "", $primerapellido = "", $segundoapellido = "")
 {
     $this->init();
     $nombre = $nombre == "" ? $this->getOPersona()->getNombre() : $nombre;
     $primerapellido = $primerapellido == "" ? $this->getOPersona()->getApellidoPaterno() : $primerapellido;
     $segundoapellido = $segundoapellido == "" ? $this->getOPersona()->getApellidoMaterno() : $segundoapellido;
     $xUser = new cSystemUser();
     $ctx = $xUser->getCTX();
     $extras = AML_BUSQUEDA_PERSONAS_REFORZADA == true ? "&jarowinkler=true&metaphone=true" : "";
     //$nombre				= urlencode($nombre);
     $result = false;
     $items = 0;
     //count($data);
     $mURL = SVC_REMOTE_HOST . "svc/listanegra.svc.php?n=" . urlencode($nombre) . "&p=" . urlencode($primerapellido) . "&m=" . urlencode($segundoapellido) . "&ctx={$ctx}" . $extras;
     if (MODO_DEBUG == true) {
         setLog($mURL);
     }
     $ql = new MQLService("", "");
     $json = $ql->getRequest($mURL);
     //file_get_contents($mURL);
     $data = json_decode($json, true);
     if (!$data) {
         $this->mMessages .= "ERROR\tNo existen ITEMS\r\n";
     } else {
         foreach ($data as $subobj) {
             $items++;
             //{"codigo":"16145","primerapellido":"CALLE","segundoapellido":"QUIROS","nombres":" LUIS SANTIAGO","curp":"SDNTK-16145","tipo":"metaphone"}
             //var_dump($subobj);
             //setLog( $subobj->primerapellido );
             //foreach ($subobj as $cls){
             //}
             $this->mMessages .= "WARN\t" . $subobj["curp"] . " : Coincidencia " . $subobj["primerapellido"] . " " . $subobj["segundoapellido"] . " " . $subobj["nombres"] . " encontrado con  " . $subobj["tipo"] . "\r\n";
         }
     }
     //setLog("NUMERO DE ITEMS $items");
     $this->mMessages .= "WARN\tReporte : {$mURL}&report=true&ret=true \r\n";
     $this->mURLConsulta = "{$mURL}&report=true&ret=true";
     //var_dump($data);
     if ($items >= 1) {
         $result = true;
         $this->mMessages .= "ERROR\tPersona en Lista Negra o con Alto riesgo con {$items} posibles concindencias\r\n";
     }
     return $result;
 }
$theFile = __FILE__;
$permiso = getSIPAKALPermissions($theFile);
if ($permiso === false) {
    header("location:../404.php?i=999");
}
$_SESSION["current_file"] = addslashes($theFile);
//<=====	FIN_H
//=====================================================================================================
$xInit = new cHPage("", HP_SERVICE);
$txt = "";
$svc = new MQLService("", "");
$ql = new MQL();
$data = isset($_REQUEST["data"]) ? $_REQUEST["data"] : null;
$command = isset($_REQUEST["cmd"]) ? $svc->getDecryptData($_REQUEST["cmd"]) : null;
//$context	= (isset($_REQUEST["ctx"])) ? $svc->getDecryptData($_REQUEST["ctx"]) : null;
$xTu = new cSystemUser(TASK_USR, false);
$xTu->init();
$ctx = $xTu->getCTX();
$cmd = $svc->getEncryptData($command);
switch ($command) {
    case TPERSONAS_GENERALES:
        $dpersona = $svc->getService(SVC_ASOCIADA_HOST . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
        if (is_array($dpersona)) {
            $xSoc = new cSocios_general($dpersona);
            $xSoc->query()->insert()->save();
            //Iniciar Cuenta de Captacion
        }
        break;
    case TPERSONAS_DIRECCIONES:
        $ddomicilio = $svc->getService(SVC_ASOCIADA_HOST . "svc/exportar.svc.php?ctx={$ctx}&data={$data}&cmd={$cmd}");
        if (is_array($ddomicilio)) {