예제 #1
0
 function get_ua()
 {
     $sql = "select sigla,descripcion from unidad_acad ";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     $resul = toba::db('designa')->consultar($sql);
     return $resul;
 }
예제 #2
0
 function programa_defecto()
 {
     $sql = "select m_p.id_programa from mocovi_programa m_p ,mocovi_tipo_programa m_t, unidad_acad t_u where m_p.id_tipo_programa=m_t.id_tipo_programa and m_t.id_tipo_programa=1 and m_p.id_unidad=t_u.sigla";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     $resul = toba::db('designa')->consultar($sql);
     return $resul[0]['id_programa'];
 }
예제 #3
0
 function get_materias()
 {
     $sql = "select id_materia,cod_carrera||'('||ordenanza||')'||desc_materia||'('||cod_siu||')' as descripcion from materia t_m, plan_estudio t_p, unidad_acad t_u" . " where t_m.id_plan=t_p.id_plan " . " and t_p.uni_acad=t_u.sigla";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     $sql = $sql . " order by descripcion";
     return toba::db('designa')->consultar($sql);
 }
예제 #4
0
 function generar_layout()
 {
     foreach ($this->sql as $id => $sql) {
         $sql2 = toba::perfil_de_datos()->filtrar($sql);
         echo "<hr><h1>" . ($id + 1) . "</h1>";
         $datos = toba::db()->consultar($sql);
         $tit1 = "<pre>" . $sql . "</pre>";
         $this->tabla($datos, $tit1);
         echo "<hr>";
         $datos = toba::db()->consultar($sql2);
         $tit2 = "<pre>" . $sql2 . "</pre>";
         $this->tabla($datos, $tit2);
     }
     echo "<hr>";
     echo "<hr>";
     echo "<hr>";
     foreach ($this->sql2 as $id => $sql) {
         $sql2 = toba::perfil_de_datos()->filtrar($sql, 'referencia');
         echo "<hr><h1>" . ($id + 1) . "</h1>";
         $datos = toba::db('referencia')->consultar($sql);
         $tit1 = "<pre>" . $sql . "</pre>";
         $this->tabla($datos, $tit1);
         echo "<hr>";
         $datos = toba::db('referencia')->consultar($sql2);
         $tit2 = "<pre>" . $sql2 . "</pre>";
         $this->tabla($datos, $tit2);
     }
 }
예제 #5
0
 function ini()
 {
     $fuente = toba::proyecto()->get_parametro('fuente_datos');
     ei_arbol(toba::perfil_de_datos()->get_id(), 'get_id');
     ei_arbol(toba::perfil_de_datos()->posee_restricciones($fuente), 'posee_restricciones');
     ei_arbol(toba::perfil_de_datos()->get_restricciones($fuente), 'get_restricciones');
     ei_arbol(toba::perfil_de_datos()->get_lista_dimensiones_restringidas($fuente), 'get_lista_dimensiones_restringidas');
     ei_arbol(toba::perfil_de_datos()->get_gatillos_activos($fuente), 'get_gatillos_activos');
 }
예제 #6
0
 function get_listado($where = null)
 {
     if (!is_null($where)) {
         $where = ' and ' . $where;
     } else {
         $where = '';
     }
     $sql = "SELECT\n\t\t\tt_t.id_tutoria,\n\t\t\tt_t.descripcion,\n\t\t\tt_ua.descripcion as uni_acad_nombre\n\t\tFROM\n\t\t\ttutoria as t_t, unidad_acad as t_ua\n                WHERE  t_t.uni_acad = t_ua.sigla\n\t\t";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     return toba::db('designa')->consultar($sql);
 }
