function buscarTiposDeContrato()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina solicitada
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $buscar = "WHERE (DESCRIPCION LIKE '%" . $_GET['q'] . "%') ";
     } else {
         $buscar = "";
     }
     $sql = "\n\t\t\tSELECT *\n\t\t\tFROM ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n\t\t\t          FROM  TIPOS_CONTRATO {$buscar}\n\t\t\t      ) AS RowConstrainedResult\n\t\t\tWHERE RowNum > {$offset} AND RowNum <= {$limit}\n\t\t\tORDER BY {$order}\n\t\t\t";
     try {
         $this->rows = database::getRows($sql);
         $total = database::getNumRows($sql);
         $this->totalnum = $total;
     } catch (customException $e) {
         throw new customException($sql);
     }
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#2
0
 function buscarArchivos()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     } else {
         $order = "FECHA_R DESC ";
     }
     if (isset($_GET['filter'])) {
         $filter = "'" . str_replace(";", "','", $_GET['filter']) . "'";
         $categorias = "WHERE TIPO IN( {$filter} ) ";
     } else {
         $categorias = "";
     }
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY FECHA_R ) AS RowNum, *\n          FROM  APOYOS\n           {$categorias} \n        ) AS RowConstrainedResult\nWHERE   RowNum >= {$offset}\n    AND RowNum <= {$limit}\nORDER BY {$order}";
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= "AND (TITULO LIKE '%" . $_GET['q'] . "%') ";
     }
     $this->archivos = database::getRows($sql);
     $this->totalnum = database::getNumRows($sql);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#3
0
 function buscarPermisos()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     $tamaño = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "PERMISO ";
                 break;
         }
     }
     $tipo = $_GET['Tipo'];
     $sql = "SELECT * \n                FROM (select PK1, PERMISO, DESCRIPCION, FECHA_R,TIPO, row_number() \n                OVER (order by  {$order}) AS \n                RowNumber FROM PERMISOS WHERE TIPO = '{$tipo}') \n                Derived WHERE RowNumber BETWEEN '{$offset}' AND '{$limit}' ";
     //echo $sql;
     $sqlcount = "SELECT PK1, PERMISO, DESCRIPCION,FECHA_R \n                     FROM PERMISOS WHERE TIPO = '{$tipo}'";
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= "AND (PERMISO LIKE '%" . $_GET['q'] . "%') ";
     }
     $this->permisos = database::getRows($sql);
     $this->totalnum = database::getNumRows($sqlcount);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $tamaño);
 }
示例#4
0
 function buscarRoles()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     if (isset($_GET['filter'])) {
         $filter = "'" . str_replace(";", "','", $_GET['filter']) . "'";
     } else {
         $nivel = $_SESSION['session']['nodo'];
         $filter = "'{$nivel}' ";
     }
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n          FROM      ROLES\n         \n        ) AS RowConstrainedResult\nWHERE   RowNum > {$offset}\n    AND RowNum <= {$limit} \nORDER BY {$order}";
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= "AND (ROLE LIKE '%" . $_GET['q'] . "%') ";
     }
     $this->roles = database::getRows($sql);
     $this->totalnum = database::getNumRows($sql);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#5
0
 function buscarUsuarios()
 {
     $this->usuarios = array();
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     $plan = $_GET['IDPlan'];
     $sql = "WITH CTE AS\n(\n  SELECT  A.PK1 AS ID,U.IMAGEN,U.PK1,U.NOMBRE,U.APELLIDOS,U.EMAIL,U.PK_JERARQUIA,U.DISPONIBLE,A.PK_USUARIO,A.PK_POPERATIVO,A.ROL, \n     ROW_NUMBER() OVER ( ORDER BY U.FECHA_R ) AS RowNum\n  FROM PL_POPERATIVOS_ASIGNACIONES A, USUARIOS U\n  WHERE   U.PK1 = A.PK_USUARIO AND A.PK_POPERATIVO = '{$plan}' \n)\nSELECT * FROM CTE \nWHERE RowNum >= {$offset} AND RowNum < {$limit}";
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= "AND (NOMBRE LIKE '%" . $_GET['q'] . "%') ";
     }
     //echo $sql;
     $result = database::executeQuery($sql);
     $total = database::getNumRows($sql);
     $this->totalnum = $total;
     while ($row = mssql_fetch_array($result, MSSQL_ASSOC)) {
         $this->usuarios[] = $row;
     }
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($total / $limit);
 }
 function buscarUsuarios($idCentro)
 {
     $this->usuarios = array();
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     //$plan = $_GET['IDPlan'];
     $sql = "\n\t\t\tWITH RESPONSABLES AS\n\t\t\t(\n\t\t\t\tSELECT R.PK1 AS ID ,U.IMAGEN,U.PK1,U.NOMBRE,U.APELLIDOS,U.EMAIL,U.PK_JERARQUIA,U.DISPONIBLE\n\t\t\t\t,R.PK_USUARIO, R.ROL\n\t\t\t\t,ROW_NUMBER() OVER ( ORDER BY U.FECHA_R ) AS RowNum\n\t\t\t\tFROM RESPONSABLES_CENTRO R, USUARIOS U\n\t\t\t\tWHERE U.PK1 = R.PK_USUARIO AND R.CENTRO='{$idCentro}'\n\t\t\t)\n\t\t\tSELECT * FROM RESPONSABLES\n\t\t\tWHERE RowNum >= {$offset} AND RowNum < {$limit}\n\t\t";
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= " AND (NOMBRE LIKE '%" . $_GET['q'] . "%') ";
     }
     //echo "[  ".$sql." ]";
     $this->usuarios = database::getRows($sql);
     //	$sql2 = " SELECT * FROM USUARIOS ";
     $this->totalnum = database::getNumRows($sql);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
     //*/
 }
