Example #1
0
function ValidarRuc($ruc)
{
    $empresa = BuscarRuc($ruc);
    if ($empresa[1] != "") {
        return true;
    } else {
        return false;
    }
}
function Entidades($Arg)
{
    global $ConexionEmpresa, $enlace, $CtaSuscripcion, $UMiembro;
    switch ($Arg) {
        case "ListadoEnt":
            $btn = "Buscar]" . $enlace . "?Entidades=EntidadCrear]PanelB}";
            $btn = Botones($btn, 'botones1', '');
            $btn = tituloBtnPn("<span></span><p >REGISTRO DE EMPRESAS</p><div class='bicel'></div>", $btn, "70px", "TituloA");
            $sql = "SELECT RUC," . "RazonSocial as 'RAZON SOCIAL'," . "DireccionFiscal as 'DIRECCION FISCAL' " . " FROM ct_entidad ";
            //. "WHERE CtaSuscripcion = '".$CtaSuscripcion."' and UMiembro='".$UMiembro."'";
            $clase = 'reporteA';
            $panel = 'PanelB';
            $reporte = ListR2('', $sql, $ConexionEmpresa, $clase, '', $url, $enlaceCod, $panel, 'busentidad', '', '');
            $s = "<div class= 'PanelPadding'>" . $btn . $reporte . "</div>";
            WE($s);
            break;
        case "EntidadCrear":
            $btn = "<div class='botIconS'><i class='icon-arrow-left'></i></div>]" . $enlace . "?Entidades=ListadoEnt]PanelB}";
            $btn = Botones($btn, 'botones1', '');
            $btn = tituloBtnPn("<span>Registrar</span><p > REGISTRO DE EMPRESAS</p><div class='bicel'></div>", $btn, "50px", "TituloA");
            $uRLForm = "Buscar]" . $enlace . "?Entidades=Confirmar]PanelB]F]}";
            $form = c_form_ult('', $ConexionEmpresa, 'busentidad', 'CuadroA', $path, $uRLForm, "'" . $codEntidad . "'", $tSelectD);
            $form = "<div style='width:100%;'>" . $btn . $form . "</div>";
            $s = "<div class= 'PanelPadding'>" . $form . "</div>";
            WE($s);
            break;
        case "Confirmar":
            $RucBus = post('Ruc');
            $btn = "<div class='botIconS'><i class='icon-arrow-left'></i></div>]" . $enlace . "?Entidades=ListadoEnt]PanelB}";
            $btn .= "Registrar]" . $enlace . "?Entidades=GrabarEntidad&RucBus=" . $RucBus . "]PanelB]}";
            $btn = Botones($btn, 'botones1', '');
            $btn = tituloBtnPn("<span>Registrar</span><p >REGISTRO DE EMPRESAS</p><div class='bicel'></div>", $btn, "140px", "TituloA");
            $val = BuscarRuc($RucBus);
            $sql = "SELECT '" . $val[0] . "' as RUC,'" . $val[1] . "' as 'RAZON SOCIAL','" . $val[2] . "' as 'DIRECCION FISCAL'";
            $clase = 'reporteA';
            $panel = 'PanelB';
            $reporte = ListR2('', $sql, $ConexionEmpresa, $clase, '', $url, $enlaceCod, $panel, 'busentidad', '', '');
            $s = "<div class= 'PanelPadding'>" . $btn . $reporte . "</div>";
            WE($s);
            break;
        case "GrabarEntidad":
            if (get('RucBus') != "") {
                $val = BuscarRuc(get('RucBus'));
                $hora = date("y/m/d h:m:s");
                if ($rg['codigo'] == "") {
                    $val2 = array('Ruc' => $val[0], 'RazonSocial' => $val[1], 'DireccionFiscal' => $val[2], 'CtaSuscripcion' => $_SESSION['CtaSuscripcion']['string'], 'UMiembro' => $_SESSION['UMiembro']['string'], 'FHCreacion' => $hora, 'IpPublica' => getRealIP(), 'IpPrivada' => getRealIP());
                    insert("ct_entidad", $val2, $ConexionEmpresa);
                }
            }
            $btn = "Buscar]" . $enlace . "?Entidades=EntidadCrear]PanelB}";
            $btn = Botones($btn, 'botones1', '');
            $btn = tituloBtnPn("<span></span><p >REGISTRO DE EMPRESAS</p><div class='bicel'></div>", $btn, "70px", "TituloA");
            $sql = "SELECT RUC," . "RazonSocial as 'RAZON SOCIAL'," . "DireccionFiscal as 'DIRECCION FISCAL' " . " FROM ct_entidad " . "WHERE CtaSuscripcion = '" . $CtaSuscripcion . "' and UMiembro = '" . $UMiembro . "'";
            $clase = 'reporteA';
            $panel = 'PanelB';
            $reporte = ListR2('', $sql, $ConexionEmpresa, $clase, '', $url, $enlaceCod, $panel, 'busentidad', '', '');
            $s = "<div class= 'PanelPadding'>" . $btn . $reporte . "</div>";
            WE($s);
            break;
    }
}
function Entidades($Arg)
{
    global $ConexionEmpresa, $enlace;
    switch ($Arg) {
        case "Listado":
            $btn = "Agregar]" . $enlace . "?Entidades=EntidadesAdd]PanelB}";
            $btn = Botones($btn, 'botones1', '');
            $btn = tituloBtnPn("<span>SuscripciĆ³n</span><p >EMPRESAS</p><div class='bicel'></div>", $btn, "70px", "TituloA");
            $sql = "SELECT ct_entidad.ruc as RUC," . "ct_entidad.razonsocial as 'RAZON SOCIAL'," . "ct_entidad.direccionfiscal as 'DIRECCION'," . "ct_empresasuscripcion.Codigo as CodigoAjax " . "FROM ct_empresasuscripcion inner join ct_entidad " . "on ct_empresasuscripcion.entidad=ct_entidad.codigo " . "WHERE ct_empresasuscripcion.UMiembro=" . $_SESSION['UMiembro'];
            $clase = 'reporteA';
            $panel = 'PanelB';
            $enlaceCod = '';
            $url = $enlace . "?Entidades=Listado";
            $reporte = ListR2('', $sql, $ConexionEmpresa, $clase, '', $url, $enlaceCod, $panel, 'ct_empresasuscripcion', '', '');
            $s = "<div class= 'PanelPadding'>" . $btn . $reporte . "</div>";
            WE($s);
            break;
        case "EntidadesAdd":
            $btn = "<div class='botIconS'><i class='icon-arrow-left'></i></div>]" . $enlace . "?Entidades=Listado]PanelB}";
            $btn = Botones($btn, 'botones1', '');
            $btn = tituloBtnPn("<span>Registrar</span><p > REGISTRO DE EMPRESAS</p><div class='bicel'></div>", $btn, "50px", "TituloA");
            $uRLForm = "Buscar]" . $enlace . "?Entidades=Confirmar]PanelB]F]}";
            $form = c_form_ult('', $ConexionEmpresa, 'busentidad', 'CuadroA', $path, $uRLForm, "'" . $codEntidad . "'", $tSelectD);
            $form = "<div style='width:100%;'>" . $btn . $form . "</div>";
            $s = "<div class= 'PanelPadding'>" . $form . "</div>";
            WE($s);
            break;
        case "Confirmar":
            $RucBus = post('Ruc');
            $btn = "<div class='botIconS'><i class='icon-arrow-left'></i></div>]" . $enlace . "?Entidades=Listado]PanelB}";
            $btn .= "Registrar]" . $enlace . "?Entidades=GrabarEntidad&RucBus=" . $RucBus . "]PanelB]}";
            $btn = Botones($btn, 'botones1', '');
            $btn = tituloBtnPn("<span>Registrar</span><p >REGISTRO DE EMPRESAS</p><div class='bicel'></div>", $btn, "140px", "TituloA");
            $val = BuscarRuc($RucBus);
            $sql = "SELECT '" . $val[0] . "' as RUC,'" . $val[1] . "' as 'RAZON SOCIAL','" . $val[2] . "' as 'DIRECCION FISCAL'";
            $clase = 'reporteA';
            $panel = 'PanelB';
            $reporte = ListR2('', $sql, $ConexionEmpresa, $clase, '', $url, $enlaceCod, $panel, 'busentidad', '', '');
            $s = "<div class= 'PanelPadding'>" . $btn . $reporte . "</div>";
            WE($s);
            break;
        case "GrabarEntidad":
            $sql = "select max(codigo)+1 as cod from ct_suscripcion";
            $rgt = rGT($ConexionEmpresa, $sql);
            $sql = "select codigo from ct_entidad where ruc like '%" . get('RucBus') . "%'";
            $rg = rGT($ConexionEmpresa, $sql);
            $codentid = "";
            if (get('RucBus') != "") {
                $val = BuscarRuc(get('RucBus'));
                $hora = date("y/m/d h:m:s");
                if ($rg['codigo'] == "") {
                    $val2 = array('Ruc' => $val[0], 'RazonSocial' => $val[1], 'DireccionFiscal' => $val[2], 'CtaSuscripcion' => $rgt['cod'], 'UMiembro' => $_SESSION['UMiembro']['string'], 'FHCreacion' => $hora, 'IpPublica' => getRealIP(), 'IpPrivada' => getRealIP());
                    $codent = insert("ct_entidad", $val2, $ConexionEmpresa);
                    $codentid = $codent['lastInsertId'];
                } else {
                    $sql = "select codigo from ct_entidad where ruc='" . $val[0] . "'";
                    $rg2 = rGT($ConexionEmpresa, $sql);
                    $codentid = $rg2['codigo'];
                }
                $sql = "select codigo from ct_acreditacion where CtaSuscripcion='" . $_SESSION['CtaSuscripcion'] . "'";
                $rg2 = rGT($ConexionEmpresa, $sql);
                $codacr = $rg2['codigo'];
                $array1 = array('Codigo' => $rgt['cod'], 'CtaSuscripcion' => $rgt['cod'], 'UMiembro' => $_SESSION['UMiembro']['string'], 'FHCreacion' => date('y-m-d h:m:s'), 'IpPublica' => getRealIP(), 'IpPrivada' => getRealIP(), 'Acreditacion' => $codacr, 'NroSuscripcion' => $rgt['cod']);
                insert('ct_suscripcion', $array1, $ConexionEmpresa);
                $array = array('CtaSuscripcion' => $rgt['cod'], 'UMiembro' => $_SESSION['UMiembro']['string'], 'FHCreacion' => date('y-m-d h:m:s'), 'IpPublica' => getRealIP(), 'IpPrivada' => getRealIP(), 'Entidad' => $codentid, 'Suscripcion' => $rgt['cod'], 'RazonSocial' => $val[1], 'Predeterminado' => '0');
                insert("ct_empresasuscripcion", $array, $ConexionEmpresa);
            }
            $btn = "Agregar]" . $enlace . "?Entidades=EntidadesAdd]PanelB}";
            $btn = Botones($btn, 'botones1', '');
            $btn = tituloBtnPn("<span></span><p >REGISTRO DE EMPRESAS</p><div class='bicel'></div>", $btn, "70px", "TituloA");
            $sql = "SELECT ct_entidad.ruc as RUC," . "ct_entidad.razonsocial as 'RAZON SOCIAL'," . "ct_entidad.direccionfiscal as 'DIRECCION'," . "ct_empresasuscripcion.Codigo as CodigoAjax " . "FROM ct_empresasuscripcion inner join ct_entidad " . "on ct_empresasuscripcion.entidad=ct_entidad.codigo " . "WHERE ct_empresasuscripcion.UMiembro=" . $_SESSION['UMiembro'];
            $clase = 'reporteA';
            $panel = 'PanelB';
            $enlaceCod = '';
            $url = $enlace . "?Entidades=Listado";
            $reporte = ListR2('', $sql, $ConexionEmpresa, $clase, '', $url, $enlaceCod, $panel, 'ct_empresasuscripcion', '', '');
            $s = "<div class= 'PanelPadding'>" . $btn . $reporte . "</div>";
            WE($s);
    }
}