예제 #7
0
 function get_categorizaciones($where = null)
 {
     if (!is_null($where)) {
         $where = ' WHERE ' . $where;
     } else {
         $where = '';
     }
     $sql = "select * from (select distinct a.*,t_de.uni_acad from " . "(select t_do.id_docente,t_do.apellido,t_do.nombre,t_do.legajo,t_c.anio_categ,t_c.id_cat,t_ci.descripcion as categoria" . " from categorizacion t_c" . " LEFT OUTER JOIN docente t_do ON (t_c.id_docente=t_do.id_docente)" . " LEFT OUTER JOIN categoria_invest t_ci ON (t_c.id_cat=t_ci.cod_cati)" . ")a" . " LEFT OUTER JOIN designacion t_de ON (a.id_docente=t_de.id_docente)" . $where . ")b, unidad_acad c" . " where b.uni_acad=c.sigla" . " order by id_docente,anio_categ";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     return toba::db('designa')->consultar($sql);
 }
 function get_designaciones()
 {
     if ($this->s__anio != null) {
         $pdia = $this->dep('datos')->tabla('mocovi_periodo_presupuestario')->primer_dia_periodo_anio($this->s__anio);
         $udia = $this->dep('datos')->tabla('mocovi_periodo_presupuestario')->ultimo_dia_periodo_anio($this->s__anio);
         $sql = "select distinct t_d.id_designacion,case when t_d.id_norma is null then (t_d1.apellido||', '||t_d1.nombre||'('||'id:'||t_d.id_designacion||'-'||t_d.cat_mapuche||')') else t_d1.apellido||', '||t_d1.nombre||'('||'id:'||t_d.id_designacion||'-'||t_d.cat_mapuche||'-'||t_no.nro_norma||'/'|| extract(year from t_no.fecha)||')' end as descripcion " . " from designacion t_d LEFT OUTER JOIN norma t_no ON (t_d.id_norma=t_no.id_norma), docente t_d1, unidad_acad t_u" . " where t_d.id_docente=t_d1.id_docente " . " and t_d.uni_acad=t_u.sigla " . "and t_d.desde<'" . $udia . "' and (t_d.hasta>'" . $pdia . "' or t_d.hasta is null)" . " order by descripcion";
         $sql = toba::perfil_de_datos()->filtrar($sql);
         //aplico el perfil de datos
         return toba::db('designa')->consultar($sql);
     }
 }
 function get_designaciones()
 {
     if ($this->s__anio != null) {
         $pdia = $this->dep('datos')->tabla('mocovi_periodo_presupuestario')->primer_dia_periodo_anio($this->s__anio);
         $udia = $this->dep('datos')->tabla('mocovi_periodo_presupuestario')->ultimo_dia_periodo_anio($this->s__anio);
         $sql = "select distinct t_d.id_designacion,t_d1.apellido||', '||t_d1.nombre||'('||'id:'||t_d.id_designacion||'-'||t_d.cat_mapuche||')' as descripcion" . " from designacion t_d, docente t_d1, unidad_acad t_u" . " where t_d.id_docente=t_d1.id_docente " . " and t_d.uni_acad=t_u.sigla " . "and t_d.desde<='" . $udia . "' and (t_d.hasta>='" . $pdia . "' or t_d.hasta is null)" . " order by descripcion";
         $sql = toba::perfil_de_datos()->filtrar($sql);
         //aplico el perfil de datos
         return toba::db('designa')->consultar($sql);
     }
 }
예제 #10
0
 function get_listado($where = null)
 {
     if (!is_null($where)) {
         $where = ' and ' . $where;
     } else {
         $where = '';
     }
     $sql = "select * from (SELECT t_ci.id_docente,t_ci.id_proyecto,t_ci.anio,t_do.apellido,t_do.apellido||', '||t_do.nombre as nombre_docente,t_ci.fecha,t_ci.monto,t_ci.cuota, t_i.denominacion as nombre_proyecto, t_i.uni_acad \n                        FROM cobro_incentivo as t_ci \n                        LEFT OUTER JOIN docente t_do ON (t_ci.id_docente=t_do.id_docente) \n                        LEFT OUTER JOIN pinvestigacion t_i ON (t_i.id_pinv=t_ci.id_proyecto))a, unidad_acad b\n                 where a.uni_acad=b.sigla\n                        ";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     $sql = $sql . $where;
     return toba::db('designa')->consultar($sql);
 }
예제 #11
0
파일: consultas.php 프로젝트: emma5021/toba
 /**
 	Retorna la lista de personas
 */
 static function get_personas($filtro = null)
 {
     $where = '';
     if (isset($filtro)) {
         if (isset($filtro['nombre'])) {
             $nombre = quote("%{$filtro['nombre']}%");
             $where = " WHERE nombre ILIKE {$nombre}";
         }
     }
     $sql = "SELECT id, nombre, fecha_nac FROM ref_persona {$where} ORDER BY nombre";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     return consultar_fuente($sql);
 }
예제 #12
0
 function get_departamentos($id_ua = null)
 {
     $where = "";
     if (isset($id_ua)) {
         $where = " and idunidad_academica='" . $id_ua . "'";
     }
     $sql = "SELECT distinct t_d.iddepto, t_d.descripcion " . " FROM departamento t_d," . " unidad_acad t_u " . " WHERE t_u.sigla=t_d.idunidad_academica" . "  {$where}" . " order by descripcion";
     //obtengo el perfil de datos del usuario logueado
     $con = "select sigla,descripcion from unidad_acad ";
     $con = toba::perfil_de_datos()->filtrar($con);
     $resul = toba::db('designa')->consultar($con);
     if (trim($resul[0]['sigla']) != 'CRUB' && trim($resul[0]['sigla']) != 'FACA' && trim($resul[0]['sigla']) != 'ASMA' && trim($resul[0]['sigla']) != 'CUZA' && trim($resul[0]['sigla']) != 'FAAS') {
         $sql = toba::perfil_de_datos()->filtrar($sql);
         //aplico el perfil para que solo aparezcan los departamentos de su facultad
     }
     $resul = toba::db('designa')->consultar($sql);
     return $resul;
 }