示例#7
0
 function buscarLineas()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = " PK1 DESC ";
                 break;
         }
     }
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $buscar = "WHERE (DESCRIPCION LIKE '%" . $_GET['q'] . "%') ";
     } else {
         $buscar = "";
     }
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n          FROM      LINEAS_INV {$buscar}\n          \n         \n        ) AS RowConstrainedResult\nWHERE   RowNum > {$offset}\n    AND RowNum <= {$limit} \nORDER BY {$order}";
     try {
         //echo $sql;
         $this->lineas = database::getRows($sql);
         $total = database::getNumRows($sql);
         $this->totalnum = $total;
     } catch (customException $e) {
         throw new customException($sql);
     }
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#8
0
 function GuardarPeriodosSeguimiento()
 {
     $fecha = date("Y-m-d H:i:s");
     $usuario = $_SESSION['session']['user'];
     $plano = $this->idplan;
     $sql = "SELECT * FROM PL_POPERATIVOS_PERIODOS WHERE PK_POPERATIVO = '{$plano}'";
     $numperiodosbase = database::getNumRows($sql);
     $numperiodos = sizeof($this->seguimiento) - 1;
     if ($numperiodosbase > $numperiodos) {
         for ($i = $numperiodos; $i <= $numperiodosbase; $i++) {
             $sql = "DELETE FROM PL_POPERATIVOS_PERIODOS WHERE PK_POPERATIVO = '{$plano}' AND ORDEN='{$i}'";
             database::executeQuery($sql);
         }
     }
     $cont = 1;
     for ($i = 0; $i < sizeof($this->seguimiento) - 1; $i++) {
         $periodo = explode("^", $this->seguimiento[$i]);
         $titulo = $periodo[0];
         $fechai = $periodo[1];
         $fechat = $periodo[2];
         $sql = "SELECT * FROM PL_POPERATIVOS_PERIODOS WHERE PK_POPERATIVO = '{$plano}' AND ORDEN = '{$cont}'";
         $row = database::getRow($sql);
         if ($row) {
             $this->campos = array('PERIODO' => $titulo, 'FECHA_I' => $fechai, 'FECHA_T' => $fechat, 'FECHA_M' => $fecha, 'PK_USUARIO' => $_SESSION['session']['user']);
             $condition = "PK_POPERATIVO = '{$plano}' AND ORDEN = '{$cont}'";
             database::updateRecords("PL_POPERATIVOS_PERIODOS", $this->campos, $condition);
         } else {
             $idperiodo = strtoupper(substr(uniqid('SP'), 0, 15));
             $this->campos = array('PK1' => $idperiodo, 'PERIODO' => $periodo[0], 'ORDEN' => $cont, 'FECHA_I' => $periodo[1], 'FECHA_T' => $periodo[2], 'PK_POPERATIVO' => $this->idplan, 'FECHA_R' => date("Y-m-d H:i:s"), 'FECHA_M' => NULL, 'PK_USUARIO' => $_SESSION['session']['user']);
             database::insertRecords("PL_POPERATIVOS_PERIODOS", $this->campos);
         }
         $cont++;
     }
 }
 function buscarUsuarios()
 {
     $this->usuarios = array();
     // maximo por pagina
     $limit = $_GET["s"];
     $tamaño = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "NOMBRE ASC ";
                 break;
         }
     }
     $sql = "SELECT * \n                FROM (select PK1, NOMBRE, APELLIDOS, IMAGEN,DISPONIBLE,PK_JERARQUIA, row_number() \n                OVER (order by  {$order}) AS \n                RowNumber FROM USUARIOS) \n                Derived WHERE RowNumber BETWEEN '{$offset}' AND '{$limit}'  ";
     //echo $sql;
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= "AND (NOMBRE LIKE '%" . $_GET['q'] . "%') ";
     }
     $result = database::executeQuery($sql);
     $sqlcount = "SELECT PK1\n                     FROM USUARIOS ";
     $total = database::getNumRows($sqlcount);
     $this->totalnum = $total;
     while ($row = mssql_fetch_array($result, MSSQL_ASSOC)) {
         $this->usuarios[] = $row;
     }
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($total / $tamaño);
 }
示例#10
0
 function buscarFichas()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     if (isset($_GET['filter'])) {
         $filter = "'" . str_replace(";", "','", $_GET['filter']) . "'";
     } else {
         $nivel = $_SESSION['session']['nodo'];
         $filter = "'{$nivel}' ";
     }
     $sql = "SELECT PK1, NOMBRE, DESCRIPCION, URL, PADRE ,ORDEN,DISPONIBLE,PK_PERMISO,FECHA_R \n                FROM (select PK1, NOMBRE, DESCRIPCION, URL, PADRE ,ORDEN,DISPONIBLE,PK_PERMISO,FECHA_R, row_number() \n                OVER (order by  {$order}) AS \n                RowNumber FROM FICHAS) \n                Derived WHERE RowNumber BETWEEN '{$offset}' AND '{$limit}' ";
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= "AND (NOMBRE LIKE '%" . $_GET['q'] . "%') ";
     }
     $this->fichas = database::getRows($sql);
     $this->totalnum = database::getNumRows($sql);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#11
