function getFactura($enviar = false, $out = OUT_PDF)
 {
     $ready = null;
     $xml = "";
     $unidad = "NO APLICA";
     $cantidad = 1;
     $mql = new MQL();
     $xLis = new cSQLListas();
     $xLoc = new cLocal();
     $xPais = new cDomiciliosPaises(EACP_CLAVE_DE_PAIS);
     $xLog = new cCoreLog();
     $sql = "SELECT * FROM `operaciones_archivo_de_facturas` WHERE `clave_de_recibo` = " . $this->mCodigoDeRecibo . " LIMIT 0,1";
     $xArch = new cOperaciones_archivo_de_facturas();
     $DFact = $mql->getDataRow($sql);
     if (isset($DFact["clave_de_recibo"])) {
         $xArch->setData($DFact);
         $this->mMessages .= "OK\tEl UUID existe  " . $xArch->uuid()->v(OUT_TXT) . "\r\n";
         if ($enviar == true) {
             if ($this->getOPersona() == null) {
             } else {
                 $xSoc = $this->getOPersona();
                 $email = $xSoc->getCorreoElectronico();
                 $comprobante = PATH_FACTURAS . $xArch->uuid()->v(OUT_TXT);
                 file_put_contents($comprobante . ".xml", base64_decode($xArch->contenido()->v(OUT_TXT)));
                 file_put_contents($comprobante . ".pdf", base64_decode($xArch->impreso()->v(OUT_TXT)));
                 $ready = $out == OUT_PDF ? base64_decode($xArch->impreso()->v(OUT_TXT)) : base64_decode($xArch->contenido()->v(OUT_TXT));
                 $xNotif = new cNotificaciones();
                 //PDF y XML
                 $arrFil = array();
                 $arrFil["archivo1"]["path"] = $comprobante . ".pdf";
                 $arrFil["archivo2"]["path"] = $comprobante . ".xml";
                 $xNotif->sendMail("Factura del Recibo " . $this->mCodigoDeRecibo, "Factura del Recibo " . $this->mCodigoDeRecibo, $email, $arrFil);
                 //Enviar al Archivo mail
                 $xNotif->sendMail("Factura del Recibo " . $this->mCodigoDeRecibo, "Factura del Recibo " . $this->mCodigoDeRecibo, FACTURACION_MAIL_ARCHIVO, $arrFil);
                 $this->mMessages .= $xNotif->getMessages();
             }
         } else {
             $ready = $out == OUT_PDF ? $xArch->impreso()->v(OUT_TXT) : $xArch->contenido()->v(OUT_TXT);
         }
     } else {
         $xLog->add("WARN\tGenerando Nueva Factura\r\n", $xLog->DEVELOPER);
         //cargar Archivo
         $xPais->init();
         if ($this->mReciboIniciado == false) {
             $this->init();
         }
         if ($this->getOPersona() == null) {
             $xLog->add("ERROR\tAl cargar la Persona\r\n");
         } else {
             $xFact = new cFacturaElectronica();
             //datos de la emisora
             //persona iniciada
             $xSoc = $this->getOPersona();
             $email = $xSoc->getCorreoElectronico();
             $xFact->setEmisor(EACP_NAME, EACP_RFC, EACP_DOMICILIO_CALLE, EACP_DOMICILIO_NUM_EXT, EACP_DOMICILIO_NUM_INT, EACP_CODIGO_POSTAL, EACP_COLONIA, EACP_MUNICIPIO, EACP_ESTADO, $xPais->getNombre());
             $xFact->setRegimenFiscal(EACP_REGIMEN_FISCAL);
             $calle = $xLoc->DomicilioCalle();
             $numeroInt = $xLoc->DomicilioNumeroInterior();
             $numeroExt = $xLoc->DomicilioNumeroExterior();
             $codigoPostal = $xLoc->DomicilioCodigoPostal();
             $colonia = $xLoc->DomicilioColonia();
             $xSocDom = $xSoc->getODomicilio();
             $pais = $xLoc->getNombreDePais();
             $estado = $xLoc->DomicilioEstado();
             $municipio = $xLoc->DomicilioMunicipio();
             $tasa_iva = TASA_IVA;
             $xFact->setLugarDeExpedicion($xLoc->DomicilioCalle(), $xLoc->DomicilioNumeroExterior(), $xLoc->DomicilioNumeroInterior(), $xLoc->DomicilioCodigoPostal(), $xLoc->DomicilioColonia(), $xLoc->DomicilioMunicipio(), $xLoc->DomicilioEstado(), $xLoc->getNombreDePais());
             if ($xSocDom == null) {
                 $xLog->add("WARN\tNo hay domicilio Valido\r\n", $xLog->DEVELOPER);
             } else {
                 $calle = $xSocDom->getCalle();
                 $numeroExt = $xSocDom->getNumeroExterior();
                 $numeroInt = $xSocDom->getNumeroInterior();
                 $codigoPostal = $xSocDom->getCodigoPostal();
                 $colonia = $xSocDom->getColonia();
                 $municipio = $xSocDom->getMunicipio();
                 $estado = $xSocDom->getEstado();
                 $pais = $xSocDom->getNombreDePais();
             }
             //Cargar datos del Docto
             //$this->getOrigen();
             $OTipoRec = $this->getOTipoRecibo();
             if ($OTipoRec->getOrigen() == RECIBOS_ORIGEN_MIXTO or $OTipoRec->getOrigen() == RECIBOS_ORIGEN_COLOCACION) {
                 $xCred = new cCredito($this->getCodigoDeDocumento());
                 $xCred->init();
                 $tasa_iva = $xCred->getTasaIVA();
                 $xLog->add("WARN\tLa tasa de IVA es {$tasa_iva}\r\n", $xLog->DEVELOPER);
             }
             $xFact->setReceptor($xSoc->getNombreCompleto(), $xSoc->getRFC(true, true), $calle, $numeroExt, $numeroInt, $codigoPostal, $colonia, $municipio, $estado, $pais);
             //Datos del pagos
             $formaDePago = "Pago en una sola exhibición";
             $cuentaDePago = "No Identificado";
             $arrEquiv = array(TESORERIA_COBRO_DOCTO => "Documentos", TESORERIA_COBRO_EFECTIVO => "Efectivo", TESORERIA_COBRO_INTERNO => "Documentos", TESORERIA_COBRO_MULTIPLE => "Documentos", TESORERIA_COBRO_NINGUNO => "Documentos", TESORERIA_COBRO_TRANSFERENCIA => "Transferencia", TESORERIA_COBRO_CHEQUE => "Cheque");
             $metodoDePago = $arrEquiv[$this->getTipoDePago()];
             //cargar equivalencias
             //TODO: Considerar cambios en otro de tipo de tributacion
             if ($this->getTipoDePago() == TESORERIA_COBRO_TRANSFERENCIA or $this->getTipoDePago() == TESORERIA_COBRO_CHEQUE) {
                 $OCaja = $this->getOCaja();
                 $cuentaDePago = $OCaja->getCuentaBancoActivo();
             }
             //Cheque, Transferencia, Depósito
             $xFact->setDatosDePago($formaDePago, $metodoDePago, $cuentaDePago);
             $sql = "SELECT\n\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`codigo_de_base`,\n\t\t\t\t\t`operaciones_mvtos`.`recibo_afectado`,\n\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro`,\n\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`subclasificacion`,\n\t\t\t\t\t`operaciones_tipos`.`descripcion_operacion` AS `operacion`,\n\t\t\t\t\t`operaciones_mvtos`.`fecha_operacion`,\n\t\t\t\t\t`operaciones_mvtos`.`afectacion_real` AS 'monto'  \n\t\t\t\tFROM\n\t\t\t\t\t`operaciones_mvtos` `operaciones_mvtos` \n\t\t\t\t\t\tINNER JOIN `eacp_config_bases_de_integracion_miembros` \n\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros` \n\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = \n\t\t\t\t\t\t`eacp_config_bases_de_integracion_miembros`.`miembro` \n\t\t\t\t\t\t\tINNER JOIN `operaciones_tipos` `operaciones_tipos` \n\t\t\t\t\t\t\tON `operaciones_mvtos`.`tipo_operacion` = `operaciones_tipos`.\n\t\t\t\t\t\t\t`idoperaciones_tipos` \n\t\t\t\tWHERE\n\t\t\t\t\t(`eacp_config_bases_de_integracion_miembros`.`codigo_de_base` =11000) AND\n\t\t\t\t\t(`operaciones_mvtos`.`recibo_afectado` =" . $this->mCodigoDeRecibo . " )";
             $iva = 0;
             $total = 0;
             $rs = $mql->getDataRecord($sql);
             foreach ($rs as $rows) {
                 $descripcion = $rows["operacion"];
                 $valor = $rows["monto"];
                 $tipo = $rows["subclasificacion"];
                 $total += $valor;
                 if ($tipo == 1000) {
                     $iva += $rows["monto"];
                 } else {
                     $xFact->addConcepto($cantidad, $unidad, $valor, $descripcion);
                 }
             }
             //agregar IVA
             if ($iva > 0) {
                 $xFact->addTrasladado("IVA", $tasa_iva, $iva);
             }
             $xml = $xFact->get();
             $this->mOFactura = $xFact;
             if ($total <= 0) {
                 $enviar = false;
             }
         }
         if ($enviar == true) {
             if ($this->mOFactura != null) {
                 if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
                     if ($this->mOFactura->timbrar() == 1) {
                         //ready = true
                         $xNotif = new cNotificaciones();
                         //PDF y XML
                         $arrFil = array();
                         $arrFil["archivo1"]["path"] = $this->mOFactura->getComprobante() . ".pdf";
                         $arrFil["archivo2"]["path"] = $this->mOFactura->getComprobante() . ".xml";
                         $xNotif->sendMail("Factura del Recibo " . $this->mCodigoDeRecibo, "Factura del Recibo " . $this->mCodigoDeRecibo, $email, $arrFil);
                         //Enviar al Archivo mail
                         $xNotif->sendMail("Factura del Recibo " . $this->mCodigoDeRecibo, "Factura del Recibo " . $this->mCodigoDeRecibo, FACTURACION_MAIL_ARCHIVO, $arrFil);
                         //Guardar en DB
                         $this->mOFactura->setArchivar($this->mCodigoDeRecibo);
                         $xLog->add($xNotif->getMessages(), $xLog->DEVELOPER);
                         $ready = $out == OUT_PDF ? $this->mOFactura->getPDF() : $this->mOFactura->getXML();
                     }
                 } else {
                     $xLog->add("WARN\tNo hay email valido para la Factura ({$email})\r\n", $xLog->DEVELOPER);
                 }
                 $xLog->add($this->mOFactura->getMessages(), $xLog->DEVELOPER);
             }
         }
     }
     $this->mMessages .= $xLog->getMessages();
     return $ready;
 }
 function sendAlerts($PersonaDeOrigen, $PersonaDeDestino, $TipoDeAlerta, $mensaje = "", $documento = false, $fecha = false, $hora = false, $valorDeterminado = 0, $tipo_de_docto = false, $tercero_relacionado = DEFAULT_SOCIO)
 {
     $hora = setNoMenorQueCero($hora) <= 0 ? date("Hi") : $hora;
     $fecha = $fecha == false ? fechasys() : $fecha;
     $documento = $documento == false ? DEFAULT_RECIBO : $documento;
     $tipo_de_docto = $tipo_de_docto == false ? $this->mTipoDeDocto : $tipo_de_docto;
     $this->mTipoDeDocto = $tipo_de_docto;
     $resultado = true;
     $xRsk = new cAml_risk_catalog();
     $xSuc = new cSucursal();
     $xSuc->init();
     $idnumerico = $xSuc->getClaveNumerica();
     $xRsk->setData($xRsk->query()->initByID($TipoDeAlerta));
     $riesgo = $xRsk->valor_ponderado()->v();
     $nombreRies = $xRsk->descripcion()->v();
     $claseRies = $xRsk->tipo_de_riesgo()->v();
     $valorDeterminado = $valorDeterminado == 0 ? $xRsk->valor_ponderado()->v() : $valorDeterminado;
     $xF = new cFecha();
     $fecha = $xF->getInt($fecha);
     $xAl = new cAml_alerts();
     $xAl->estado_en_sistema(SYS_UNO);
     $xAl->fecha_de_checking(SYS_CERO);
     $xAl->fecha_de_origen($fecha);
     $xAl->fecha_de_registro($xF->getInt(fechasys()));
     $xAl->hora_de_proceso($hora);
     $xAl->documento_relacionado($documento);
     $xAl->medio_de_envio(AML_ALERT_MAIL);
     $xAl->mensaje($mensaje);
     $xAl->riesgo_calificado($valorDeterminado);
     $xAl->tipo_de_aviso($TipoDeAlerta);
     $xAl->sucursal($idnumerico);
     //Verificar
     $xAl->entidad(EACP_CLAVE_CASFIN);
     //Actualizar
     $xAl->usuario(getUsuarioActual());
     $xAl->persona_de_destino($PersonaDeDestino);
     $xAl->persona_de_origen($PersonaDeOrigen);
     $xAl->tipo_de_documento($tipo_de_docto);
     $xAl->tercero_relacionado($tercero_relacionado);
     $id_de_alerta = $xAl->query()->getLastID();
     $xAl->clave_de_control($id_de_alerta);
     $ql = $xAl->query()->insert();
     $res = $ql->save();
     if (setNoMenorQueCero($res) <= 0) {
         $this->mMessages .= "ERROR\tAl guardar registro ({$idnumerico})\r\n";
         if (MODO_DEBUG == true) {
             $this->mMessages .= $ql->getMessages(OUT_TXT);
         }
         $resultado = false;
     }
     //$xCatRiesgo				= new cAml_risk_catalog();
     //$xCatRiesgo->setData( $xCatRiesgo->query()->initByID($TipoDeAlerta) );
     //
     $xCatRiesgos = new cAml_risk_catalog();
     $xCatRiesgos->setData($xCatRiesgos->query()->initByID($TipoDeAlerta));
     $nombre_riesgo = $xCatRiesgos->descripcion()->v();
     //Enviar SMS
     $xMail = new cNotificaciones();
     //obtener los datos del usuario
     $xVUser = new cVistaUsuarios();
     $xD = $xVUser->query()->initByID($PersonaDeDestino);
     $xVUser->setData($xD);
     $userP = $xVUser->codigo_de_persona()->v();
     $mailD = false;
     $telD = false;
     $xSoc = new cSocio($userP);
     if ($xSoc->existe($userP) == true) {
         $xSoc->init();
         $mailD = $xSoc->getCorreoElectronico();
         $telD = $xSoc->getTelefonoPrincipal();
     } else {
         $this->mMessages .= "ERROR\tNo existe la persona de envio {$userP}\r\n";
     }
     //Array de valores
     $arrV = array();
     $fechacorta = $xF->getFechaCorta($xF->getFechaByInt($fecha));
     $arrV["variable_documento_codigo"] = $documento;
     $arrV["variable_docto_fecha"] = $fechacorta;
     $arrV["variable_docto_hora"] = $hora;
     $arrV["variable_nivel_de_riesgo"] = $riesgo;
     $arrV["variable_tipo_de_riesgo"] = $nombreRies;
     $arrV["variable_clasificacion_de_riesgo"] = $claseRies;
     $arrV["variable_codigo_de_alerta"] = $id_de_alerta;
     $arrV["variable_mensaje_de_alerta"] = $mensaje;
     $arrV["variable_url_del_sistema"] = SAFE_HOST_URL;
     //Enviar Mail
     $xFmt = new cFormato(800);
     $xFmt->setUsuario($PersonaDeDestino);
     $xFmt->setPersona($PersonaDeOrigen);
     $xFmt->setProcesarVars($arrV);
     $txtMail = $xFmt->get();
     if ($valorDeterminado > 51 or $this->mForceAvisos == true) {
         $xMail->setTitulo(AML_TITULO_DE_ALERTA);
         $this->mMessages .= $xMail->send($txtMail, $mailD, $telD, $PersonaDeDestino, "{$fechacorta}-{$claseRies}-{$mensaje}", "aml.{$mailD}");
         if ($this->mForceRegRiesgo == true) {
             //Agregar el riesgo
             $xAlert = new cAMLAlertas($id_de_alerta);
             $regFecha = $xF->getFechaByInt($fecha);
             $xAlert->setConfirmaAlerta($mensaje, $regFecha);
             $this->mMessages .= $xAlert->getMessages();
             //$xPAML		= new cAMLPersonas($PersonaDeOrigen);
             //$xPAML->setAgregarPerfilDeRiesgo($TipoDeAlerta, $fecha, $valorDeterminado, $documento, $tipo_de_docto, $PersonaDeDestino, $hora, $tercero_relacionado, $mensaje );
             //$this->mMessages	.= $xPAML->getMessages();
         }
     }
     return $resultado;
 }
    $arr = array("mensajes" => $msg, "registros" => $operaciones, "errores" => $totalerrores);
    echo json_encode($arr);
} else {
    if ($production == true and $errors == false and $operaciones > 0) {
        $archivo = $xLayout->getClave() . $xT->cSerial(6, $casfin) . $FechaTitulo . "." . $xT->cSerial(3, $supervisor);
        //header("Content-type: text/x-csv");
        header("Content-type: text/plain");
        //header("Content-type: application/csv");
        header("Content-Disposition: attachment; filename={$archivo}");
        echo $rpt;
        if ($definitivo == true) {
            //Guardar
            $sqlUpdate = " UPDATE `aml_risk_register` SET `estado_de_envio` = 1, `fecha_de_envio`= " . $xF->getInt() . "\n\t\t\tWHERE (SELECT `tipo_de_riesgo` FROM `aml_risk_catalog` WHERE\n\t\t\t(`clave_de_control`= `aml_risk_register`.`tipo_de_riesgo`= " . AML_CLAVE_OPERACIONES_INTERNAS . "\n\t\t\t\tOR\n\t\t\t`clave_de_control`= `aml_risk_register`.`tipo_de_riesgo`= " . AML_CLAVE_OPERACIONES_INUSUALES . ")\n\t\t\tAND (getFechaByInt(`aml_risk_register`.`fecha_de_reporte`) <='{$FechaFinal}')\n\t\t\tAND (`aml_risk_register`.`estado_de_envio` =0)\n\t\t\tAND (`aml_risk_register`.`reporte_inmediato` =1)\t\t\t\n\t\t\t";
            $query->setRawQuery($sqlUpdate);
            //enviar por mail al administrador
            $xMail = new cNotificaciones();
            $xMail->sendMail($archivo, $rpt, ADMIN_MAIL);
        }
    } else {
        $xRPT = new cReportes();
        $xRPT->setOut(OUT_HTML);
        $xRPT->addContent($xRPT->getHInicial($xHP->getTitle(), $FechaInicial, $FechaFinal));
        $arrTitulos = array();
        foreach ($Estructura as $indice => $propiedades) {
            $xCampo = new cReportes_LayoutTipos($propiedades);
            $arrTitulos[] = $xCampo->getNombre();
        }
        $xHTable->addTitles($arrTitulos);
        if ($msg != "") {
            $xRPT->addFooterBar("<h3>El reporte contiene los siguientes errores</h3>" . $msg);
        }
 function setActualizarNivelDeRiesgo($nivel = SYS_RIESGO_BAJO, $mensaje = "", $fecha = false)
 {
     $xNot = new cNotificaciones();
     $xF = new cFecha();
     $fecha = $xF->getFechaISO($fecha);
     $mensaje = $xNot->cleanString($mensaje);
     //AML.- Agregar aviso de cambio
     if ($nivel >= SYS_RIESGO_ALTO and MODULO_AML_ACTIVADO == true) {
         $xAml = new cAML();
         $xAml->setForceAlerts();
         $xAml->sendAlerts($this->mCodigo, AML_OFICIAL_DE_CUMPLIMIENTO, AML_RISK_INTERNAL_OPERATION, $mensaje, false, $fecha);
         //TODO: Exportar a asociada, falta relaciones exportar relaciones
         $this->getExportarAsociada(TPERSONAS_GENERALES, SVC_REMOTE_HOST);
         $this->getExportarAsociada(TPERSONAS_DIRECCIONES, SVC_REMOTE_HOST);
         $this->getExportarAsociada(TPERSONAS_ACTIVIDAD_ECONOMICA, SVC_REMOTE_HOST);
         $this->mMessages .= $xAml->getMessages();
     }
     //Omitir AML en la actualizacion
     $this->setOmitirAML(true);
     $this->setUpdate(array("nivel_de_riesgo_aml" => $nivel));
     //agregar una Noticiacion a la Persona de Nota
     $this->addMemo(MEMOS_TIPO_HISTORIAL, $mensaje, false, $fecha);
 }
 function setSendToMail($titulo = "", $email = false)
 {
     $email = $email == false ? ADMIN_MAIL : $email;
     $lng = new cLang();
     $titulo = $lng->getT($titulo);
     $body = "TITLE: " . $titulo . "\r\n";
     $body .= "FILE: " . $this->mName . "\r\n";
     //
     $xAviso = new cNotificaciones();
     $xAviso->sendMail($titulo, $body, $email, array("path" => $this->mCompleteName));
     return $xAviso->getMessages();
 }
 function sendMail($subject = "", $body = "", $to = "", $arrFile = false)
 {
     $xNot = new cNotificaciones();
     return $xNot->sendMail($subject, $body, $to, $arrFile);
 }
 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;
 }