예제 #13
0
 function get_credito_ua($estado)
 {
     switch ($estado) {
         case 1:
             $where = ' and c.actual ';
             break;
         case 2:
             $where = ' and c.presupuestando ';
             break;
     }
     $sql = "select sum(b.credito) as cred " . " from mocovi_programa a, mocovi_credito b, mocovi_periodo_presupuestario c, unidad_acad d " . " where  a.id_programa=b.id_programa" . " and b.id_periodo=c.id_periodo " . " and a.id_unidad=d.sigla" . $where;
     $sql = toba::perfil_de_datos()->filtrar($sql);
     //aplico el perfil de datos
     $resul = toba::db('designa')->consultar($sql);
     if ($resul[0]['cred'] != null) {
         $credito = $resul[0]['cred'];
     } else {
         $credito = 0;
     }
     return $credito;
 }
예제 #14
0
 function generar_layout()
 {
     $fuente = toba::proyecto()->get_parametro('fuente_datos');
     echo "<pre>";
     foreach ($this->sql as $s) {
         echo "SQL: {$s}<br>";
         $tablas_gatillo = toba::perfil_de_datos()->buscar_tablas_gatillo_en_sql($s, $fuente);
         ei_arbol($tablas_gatillo, 'Gatillos encontrados');
         $dimensiones = toba::perfil_de_datos()->reconocer_dimensiones_implicadas(array_keys($tablas_gatillo), $fuente);
         ei_arbol($dimensiones, 'Dimensiones implicadas');
         $where = array();
         foreach ($dimensiones as $dimension => $tabla) {
             //-- 2 -- Obtengo la porcion de WHERE perteneciente a cada gatillo
             $alias_tabla = $tablas_gatillo[$tabla];
             $where[] = toba::perfil_de_datos()->get_where_dimension_gatillo($fuente, $dimension, $tabla, $alias_tabla);
         }
         ei_arbol($where, 'WHERE dim: ');
         echo "<br>";
     }
     echo "</pre>";
 }
예제 #15
0
 function get_listado_perfil($where = null)
 {
     if (!is_null($where)) {
         $where1 = ' WHERE ' . $where;
         $where2 = ' and ' . $where;
     } else {
         $where1 = '';
         $where2 = '';
     }
     //obtengo el perfil de datos del usuario logueado
     $con = "select sigla,descripcion from unidad_acad ";
     $con = toba::perfil_de_datos()->filtrar($con);
     $resul = toba::db('designa')->consultar($con);
     $salida = array();
     if ($resul[0]['sigla'] != null) {
         $sql = "select distinct n.id_norma,nro_norma,tipo_norma,emite_norma,fecha,b.quien_emite_norma,c.nombre_tipo,uni_acad " . " from norma n " . "INNER JOIN tipo_emite b ON (n.emite_norma=b.cod_emite)\n                       INNER JOIN tipo_norma_exp c ON (n.tipo_norma=c.cod_tipo)" . " INNER JOIN designacion d ON (n.id_norma=d.id_norma and d.uni_acad='" . trim($resul[0]['sigla']) . "')" . $where1 . " UNION " . "select distinct n.id_norma,nro_norma,tipo_norma,emite_norma,fecha,b.quien_emite_norma,c.nombre_tipo,uni_acad " . " from norma n " . " INNER JOIN tipo_emite b ON (n.emite_norma=b.cod_emite)\n                        INNER JOIN tipo_norma_exp c ON (n.tipo_norma=c.cod_tipo)" . " INNER JOIN designacion d ON (n.id_norma=d.id_norma_cs and d.uni_acad='" . trim($resul[0]['sigla']) . "')" . $where1;
         //agrego todas las normas que no estan asociadas a ninguna designacion
         $sql .= " UNION\n                    select distinct n.id_norma,nro_norma,tipo_norma,emite_norma,fecha,b.quien_emite_norma,c.nombre_tipo,''\n                    from norma n\n                    INNER JOIN tipo_emite b ON (n.emite_norma=b.cod_emite)\n                    INNER JOIN tipo_norma_exp c ON (n.tipo_norma=c.cod_tipo)\n                    where  not exists (select * from designacion b\n                                      where n.id_norma=b.id_norma)\n                          and not exists (select * from designacion c\n                                      where n.id_norma=c.id_norma_cs)      \n                    {$where2}\n                    ";
         $salida = toba::db('designa')->consultar($sql);
     }
     return $salida;
 }
예제 #16
0
 function es_externa($id_mat)
 {
     $sql = "select * from materia t_m, plan_estudio t_p, unidad_acad t_u " . "where t_m.id_plan=t_p.id_plan " . " and t_p.uni_acad=t_u.sigla ";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     $resul = toba::db('designa')->consultar($sql);
     $esta = false;
     $i = 0;
     $long = count($resul);
     while (!$esta && $i < $long) {
         if ($resul[$i]['id_materia'] == $id_mat) {
             $esta = true;
         } else {
             $i++;
         }
     }
     if ($esta) {
         //no es externa
         return false;
     } else {
         //es externa
         return true;
     }
 }