0
 function initMenu($nivel = 0, $submenu = false, $idmenu = "", $idsubmenu = "")
 {
     $idmenu = isset($_GET['Menu']) ? $_GET['Menu'] : $idmenu;
     $idsubmenu = isset($_GET['SubMenu']) ? $_GET['SubMenu'] : $idsubmenu;
     $lista = '<ul';
     if (!$submenu) {
         $lista .= ' class="Menu">';
     } else {
         $lista .= ' class="subMenu">';
     }
     // Obtenemos los datos los dependientes del nivel solicitado
     $sql = sprintf("SELECT PK1, NOMBRE,URL, PADRE,PK_PERMISO FROM FICHAS WHERE PADRE = '{$nivel}' ORDER BY ORDEN");
     $rows = database::getRows($sql);
     // Para cada dependiente del nivel solicitado...
     foreach ($rows as $r) {
         // Abrimos el nodo con el nombre del primer dependiente
         $lista .= '<li';
         if (!$submenu) {
             //Agregamos las Fichas superiores del Menu
             //Validamos si tiene permiso
             if ($this->passport->privilegios->hasPrivilege($r['PK_PERMISO'])) {
                 //echo $r['NOMBRE'];
                 if ($idmenu == $r['PK1']) {
                     $lista .= ' id="active">' . htmlentities($r['NOMBRE'], ENT_QUOTES, "ISO-8859-1") . '';
                 } else {
                     $lista .= '><a href="' . $r['URL'] . '">' . htmlentities($r['NOMBRE'], ENT_QUOTES, "ISO-8859-1") . '</a>';
                 }
             }
         } else {
             if ($this->passport->privilegios->hasPrivilege($r['PK_PERMISO'])) {
                 if ($idsubmenu == $r['PK1']) {
                     $lista .= ' id="subActive">' . htmlentities($r['NOMBRE'], ENT_QUOTES, "ISO-8859-1");
                 } else {
                     $lista .= '><a href="' . $r['URL'] . '">' . htmlentities($r['NOMBRE'], ENT_QUOTES, "ISO-8859-1") . '</a>';
                 }
             }
         }
         // Utilizaremos esta variable para ver si seguimos consultado la BDD
         $tiene_dependientes = null;
         $id = $r['PK1'];
         $sql = sprintf("SELECT * FROM FICHAS WHERE PADRE = '{$id}'");
         $tiene_dependientes = database::getNumRows($sql);
         // Si tiene dependientes, ejecutamos recursivamente
         // tomando como parámetro el nuevo nivel
         if ($tiene_dependientes > 0) {
             if ($idmenu == $r['PK1']) {
                 $lista .= $this->initMenu($r['PK1'], TRUE, $idmenu, $idsubmenu);
             }
         }
         // Cerramos el nodo
         $lista .= '</li>';
     }
     // Cerramos la lista
     $lista .= '</ul>';
     return $lista;
 }
示例#12
0
 function hasPrivilege($perm)
 {
     $user = $_SESSION['session']['user'];
     $sql = "SELECT PK1 FROM ROLES_USUARIO WHERE PK_USUARIO = '{$user}' AND PK_ROLE = 'R00'";
     $row = database::getNumRows($sql);
     if ($row) {
         return TRUE;
     } else {
         foreach ($this->roles as $role) {
             if ($role->hasPerm($perm)) {
                 return true;
             }
         }
         return false;
     }
 }
示例#13
0
    function getAlertas()
    {
        $usuario = $_SESSION['session']['user'];
        $alertas = "";
        $sql = sprintf("SELECT * FROM NOTIFICACIONES WHERE TIPO = 'ALERT' AND PK_USUARIO = '{$usuario}' ORDER BY VISTO, FECHA_R DESC");
        $result = database::getRows($sql);
        $rows = database::getNumRows($sql);
        if ($rows > 0) {
            $alertas .= '<ul id="themes" class="dropdown-menu"  style="width: 320px; height: 373px;  overflow-y: auto;">';
            foreach ($result as $r) {
                $USER = $r['ENVIADO'];
                $sql2 = "SELECT IMAGEN,concat(TITULO,' ',NOMBRE,' ',APELLIDOS) AS NOMBRE FROM USUARIOS WHERE PK1='" . $USER . "'";
                $rowu = database::getRow($sql2);
                $alertas .= '<li ';
                $imagen = $rowu['IMAGEN'];
                if (trim($r['VISTO']) == "1") {
                    $objetivo = "<strike>" . $r['OBJETIVO'] . "</strike>";
                    $fecha = "<strike>" . $r['FECHA_R']->format('Y-m-d') . "</strike>";
                    $nombre = "<strike>" . htmlentities($rowu['NOMBRE']) . "</strike>";
                } else {
                    $objetivo = $r['OBJETIVO'];
                    $fecha = $r['FECHA_R']->format('Y-m-d');
                    $nombre = htmlentities($rowu['NOMBRE']);
                }
                $alertas .= '><a href="javascript:void(0)" onclick="goAlerta(\'' . $r['PK1'] . '\');" data-value="cerulean"> 
						<img src="media/usuarios/' . $imagen . '" height="45" width="45"  style="margin-top: 6px; position: absolute;" alt="">
						<span style="margin-left: 48px; font-size: 11px;"><i class="icon-hand-right"></i> ' . $objetivo . '</span><br/>
					    <span style="margin-left: 48px; font-size: 11px;"><i class="icon-user"></i> ' . $nombre . '</span><br/>
						<span style="font-size: 10px; margin-left: 48px;"><i class="icon-time"></i> ' . $fecha . '</span>
						</a>
						</li>
						<li class="divider"></li>';
            }
            $alertas .= '</ul>';
        } else {
            $alertas .= '<ul id="themes" class="dropdown-menu"  style="width: 300px; height:60px;  overflow-y: auto;">';
            $alertas .= '<li><a data-value="cerulean"  href="javascript:void(0)"> 
						<span style="margin-top: 18px; position: absolute;" class="icon icon-red icon-time"></span> 
						<br/>
					    <span style="margin-left: 18px; font-size: 11px;">&nbsp; No existen alertas por el momento....</span><br>
						<br/>
						</a>
						</li>';
            $alertas .= '</ul>';
        }
        return $alertas;
    }