예제 #17
0
 function get_articulo73()
 {
     $sql = "select sigla,descripcion from unidad_acad ";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     $perfil = toba::db('designa')->consultar($sql);
     if (count($perfil) > 0) {
         $ua = $perfil[0]['sigla'];
         //veo cuales son los docentes son interinos vigentes de esta facultad
         $sql = " SELECT distinct a.legajo" . " from docente a, designacion b" . " where a.id_docente=b.id_docente" . " and b.desde <= '2016-09-30' and (b.hasta >= '2016-06-01' or b.hasta is null)\r\n                        and ((b.carac='I' and b.cat_estat<>'AYS' and b.cat_estat<>'PTR' and b.cat_estat<>'PAS') or (b.carac='R' and b.cat_estat='ASDEnc' ))\r\n                        and b.uni_acad='" . $ua . "'";
         $legajos = toba::db('designa')->consultar($sql);
         if (count($legajos) > 0) {
             //si hay docentes
             $doc = array();
             foreach ($legajos as $value) {
                 $leg[] = $value['legajo'];
             }
             $conjunto = implode(",", $leg);
             //recupero de mapuche la antiguedad de los legajos que van como argumento
             $datos_mapuche = consultas_mapuche::get_antiguedad_docente($conjunto);
             if (count($datos_mapuche) > 0) {
                 $sql = " CREATE LOCAL TEMP TABLE auxi(\r\n                        nro_legaj integer,\r\n                        antiguedad integer\r\n                    );";
                 toba::db('designa')->consultar($sql);
                 //creo la tabla auxi
                 foreach ($datos_mapuche as $valor) {
                     $sql = " insert into auxi values (" . $valor['nro_legaj'] . "," . $valor['antig'] . ")";
                     toba::db('designa')->consultar($sql);
                 }
                 $sql = "SELECT a.*,b.antiguedad from (" . " SELECT distinct a.legajo,b.id_designacion,a.apellido||', '||a.nombre||'('||b.cat_estat||b.dedic||'-'||b.id_designacion||')' as descripcion " . " from docente a, designacion b,mocovi_costo_categoria c, imputacion d, mocovi_programa e" . " where a.id_docente=b.id_docente" . " and b.desde <= '2016-09-30' and (b.hasta >= '2016-06-01' or b.hasta is null)\r\n                        and (b.carac='I' and (b.cat_estat<>'AYS' and b.cat_estat<>'PTR' and b.cat_estat<>'PAS')\r\n                           or\r\n                           (b.carac='R' and b.cat_estat='ASDEnc')\r\n                           )\r\n                        \r\n                        and c.codigo_siu=b.cat_mapuche\r\n                        and c.id_periodo=2--periodo 2016\r\n                        and c.costo_diario<=751.13\r\n                        and b.uni_acad='" . $ua . "'" . " and b.id_designacion=d.id_designacion" . " and e.id_programa=d.id_programa" . " and e.id_tipo_programa=1 " . ") a INNER JOIN auxi b " . " ON (a.legajo=b.nro_legaj)" . " order by descripcion";
                 //and c.id_periodo=2--periodo 2016
                 //c.costo_diario<=751,12 --costo de PAD1=ADJE
                 $res = toba::db('designa')->consultar($sql);
                 return $res;
             }
         }
     }
 }
예제 #18
0
 function puede_cargar_categorizacion($id_docente)
 {
     $sql = "select * from (select * from docente t_doc,designacion t_de" . " where t_doc.id_docente={$id_docente} and t_doc.id_docente=t_de.id_docente" . ")a, unidad_acad b where a.uni_acad=b.sigla";
     $sql = toba::perfil_de_datos()->filtrar($sql);
     $res = toba::db('designa')->consultar($sql);
     if (count($res) > 0) {
         $respuesta = true;
     } else {
         $respuesta = false;
     }
     return $respuesta;
 }