示例#14
0
 function buscarGrados()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "CLAVE DESC ";
                 break;
             case 2:
                 $order = "DESCRIPCION DESC ";
                 break;
         }
     }
     /*if(isset($_GET['filter'])){
     			
     			$filter = "'".str_replace(";","','",$_GET['filter'])."'";
     	
     		}else{
     			$nivel =  $_SESSION['session']['nodo'];
     			$filter = "'$nivel' ";	
     		}*/
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $buscar = "WHERE (DESCRIPCION LIKE '%" . $_GET['q'] . "%') ";
     } else {
         $buscar = "";
     }
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n          FROM      GRADOS {$buscar}\n          \n         \n        ) AS RowConstrainedResult\nWHERE   RowNum > {$offset}\n    AND RowNum <= {$limit} \nORDER BY {$order}";
     try {
         $this->grados = database::getRows($sql);
         $total = database::getNumRows($sql);
         $this->totalnum = $total;
     } catch (customException $e) {
         throw new customException($sql);
     }
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#15
0
 function obtenerEstadoPlan($idplan)
 {
     $sql = "SELECT * FROM PL_POPERATIVOS_PERIODOS WHERE PK_POPERATIVO = '{$idplan}'";
     $total = database::getNumRows($sql);
     $sql = "SELECT * FROM PL_POPERATIVOS_PERIODOS WHERE PK_POPERATIVO = '{$idplan}' AND ENVIADO = '3'";
     $terminados = database::getNumRows($sql);
     $sql = "SELECT * FROM PL_POPERATIVOS_PERIODOS WHERE PK_POPERATIVO = '{$idplan}' AND ENVIADO = '1'";
     $enviados = database::getNumRows($sql);
     if ($total == $terminados) {
         return '';
     } else {
         if ($enviados > 0) {
             return "R";
         } else {
             return "E";
         }
     }
 }
示例#16
0
 function buscarFichas()
 {
     $this->fichas = array();
     // maximo por pagina
     $limit = $_GET["s"];
     $tamaño = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     /*
              $sql = "SELECT PK1, APLICACION, MODULO, MENSAJE, PK_USUARIO ,FECHA_R 
                     FROM (select PK1, APLICACION, MODULO, MENSAJE, PK_USUARIO ,FECHA_R, row_number() 
                     OVER (order by  $order) AS 
                     RowNumber FROM ACTIVIDAD_USUARIO) 
                     Derived WHERE RowNumber BETWEEN '$offset' AND '$limit' ";
     			
             if(isset($_GET['q']) && $_GET['q']!= ""){ 
     			$sql .= "AND (APLICACION LIKE '%".$_GET['q']."%') ";	
     		}
     */
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $buscar = "WHERE  (APLICACION LIKE '%" . $_GET['q'] . "%') ";
     } else {
         $buscar = "";
     }
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n          FROM      ACTIVIDAD_USUARIO\n           {$buscar}\n        ) AS RowConstrainedResult\nWHERE   RowNum > {$offset}\n    AND RowNum <= {$limit} \nORDER BY {$order}";
     $this->fichas = database::getRows($sql);
     $sqlcount = "SELECT PK1\n                     FROM ACTIVIDAD_USUARIO ";
     $this->totalnum = database::getNumRows($sqlcount);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $tamaño);
 }
示例#17
0
 function buscarProyectos()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     if (isset($_GET['filter'])) {
         $filter = "'" . str_replace(";", "','", $_GET['filter']) . "'";
         $filtro = " AND ( FACULTAD IN( {$filter} ) OR CENTRO IN( {$filter} ) ) ";
         if (trim($_GET['filter']) == "UAN") {
             $filtro = "";
         }
     } else {
         //$nivel =  $_SESSION['session']['nodo'];
         //$filter = "'$nivel' ";
         $filtro = "";
     }
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $buscar = " WHERE (TITULO LIKE '%" . $_GET['q'] . "%') ";
     } else {
         $buscar = "";
     }
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n          FROM      PROYECTOS  {$buscar}\t\n        \n        ) AS RowConstrainedResult\nWHERE   RowNum > {$offset}  AND RowNum <= {$limit}  {$filtro} ORDER BY {$order}";
     $this->proyectos = database::getRows($sql);
     $sqlcount = "SELECT PK1\n                     FROM PROYECTOS";
     $this->totalnum = database::getNumRows($sqlcount);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#18
0
 function buscarArchivos()
 {
     $this->archivos = array();
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     } else {
         $order = "FECHA_R DESC ";
     }
     $idPlan = $_GET['IDPlan'];
     if (isset($_GET['filter'])) {
         $filter = "'" . str_replace(";", "','", $_GET['filter']) . "'";
         $categorias = "AND TIPO IN( {$filter} ) ";
     } else {
         $categorias = "";
     }
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY FECHA_R ) AS RowNum, *\n          FROM      PL_PESTARTEGICOS_ADJUNTOS\n          WHERE     PK_PESTRATEGICO = '{$idPlan}' {$categorias} \n        ) AS RowConstrainedResult\nWHERE   RowNum >= {$offset}\n    AND RowNum <= {$limit}\nORDER BY {$order}";
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= "AND (TITULO LIKE '%" . $_GET['q'] . "%') ";
     }
     $result = database::executeQuery($sql);
     $total = database::getNumRows($sql);
     $this->totalnum = $total;
     while ($row = mssql_fetch_array($result, MSSQL_ASSOC)) {
         $this->archivos[] = $row;
     }
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($total / $limit);
 }