예제 #19
0
 function get_programas($es_prog = null)
 {
     if ($es_prog == 'NO') {
         //trae todos los programas de la unidad academica que se logueo
         //obtengo el perfil de datos del usuario logueado
         $con = "select sigla,descripcion from unidad_acad ";
         $con = toba::perfil_de_datos()->filtrar($con);
         $resul = toba::db('designa')->consultar($con);
         //le agrego al desplegable la opcion 0 sin programa
         $sql = "select 0 as id_pinv,'SIN/PROGRAMA' as denominacion UNION select id_pinv,denominacion from pinvestigacion where es_programa=1 and uni_acad='" . trim($resul[0]['sigla']) . "'";
         $res = toba::db('designa')->consultar($sql);
         return toba::db('designa')->consultar($sql);
     } else {
         //si es un programa entonces no muestra nada en este combo
         $res = array();
         $ar['id_pinv'] = 0;
         $ar['denominacion'] = 'SIN/PROGRAMA';
         $res[] = $ar;
         return $res;
     }
 }
 function alcanza_credito_modif($id_vieja, $desde, $hasta, $cat, $per)
 {
     $sql_ua = "select sigla,descripcion from unidad_acad ";
     $sql_ua = toba::perfil_de_datos()->filtrar($sql_ua);
     $resul = toba::db('designa')->consultar($sql_ua);
     if (count($resul > 0)) {
         //el usuario esta asociado a un perfil de datos
         $ua = $resul[0]['sigla'];
         //1 periodo actual
         //2 periodo presupuestando
         //obtengo inicio y fin del periodo
         $udia = $this->ultimo_dia_periodo($per);
         $pdia = $this->primer_dia_periodo($per);
         $anio = $this->annio($per);
         switch ($per) {
             case 1:
                 //obtengo el costo diario de la categoria en el periodo actual
                 $concat = " m_e.actual ";
                 $where = "and  actual=true";
                 break;
             case 2:
                 $concat = " m_e.presupuestando ";
                 $where = "and  presupuestando=true";
                 break;
         }
         //--COSTO DE LA NUEVA DESIGNACION en el periodo actual o el periodo presupuestario
         $sql = "select * " . "from mocovi_costo_categoria m_c," . "mocovi_periodo_presupuestario m_e " . "where m_c.id_periodo=m_e.id_periodo " . "and m_c.codigo_siu='" . trim($cat) . "'" . $where;
         $costo = toba::db('designa')->consultar($sql);
         if (count($costo) > 0) {
             $valor_categoria = $costo[0]['costo_diario'];
         } else {
             $valor_categoria = 0;
         }
         //----------dias trabajados dentro del periodo
         $dias = 0;
         if ($desde > $udia || $hasta != null && $hasta < $pdia) {
             //cae fuera del periodo
             $dias = 0;
         } else {
             if ($desde <= $pdia) {
                 //$hasta-$pdia
                 if ($hasta == null || $hasta >= $udia) {
                     $dias = $this->dias_transcurridos($pdia, $udia) + 1;
                 } else {
                     $dias = $this->dias_transcurridos($pdia, $hasta) + 1;
                 }
             } else {
                 if ($hasta >= $udia || $hasta == null) {
                     //$udia-$desde
                     $dias = $this->dias_transcurridos($desde, $udia) + 1;
                 } else {
                     //$hasta-$desde
                     $dias = $this->dias_transcurridos($desde, $hasta) + 1;
                 }
             }
         }
         $cuesta_nuevo = $dias * $valor_categoria;
         //-----------CALCULO LO QUE GASTE sin considerar la designacion vieja
         //busco las designaciones y reservas dentro del periodo que son de la UA
         //designaciones sin licencia UNION designaciones c/licencia sin norma UNION designaciones c/licencia c norma UNION reservas
         //            $sql = "(SELECT distinct t_d.id_designacion,t_d.desde,t_d.hasta,t_d.uni_acad,"
         //                    . "m_c.costo_diario,"
         //                    . "t_t.porc,"
         //                    . "0 as dias_lic,"
         //                    . " case when t_d.desde<='".$pdia."' then ( case when (t_d.hasta>='".$udia."' or t_d.hasta is null ) then (((cast('".$udia."' as date)-cast('".$pdia."' as date))+1)) else ((t_d.hasta-'".$pdia."')+1) end ) else (case when (t_d.hasta>='".$udia."' or t_d.hasta is null) then ((('".$udia."')-t_d.desde+1)) else ((t_d.hasta-t_d.desde+1)) end ) end as dias_des
         //                            FROM
         //                            designacion as t_d LEFT OUTER JOIN categ_siu as t_cs ON (t_d.cat_mapuche = t_cs.codigo_siu)
         //                            LEFT OUTER JOIN imputacion as t_t ON (t_d.id_designacion = t_t.id_designacion)
         //                            LEFT OUTER JOIN mocovi_programa as m_p ON (t_t.id_programa = m_p.id_programa)
         //                            LEFT OUTER JOIN mocovi_periodo_presupuestario m_e ON ( ".$concat.")
         //                            LEFT OUTER JOIN mocovi_costo_categoria as m_c ON (t_d.cat_mapuche = m_c.codigo_siu and m_c.id_periodo=m_e.id_periodo)
         //
         //                        WHERE  t_d.tipo_desig=1
         //                            AND not exists(SELECT * from novedad t_no
         //                                            where t_no.id_designacion=t_d.id_designacion
         //                                            and (t_no.tipo_nov=1 or t_no.tipo_nov=2 or t_no.tipo_nov=4 or t_no.tipo_nov=5)))"
         //
         //                        ."UNION
         //                        (SELECT distinct t_d.id_designacion,t_d.desde,t_d.hasta,t_d.uni_acad,
         //                        m_c.costo_diario,
         //                        t_t.porc,
         //                        0 as dias_lic,
         //                        case when t_d.desde<='".$pdia."' then ( case when (t_d.hasta>='".$udia."' or t_d.hasta is null ) then (((cast('".$udia."' as date)-cast('".$pdia."' as date))+1)) else ((t_d.hasta-'".$pdia."')+1) end ) else (case when (t_d.hasta>='".$udia."' or t_d.hasta is null) then ((('".$udia."')-t_d.desde+1)) else ((t_d.hasta-t_d.desde+1)) end ) end as dias_des
         //
         //                            FROM designacion as t_d LEFT OUTER JOIN categ_siu as t_cs ON (t_d.cat_mapuche = t_cs.codigo_siu)
         //
         //                            LEFT OUTER JOIN imputacion as t_t ON (t_d.id_designacion = t_t.id_designacion)
         //                            LEFT OUTER JOIN mocovi_programa as m_p ON (t_t.id_programa = m_p.id_programa)
         //                            LEFT OUTER JOIN mocovi_periodo_presupuestario m_e ON ( ".$concat.")
         //                            LEFT OUTER JOIN mocovi_costo_categoria as m_c ON (t_d.cat_mapuche = m_c.codigo_siu and m_c.id_periodo=m_e.id_periodo),
         //
         //                            novedad as t_no
         //
         //                        WHERE  t_d.tipo_desig=1
         //                            AND t_no.id_designacion=t_d.id_designacion
         //                            AND (((t_no.tipo_nov=2 or t_no.tipo_nov=5) AND (t_no.tipo_norma is null or t_no.tipo_emite is null or t_no.norma_legal is null))
         //                                OR (t_no.tipo_nov=1 or t_no.tipo_nov=4))
         //                            )"
         //                        ."UNION
         //                        (SELECT distinct
         //                        t_d.id_designacion,t_d.desde,t_d.hasta,t_d.uni_acad,
         //                        m_c.costo_diario,
         //                        t_t.porc,"
         //                    . " sum(case when (t_no.desde>'".$udia."' or (t_no.hasta is not null and t_no.hasta<'".$pdia."')) then 0 else (case when t_no.desde<='".$pdia."' then ( case when (t_no.hasta is null or t_no.hasta>='".$udia."' ) then (((cast('".$udia."' as date)-cast('".$pdia."' as date))+1)) else ((t_no.hasta-'".$pdia."')+1) end ) else (case when (t_no.hasta is null or t_no.hasta>='".$udia."' ) then ((('".$udia."')-t_no.desde+1)) else ((t_no.hasta-t_no.desde+1)) end ) end )end ) as dias_lic,"
         //                    . " case when t_d.desde<='".$pdia."' then ( case when (t_d.hasta>='".$udia."' or t_d.hasta is null ) then (((cast('".$udia."' as date)-cast('".$pdia."' as date))+1)) else ((t_d.hasta-'".$pdia."')+1) end ) else (case when (t_d.hasta>='".$udia."' or t_d.hasta is null) then ((('".$udia."')-t_d.desde+1)) else ((t_d.hasta-t_d.desde+1)) end ) end as dias_des
         //                        FROM designacion as t_d
         //
         //                            LEFT OUTER JOIN imputacion as t_t ON (t_d.id_designacion = t_t.id_designacion)
         //                            LEFT OUTER JOIN mocovi_programa as m_p ON (t_t.id_programa = m_p.id_programa)
         //                            LEFT OUTER JOIN mocovi_periodo_presupuestario m_e ON ( ".$concat.")
         //                            LEFT OUTER JOIN mocovi_costo_categoria as m_c ON (t_d.cat_mapuche = m_c.codigo_siu and m_c.id_periodo=m_e.id_periodo),
         //                       	    novedad t_no
         //                        WHERE t_d.tipo_desig=1
         //                                AND t_no.id_designacion=t_d.id_designacion
         //                                AND (t_no.tipo_nov=2 or t_no.tipo_nov=5)
         //                                AND t_no.tipo_norma is not null
         //                                AND t_no.tipo_emite is not null
         //                                AND t_no.norma_legal is not null
         //                        GROUP BY t_d.id_designacion,t_d.desde,t_d.hasta,t_d.uni_acad,m_c.costo_diario,t_t.porc  )".
         //                    "UNION
         //                        (SELECT distinct t_d.id_designacion,t_d.desde,t_d.hasta, t_d.uni_acad,m_c.costo_diario, t_t.porc,0 as dias_lic,
         //                        case when t_d.desde<='".$pdia."' then ( case when (t_d.hasta>='".$udia."' or t_d.hasta is null ) then (((cast('".$udia."' as date)-cast('".$pdia."' as date))+1)) else ((t_d.hasta-'".$pdia."')+1) end ) else (case when (t_d.hasta>='".$udia."' or t_d.hasta is null) then ((('".$udia."')-t_d.desde+1)) else ((t_d.hasta-t_d.desde+1)) end ) end as dias_des
         //                        FROM designacion as t_d
         //                            LEFT OUTER JOIN imputacion t_i ON (t_d.id_designacion=t_i.id_designacion)
         //                            LEFT OUTER JOIN mocovi_programa m_p ON (t_i.id_programa=m_p.id_programa)
         //                            LEFT OUTER JOIN imputacion as t_t ON (t_d.id_designacion = t_t.id_designacion)
         //                            LEFT OUTER JOIN mocovi_periodo_presupuestario m_e ON ( ".$concat.")
         //                            LEFT OUTER JOIN mocovi_costo_categoria as m_c ON (t_d.cat_mapuche = m_c.codigo_siu and m_c.id_periodo=m_e.id_periodo),
         //                        reserva as t_r
         //                        WHERE t_d.id_reserva = t_r.id_reserva
         //                                 AND t_d.tipo_desig=2
         //                                )
         //                            ";
         $sql = dt_designacion::armar_consulta($pdia, $udia, $anio);
         $sql = "select * from (" . $sql . ")b WHERE b.id_designacion<>" . $id_vieja . " and b.uni_acad='" . $ua . "' and b.desde <='" . $udia . "'  and (b.hasta >='" . $pdia . "' or b.hasta is null)";
         //aqui queda
         //$con="select sum((dias_des-dias_lic)*costo_diario*porc/100)as monto from ("
         $con = "select sum(case when (dias_des-dias_lic)>=0 then (dias_des-dias_lic)*costo_diario*porc/100 else 0 end)as monto from (" . " select id_designacion,desde,hasta,uni_acad,costo_diario, id_programa,porc,dias_des,sum(dias_lic) as dias_lic from (" . $sql . ")a" . " group by id_designacion,desde,hasta,uni_acad,costo_diario, id_programa,porc,dias_des" . ")b";
         $res = toba::db('designa')->consultar($con);
         $gaste = $res[0]['monto'];
         //print_r($gaste);exit();
         //sumo los creditos (correspondientes al periodo actual/presupuestando) de todos los programas asociados a la UA
         $sql = "select sum(b.credito) as cred from mocovi_programa a, mocovi_credito b,mocovi_periodo_presupuestario d,unidad_acad c " . "where a.id_unidad=c.sigla and a.id_programa=b.id_programa" . " and b.id_periodo=d.id_periodo " . $where;
         $sql = toba::perfil_de_datos()->filtrar($sql);
         $resul = toba::db('designa')->consultar($sql);
         $tengo = 0;
         if (count($resul) > 0) {
             $tengo = $resul[0]['cred'];
         }
         //print_r($cuesta_nuevo);exit();
         //print_r('tengo:'.$tengo);exit();
         if ($gaste + $cuesta_nuevo > $tengo) {
             return false;
         } else {
             return true;
         }
     } else {
         //si el usuario no tiene perfil de datos asociado
         return false;
     }
 }