示例#19
0
 function buscarPlanesEstrategicos()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     $user = $_SESSION['session']['user'];
     $sql = "SELECT * FROM ROLES_USUARIO WHERE PK_USUARIO = '{$user}' AND PK_ROLE='R00'";
     $result = database::getNumRows($sql);
     if ($result != 0) {
         $filter = "";
     } else {
         $sql = "DECLARE @jerarquia VARCHAR(8000) = ''\n                   SELECT @jerarquia = @jerarquia + PK_JERARQUIA + ','\n                   FROM USUARIOS_JERARQUIA \n                   where PK_USUARIO = 'red'\n\n                   SELECT @jerarquia AS JERARQUIAS";
         //SELECT PK_JERARQUIA FROM USUARIOS_JERARQUIA WHERE PK_USUARIO = 'red'
         $row = database::getRow($sql);
         $jeararquias = "'" . str_replace(",", "','", $row['JERARQUIAS']) . "'";
         $filter = " AND PK_JERARQUIA IN( {$jeararquias} )";
     }
     $sql = "SELECT PK1, TITULO, DESCRIPCION, PK_JERARQUIA, DISPONIBLE,FECHA_I,FECHA_T,FECHA_R,PK_USUARIO,ELIMINADO \n                FROM (select PK1, TITULO, DESCRIPCION, PK_JERARQUIA, DISPONIBLE,FECHA_I,FECHA_T,FECHA_R,PK_USUARIO,ELIMINADO, row_number() \n                OVER (order by  {$order}) AS \n                RowNumber FROM PL_PESTRATEGICOS\t) \n                Derived WHERE RowNumber BETWEEN '{$offset}' AND '{$limit}' {$filter} ";
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $sql .= "AND (TITULO LIKE '%" . $_GET['q'] . "%') ";
     }
     //echo $sql;
     $this->planes = database::getRows($sql);
     $this->totalnum = database::getNumRows($sql);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#20
0
 function buscarNiveles()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $idNivel = $_GET['Nivel'];
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     if (isset($_GET['filter'])) {
         $filter = "'" . str_replace(";", "','", $_GET['filter']) . "'";
     } else {
         $nivel = $_SESSION['session']['nodo'];
         $filter = "'{$nivel}' ";
     }
     /* $sql = "SELECT PK1, NOMBRE, DESCRIPCION, PADRE, DISPONIBLE ,FECHA_R,ELIMINADO 
        FROM (select PK1, NOMBRE, DESCRIPCION, PADRE, DISPONIBLE ,FECHA_R,ELIMINADO, row_number() 
        OVER (order by  ORDEN) AS 
        RowNumber FROM JERARQUIAS) 
        Derived WHERE RowNumber BETWEEN '$offset' AND '$limit' AND PADRE = '$idNivel'";*/
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n          FROM      JERARQUIAS\n          WHERE     PADRE = '{$idNivel}' \n        ) AS RowConstrainedResult\nWHERE   RowNum > {$offset}\n    AND RowNum <= {$limit} \nORDER BY ORDEN";
     /*if(isset($_GET['q']) && $_GET['q']!= ""){ 
     			$sql .= "AND (NOMBRE LIKE '%".$_GET['q']."%') ";	
     		}*/
     $this->niveles = database::getRows($sql);
     $this->totalnum = database::getNumRows($sql);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#21
0
 function buscarUsuarios()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     $tamaño = $_GET["s"];
     // pagina pedida
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = "FECHA_R DESC ";
                 break;
         }
     }
     if (isset($_GET['filter'])) {
         $filter = "'" . str_replace(";", "','", $_GET['filter']) . "'";
     } else {
         $nivel = $_SESSION['session']['nodo'];
         $filter = "'{$nivel}' ";
     }
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $buscar = " AND (NOMBRE LIKE '%" . $_GET['q'] . "%') OR (PK1 LIKE '%" . $_GET['q'] . "%') ";
     } else {
         $buscar = "";
     }
     //(  FACULTAD IN( $filter ) OR FACULTAD IN( $filter ) OR CENTRO IN( $filter ) )
     $sql = "SELECT  *\nFROM    ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n          FROM      USUARIOS\n          WHERE     PK_JERARQUIA IN( {$filter} ) {$buscar}\n        ) AS RowConstrainedResult\nWHERE   RowNum > {$offset}\n    AND RowNum <= {$limit} \nORDER BY {$order}";
     $sqlcount = "SELECT * \n                     FROM USUARIOS WHERE PK_JERARQUIA IN( {$filter} ) {$buscar}";
     $this->usuarios = database::getRows($sql);
     $this->totalnum = database::getNumRows($sqlcount);
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $tamaño);
 }
 function buscaTodosLosProductos()
 {
     // maximo por pagina
     $limit = $_GET["s"];
     // pagina solicitada
     $pag = (int) $_GET["p"];
     if ($pag < 1) {
         $pag = 1;
     }
     $offset = ($pag - 1) * $limit;
     $limit = $limit * $pag;
     if (isset($_GET['sort'])) {
         switch ($_GET['sort']) {
             case 1:
                 $order = " FECHA_R DESC ";
                 break;
             case 2:
                 $order = " PRODUCTO  ";
                 break;
         }
     }
     if (isset($_GET['q']) && $_GET['q'] != "") {
         $text = strtoupper($_GET['q']);
         $buscar = "WHERE (UPPER(PRODUCTO) LIKE '%{$text}%') ";
     } else {
         $buscar = "";
     }
     $sql = "\n\t\t\tSELECT *\n\t\t\tFROM ( SELECT ROW_NUMBER() OVER ( ORDER BY {$order} ) AS RowNum, *\n\t\t\t          FROM  CATALOGO_PRODUCTOS {$buscar}\n\t\t\t      ) AS RowConstrainedResult\n\t\t\tWHERE RowNum > {$offset} AND RowNum <= {$limit}\n\t\t\tORDER BY {$order}\n\t\t\t";
     try {
         $this->rows = database::getRows($sql);
         $total = database::getNumRows($sql);
         $this->totalnum = $total;
     } catch (customException $e) {
         throw new customException($sql);
     }
     //CALCULAMOS EL TOTAL DE PAGINAS
     $this->totalPag = ceil($this->totalnum / $limit);
 }
示例#23
0
 function goAlerta($ID)
 {
     $sql = "UPDATE NOTIFICACIONES SET VISTO = '1' WHERE PK1='{$ID}'";
     database::executeQuery($sql);
     $sql = "SELECT * FROM NOTIFICACIONES WHERE PK1 = '{$ID}' ";
     $row = database::getRow($sql);
     if ($row['PARAMETROS'] == NULL) {
         echo $row['URL'];
     } else {
         //echo $row['URL'];
         $parametros = explode(",", $row['PARAMETROS']);
         $estado = explode("=", $parametros[0]);
         $plan = explode("=", $parametros[1]);
         $estado = $estado[1];
         $plan = $plan[1];
         $sql2 = "SELECT * FROM PL_POPERATIVOS WHERE PK1='{$plan}' AND ESTADO='{$estado}'";
         //echo $sql2;
         $result = database::getNumRows($sql2);
         //	$row2 = database::getRow($sql);
         if ($result > 0) {
             echo $row['URL'];
         }
     }
 }
 function GuardarObjetivos($idlineae, $i)
 {
     $fecha = date("Y-m-d H:i:s");
     $usuario = $_SESSION['session']['user'];
     $objetivosestrategicos = explode("|", $this->objetivos[$i]);
     $sql = "SELECT PK1 FROM PL_PESTRATEGICOS_OBJETIVOSE WHERE PK_LESTRATEGICA = '{$idlineae}'";
     $numobjetivosbase = database::getNumRows($sql);
     $numobjetivos = sizeof($objetivosestrategicos) - 1;
     if ($numobjetivosbase > $numobjetivos) {
         for ($i = $numobjetivos; $i <= $numobjetivosbase; $i++) {
             $sql = "DELETE FROM PL_PESTRATEGICOS_OBJETIVOSE WHERE PK_LESTRATEGICA = '{$idlineae}' AND ORDEN='{$i}'";
             database::executeQuery($sql);
         }
     }
     for ($i = 0; $i < sizeof($objetivosestrategicos) - 1; $i++) {
         $objetivo = $objetivosestrategicos[$i];
         $sql = "SELECT * FROM PL_PESTRATEGICOS_OBJETIVOSE WHERE PK_LESTRATEGICA = '{$idlineae}' AND ORDEN = '{$i}'";
         $row = database::getRow($sql);
         if ($row) {
             $this->campos = array('OBJETIVO' => $objetivo, 'FECHA_M' => date("Y-m-d H:i:s"), 'PK_USUARIO' => $_SESSION['session']['user']);
             $condition = "PK_LESTRATEGICA = '{$idlineae}' AND ORDEN = '{$i}'";
             database::updateRecords("PL_PESTRATEGICOS_OBJETIVOSE", $this->campos, $condition);
         } else {
             $idobjetivo = strtoupper(substr(uniqid('OE'), 0, 15));
             $this->campos = array('PK1' => $idobjetivo, 'OBJETIVO' => $objetivo, 'ORDEN' => $i, 'PK_LESTRATEGICA' => $idlineae, 'FECHA_R' => date("Y-m-d H:i:s"), 'PK_USUARIO' => $_SESSION['session']['user']);
             $result = database::insertRecords("PL_PESTRATEGICOS_OBJETIVOSE", $this->campos);
         }
     }
 }