예제 #21
0
파일: ci_prueba.php 프로젝트: emma5021/toba
 function ejecutar_test()
 {
     toba::perfil_de_datos()->set_perfil(toba_editor::get_proyecto_cargado(), $this->s__detalle_test['perfil_datos']);
     $this->cabecera_prueba = toba::perfil_de_datos()->get_info($this->fuente);
     if (toba::perfil_de_datos()->posee_restricciones($this->fuente)) {
         $this->pruebas = toba::perfil_de_datos()->probar_sqls($this->fuente, $this->s__sqls_a_ejecutar, $this->s__detalle_test['datos_filas'], $this->s__detalle_test['datos_listar']);
         // Oculto la informacion que no se solicito
         foreach (array_keys($this->pruebas) as $id) {
             // Ocultar no procesados
             if (!$this->pruebas[$id]['modificado'] && $this->s__detalle_test['omitir_no_afectados']) {
                 unset($this->pruebas[$id]);
             }
             // Ocultar el SQL original
             if (!$this->s__detalle_test['sql_original']) {
                 unset($this->pruebas[$id]['sql_original']);
             }
             // Ocultar analisis de dimensiones
             if (!$this->s__detalle_test['info_dimensiones']) {
                 unset($this->pruebas[$id]['gatillos']);
                 unset($this->pruebas[$id]['dimensiones']);
             }
             // Ocultar el WHERE
             if (!$this->s__detalle_test['sql_where']) {
                 unset($this->pruebas[$id]['where']);
             }
             // Ocultar SQL modificado
             if (!$this->s__detalle_test['sql_modificado']) {
                 unset($this->pruebas[$id]['sql_modificado']);
             }
         }
     } else {
         toba::notificacion()->agregar('El perfil seleccionado no tiene restricciones aplicables');
     }
 }