示例#25
0
            break;
    }
}
/*if ( $password != $password2 ) {
	$_SESSION['message'] = 'The passwords you entered did not match.';
	header( 'location: ' . $_SERVER['HTTP_REFERER']);
	exit();
}*/
///print_r($_SESSION);
$sql = " select * from corporate_partners cp ";
$sql .= " where cp.clientID=" . intval($clientID);
if (!($result = $db->query($sql))) {
    die('Error:' . $db->error());
}
$db->fetcharray();
if ($db->getNumRows() > 0) {
    $sql = " update corporate_partners ";
    $sql .= " set clientname = '{$clientname}' , ";
    $sql .= " contactname = '{$contactname}', ";
    $sql .= " username = '******', ";
    if ($password != '') {
        $sql .= " password = '******', ";
    }
    $sql .= " address = '{$address}', ";
    $sql .= " phoneno = '{$phoneno}', ";
    $sql .= " faxno = '{$faxno}', ";
    $sql .= " emailadd = '{$emailadd}', ";
    $sql .= " extrainfo = '{$extrainfo}' ";
    $sql .= " where clientID = '{$clientID}' ";
    $_SESSION['task'] = 'edit';
    $_SESSION['title'] = $clientname;
 /**
  * Returns the number of rows returned from the most recent query.
  * 
  * @return int
  */
 function getNumRows($cur = null)
 {
     return $this->_db->getNumRows($cur);
 }
示例#27
0
 function getPrivilegioRol($rol, $permiso)
 {
     $sql = "SELECT * FROM ROLES_PERMISOS WHERE PK_ROL = '{$rol}' AND PK_PERMISO = '{$permiso}' ";
     $rows = database::getNumRows($sql);
     if ($rows) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
示例#28
0
 function UploadFile()
 {
     $idplan = $this->idplan;
     $linea = $this->idlinea;
     $objetivo = $this->idobjetivo;
     $sql = "SELECT * FROM PL_POPERATIVOS_EVIDENCIAS WHERE PK_POPERATIVO = '{$idplan}' AND PK_LESTRATEGICA = '{$linea}' AND PK_OTACTICO = '{$objetivo}'";
     $orden = database::getNumRows($sql);
     $usuario = $_SESSION['session']['user'];
     $this->campos = array('PK1' => uniqid($this->tipo), 'EVIDENCIA' => $this->titulo, 'ORDEN' => $orden, 'DESCRIPCION' => $this->descripcion, 'AUTOR' => $this->autor, 'TIPO' => $this->tipo, 'IMAGEN' => $this->imagen, 'ADJUNTO' => $this->adjunto, 'PK_POPERATIVO' => $this->idplan, 'PK_LESTRATEGICA' => $this->idlinea, 'PK_OTACTICO' => $this->idobjetivo, 'FECHA_R' => date("Y-m-d H:i:s"), 'PK_USUARIO' => $usuario);
     database::insertRecords("PL_POPERATIVOS_EVIDENCIAS", $this->campos);
 }
 function GuardarObjetivos()
 {
     //$this->EliminarObjetivos();
     $fecha = date("Y-m-d H:i:s");
     $usuario = $_SESSION['session']['user'];
     $plano = $this->idPlanOpe;
     for ($i = 0; $i < sizeof($this->lineas) - 1; $i++) {
         $lineae = $this->lineas[$i];
         $objetivos = explode("^", $this->objetivos[$i]);
         $medios = explode("~", $this->medios[$i]);
         $evidencias = explode("~", $this->evidencias[$i]);
         $sql = "SELECT * FROM PL_POPERATIVOS_OBJETIVOST WHERE PK_POPERATIVO = '{$plano}'AND PK_LESTRATEGICA = '{$lineae}' ";
         $numobjetivosbase = database::getNumRows($sql);
         $numobjetivos = sizeof($objetivos) - 1;
         if ($numobjetivosbase > $numobjetivos) {
             for ($x = $numobjetivos; $x <= $numobjetivosbase; $x++) {
                 $sql = "DELETE FROM PL_POPERATIVOS_OBJETIVOST WHERE PK_POPERATIVO = '{$plano}' AND PK_LESTRATEGICA = '{$lineae}' AND ORDEN='{$x}'";
                 database::executeQuery($sql);
             }
         }
         for ($j = 0; $j < sizeof($objetivos) - 1; $j++) {
             //GUARDAMOS LOS OBJETIVOS DEL PLAN OPERATIVO
             $objetivo = explode("¬", $objetivos[$j]);
             $sql = "SELECT * FROM PL_POPERATIVOS_OBJETIVOST WHERE PK_POPERATIVO = '{$plano}' AND ORDEN = '{$j}' AND PK_LESTRATEGICA = '{$lineae}'";
             $row = database::getRow($sql);
             if ($row) {
                 $idObjT = $row['PK1'];
                 $this->campos = array('OBJETIVO' => str_replace("'", "''", $objetivo[0]), 'PK_OESTRATEGICO' => $objetivo[1], 'PK_RESPONSABLE' => $objetivo[2], 'FECHA_M' => $fecha, 'PK_USUARIO' => $_SESSION['session']['user']);
                 $condition = "PK_POPERATIVO = '{$plano}' AND ORDEN = '{$j}' AND PK_LESTRATEGICA = '{$lineae}'";
                 database::updateRecords("PL_POPERATIVOS_OBJETIVOST", $this->campos, $condition);
             } else {
                 $idObjT = (string) strtoupper(substr(uniqid('OT'), 0, 15));
                 $this->campos = array('PK1' => $idObjT, 'OBJETIVO' => str_replace("'", "''", $objetivo[0]), 'ORDEN' => $j, 'PK_POPERATIVO' => $this->idPlanOpe, 'PK_LESTRATEGICA' => $this->lineas[$i], 'PK_OESTRATEGICO' => $objetivo[1], 'PK_RESPONSABLE' => $objetivo[2], 'FECHA_R' => date("Y-m-d H:i:s"), 'PK_USUARIO' => $_SESSION['session']['user']);
                 database::insertRecords("PL_POPERATIVOS_OBJETIVOST", $this->campos);
             }
             /////////EMPEZAMOS A GUARDAR LOS MEDIOS///////
             $medios_objetivo = explode("^", $medios[$j]);
             $sql = "SELECT * FROM PL_POPERATIVOS_MEDIOS WHERE PK_OTACTICO = '{$idObjT}'";
             $numobjetivosbase = database::getNumRows($sql);
             $numobjetivos = sizeof($medios_objetivo) - 1;
             if ($numobjetivosbase > $numobjetivos) {
                 for ($x = $numobjetivos; $x <= $numobjetivosbase; $x++) {
                     $sql = "DELETE FROM PL_POPERATIVOS_MEDIOS WHERE PK_OTACTICO = '{$idObjT}' AND ORDEN='{$x}'";
                     database::executeQuery($sql);
                 }
             }
             for ($k = 0; $k < sizeof($medios_objetivo) - 1; $k++) {
                 $medio = explode("¬", $medios_objetivo[$k]);
                 $idMedio = strtoupper(substr(uniqid('M'), 0, 15));
                 $sql = "SELECT * FROM PL_POPERATIVOS_MEDIOS WHERE PK_OTACTICO = '{$idObjT}' AND ORDEN = '{$k}'";
                 $row = database::getRow($sql);
                 if ($row) {
                     $this->campos = array('MEDIO' => str_replace("'", "''", $medio[0]), 'PK_RESPONSABLE' => $medio[1], 'FECHA_M' => $fecha, 'PK_USUARIO' => $_SESSION['session']['user']);
                     $condition = "PK_OTACTICO = '{$idObjT}' AND ORDEN = '{$k}'";
                     database::updateRecords("PL_POPERATIVOS_MEDIOS", $this->campos, $condition);
                 } else {
                     $this->camposM = array('PK1' => $idMedio, 'MEDIO' => str_replace("'", "''", $medio[0]), 'ORDEN' => $k, 'PK_OTACTICO' => $idObjT, 'PK_RESPONSABLE' => $medio[1], 'FECHA_R' => date("Y-m-d H:i:s"), 'PK_USUARIO' => $_SESSION['session']['user']);
                     database::insertRecords("PL_POPERATIVOS_MEDIOS", $this->camposM);
                 }
             }
             /////////EMPEZAMOS A GUARDAR LAS EVIDENCIAS///////
             $evidencias_objetivo = explode("^", $evidencias[$j]);
             $sql = "SELECT * FROM PL_POPERATIVOS_EVIDENCIAS WHERE PK_OTACTICO = '{$idObjT}'";
             $numobjetivosbase = database::getNumRows($sql);
             $numobjetivos = sizeof($evidencias_objetivo) - 1;
             if ($numobjetivosbase > $numobjetivos) {
                 for ($x = $numobjetivos; $x <= $numobjetivosbase; $x++) {
                     $sql = "DELETE FROM PL_POPERATIVOS_EVIDENCIAS WHERE PK_OTACTICO = '{$idObjT}' AND ORDEN='{$x}'";
                     database::executeQuery($sql);
                 }
             }
             for ($k = 0; $k < sizeof($evidencias_objetivo) - 1; $k++) {
                 $sql = "SELECT * FROM PL_POPERATIVOS_EVIDENCIAS WHERE PK_OTACTICO = '{$idObjT}' AND ORDEN = '{$k}'";
                 $row = database::getRow($sql);
                 if ($row) {
                     $this->campos = array('EVIDENCIA' => str_replace("'", "''", $evidencias_objetivo[$k]), 'FECHA_M' => $fecha, 'PK_USUARIO' => $_SESSION['session']['user']);
                     $condition = "PK_OTACTICO = '{$idObjT}' AND ORDEN = '{$k}'";
                     database::updateRecords("PL_POPERATIVOS_EVIDENCIAS", $this->campos, $condition);
                 } else {
                     $idEvidencia = strtoupper(substr(uniqid('E'), 0, 15));
                     $this->camposM = array('PK1' => $idEvidencia, 'EVIDENCIA' => str_replace("'", "''", $evidencias_objetivo[$k]), 'ORDEN' => $k, 'PK_POPERATIVO' => $this->idPlanOpe, 'PK_LESTRATEGICA' => $this->lineas[$i], 'PK_OTACTICO' => $idObjT, 'FECHA_R' => date("Y-m-d H:i:s"), 'PK_USUARIO' => $_SESSION['session']['user']);
                     database::insertRecords("PL_POPERATIVOS_EVIDENCIAS", $this->camposM);
                 }
             }
         }
     }
     /////////GUARDAMOS EL RESUMEN EJECUTIVO///////
     $idplano = $this->idPlanOpe;
     $sql = "DELETE FROM PL_POPERATIVOS_AREAS WHERE PK_POPERATIVO = '{$idplano}' ";
     database::executeQuery($sql);
     for ($k = 0; $k < sizeof($this->areas) - 1; $k++) {
         $idArea = strtoupper(substr(uniqid('A'), 0, 15));
         $this->camposM = array('PK1' => $idArea, 'AREA' => $this->areas[$k], 'ORDEN' => $k, 'PK_POPERATIVO' => $this->idPlanOpe, 'FECHA_R' => date("Y-m-d H:i:s"), 'PK_USUARIO' => $_SESSION['session']['user']);
         database::insertRecords("PL_POPERATIVOS_AREAS", $this->camposM);
     }
     $sql = "DELETE FROM PL_POPERATIVOS_FORTALEZAS WHERE PK_POPERATIVO = '{$idplano}' ";
     database::executeQuery($sql);
     for ($k = 0; $k < sizeof($this->fortalezas) - 1; $k++) {
         $idFortaleza = strtoupper(substr(uniqid('F'), 0, 15));
         $this->camposM = array('PK1' => $idFortaleza, 'FORTALEZA' => $this->fortalezas[$k], 'ORDEN' => $k, 'PK_POPERATIVO' => $this->idPlanOpe, 'FECHA_R' => date("Y-m-d H:i:s"), 'PK_USUARIO' => $_SESSION['session']['user']);
         database::insertRecords("PL_POPERATIVOS_FORTALEZAS", $this->camposM);
     }
     //////ACTUALIZAMOS EL ESTADO DEL PLAN OPERATIVO A GUARDADO///
     $this->campos = array('ESTADO' => $this->estado);
     $condition = "PK1='" . $this->idPlanOpe . "'";
     database::updateRecords("PL_POPERATIVOS", $this->campos, $condition);
 }
示例#30
0
文件: index3.php 项目: cwcw/cms
}
// restore some session variables
$my = new mosUser($database);
$my->id = mosGetParam($_SESSION, 'session_user_id', '');
$my->username = mosGetParam($_SESSION, 'session_username', '');
$my->usertype = mosGetParam($_SESSION, 'session_usertype', '');
$my->gid = mosGetParam($_SESSION, 'session_gid', '');
$session_id = mosGetParam($_SESSION, 'session_id', '');
$logintime = mosGetParam($_SESSION, 'session_logintime', '');
// check against db record of session
if ($session_id == md5($my->id . $my->username . $my->usertype . $logintime)) {
    $database->setQuery("SELECT * FROM #__session" . "\nWHERE session_id='{$session_id}'");
    if (!($result = $database->query())) {
        echo $database->stderr();
    }
    if ($database->getNumRows($result) != 1) {
        echo "<script>document.location.href='index.php'</script>\n";
        exit;
    }
} else {
    echo "<script>document.location.href='index.php'</script>\n";
    exit;
}
// update session timestamp
$current_time = time();
$database->setQuery("UPDATE #__session SET time='{$current_time}'" . "\nWHERE session_id='{$session_id}'");
$database->query();
// timeout old sessions
$past = time() - 1800;
$database->setQuery("DELETE FROM #__session WHERE time < '{$past}'");
$database->query();