예제 #22
0
파일: toba.php 프로젝트: emma5021/toba
 /**
  * El perfil de datos permite restringir los datos que surgen desde la base de datos en base a una dimensión dada
  * @return toba_perfil_datos
  */
 static function perfil_de_datos()
 {
     if (!isset(self::$perfil_de_datos)) {
         self::$perfil_de_datos = new toba_perfil_datos();
     }
     return self::$perfil_de_datos;
 }
예제 #23
0
 /**
  * @param array $where Clasulas que seran concatenadas con un AND
  * @param array $from Tablas extra que participan (la actual se incluye automaticamente)
  * @return string Consulta armada
  * @ignore 
  */
 protected function generar_sql_select($where = array(), $from = null, $columnas = null)
 {
     //Si no se explicitan las columnas, se asume que son todas
     if (!isset($columnas)) {
         $columnas = array();
         foreach ($this->_columnas as $col) {
             if (!$col['externa'] && $col['tipo'] != 'B') {
                 $columnas[] = $this->get_select_col($col['columna']);
             }
         }
     }
     //Si no se explicitan los from se asume que es la tabla local
     if (!isset($from)) {
         $from = array($this->get_from_default());
     }
     $sql = "SELECT\n\t" . implode(", \n\t", $columnas);
     $sql .= "\nFROM\n\t" . implode(", ", $from);
     if (!empty($where)) {
         $sql .= "\nWHERE";
         foreach ($where as $clausula) {
             $sql .= "\n\t{$clausula} AND";
         }
         $sql = substr($sql, 0, -4);
         //Se saca el ultimo AND
     }
     if ($this->_usar_perfil_de_datos) {
         //Si el datos_tabla maneja perfil de datos
         $sql = toba::perfil_de_datos()->filtrar($sql);
     }
     //Se guardan los datos de la carga
     $this->_sql_carga = array('from' => $from, 'where' => $where);
     return $sql;
 }
예제 #24
0
 function get_permutas_externas($where = null)
 {
     if (!is_null($where)) {
         $where = ' where ' . $where;
     } else {
         $where = '';
     }
     $x = toba::usuario()->get_id();
     $z = toba::usuario()->get_perfil_datos($x);
     //si el usuario esta asociado a un perfil de datos
     if (isset($z)) {
         //si una variable está definida y no es NULL
         $sql = "select sigla,descripcion from unidad_acad ";
         $sql = toba::perfil_de_datos()->filtrar($sql);
         $resul = toba::db('designa')->consultar($sql);
         $sql = "select * from(" . "select t_d.id_designacion,t_a.anio,t_do.apellido||', '||t_do.nombre as docente_nombre,t_do.legajo,t_d.cat_mapuche,t_d.cat_estat||'-'||t_d.dedic as cat_estat,t_d.carac,t_d.desde,t_d.hasta,t_de.descripcion as departamento,t_ar.descripcion as area,t_o.descripcion as orientacion,\n                        t_e.uni_acad as uni_acad,t_d.uni_acad as ua, t_m.desc_materia,t_m.cod_siu,t_e.cod_carrera,t_e.ordenanza,t_mo.descripcion as modulo\n                        from designacion t_d \n                        LEFT OUTER JOIN departamento t_de ON (t_d.id_departamento=t_de.iddepto)\n                        LEFT OUTER JOIN area t_ar ON (t_d.id_area=t_ar.idarea)\n                        LEFT OUTER JOIN orientacion t_o ON (t_d.id_orientacion=t_o.idorient and t_ar.idarea=t_o.idarea),\n                        asignacion_materia t_a,  materia t_m, plan_estudio t_e, docente t_do, modulo t_mo\n                        where t_a.id_designacion=t_d.id_designacion\n                        and t_a.id_materia=t_m.id_materia\n                        and t_m.id_plan=t_e.id_plan\n                        and t_d.id_docente=t_do.id_docente\n                        and t_a.modulo=t_mo.id_modulo\n                        and t_e.uni_acad<>t_d.uni_acad\n                        and t_d.uni_acad<>'" . $resul[0]['sigla'] . "'" . " and t_e.uni_acad='" . $resul[0]['sigla'] . "'" . ")b {$where}" . " order by docente_nombre";
     } else {
         //el usuario no esta asociado a ningun perfil de datos
         $sql = "select * from(" . " select t_d.id_designacion,t_a.anio,t_do.apellido||', '||t_do.nombre as docente_nombre,t_do.legajo,t_d.cat_mapuche,t_d.cat_estat||'-'||t_d.dedic as cat_estat,t_d.carac,t_d.desde,t_d.hasta,t_de.descripcion as departamento,t_ar.descripcion as area,t_o.descripcion as orientacion,\n                        t_e.uni_acad as uni_acad,t_d.uni_acad as ua, t_m.desc_materia,t_m.cod_siu,t_e.cod_carrera,t_e.ordenanza,t_mo.descripcion as modulo\n                        from designacion t_d \n                        LEFT OUTER JOIN departamento t_de ON (t_d.id_departamento=t_de.iddepto)\n                        LEFT OUTER JOIN area t_ar ON (t_d.id_area=t_ar.idarea)\n                        LEFT OUTER JOIN orientacion t_o ON (t_d.id_orientacion=t_o.idorient and t_ar.idarea=t_o.idarea),\n                        asignacion_materia t_a,  materia t_m, plan_estudio t_e, docente t_do, modulo t_mo\n                        where t_a.id_designacion=t_d.id_designacion\n                        and t_a.id_materia=t_m.id_materia\n                        and t_m.id_plan=t_e.id_plan\n                        and t_d.id_docente=t_do.id_docente\n                        and t_a.modulo=t_mo.id_modulo\n                        and t_e.uni_acad<>t_d.uni_acad\n                        )b {$where}";
     }
     return toba::db('designa')->consultar($sql);
 }