Example #1
0
<?php

include_once dirname(dirname(__FILE__)) . "/conexionLocal.php";
include_once dirname(__FILE__) . "/getTMRut.php";
$rutTM = $_POST['rut'];
$tm = getTMRut($rutTM);
$idtm = $tm['idTM'];
if (isset($_POST['especifico'])) {
    $especifico = $_POST['especifico'];
    $queryprestacion = mysql_query("Select idprestaciones from prestaciones where \n\t\tEspecifico='{$especifico}'");
    $res = mysql_fetch_assoc($queryprestacion);
    $idPrestacion = $res['idprestaciones'];
    $query = "Delete from prestacionestm WHERE TM_idTM={$idtm} and prestaciones_idprestaciones={$idPrestacion} ";
    $resultadoborrar = mysql_query($query);
    if ($resultadoborrar) {
        //success
        echo "Borrado con exito";
    } else {
        //failure
        echo "Error en la eliminacion";
    }
}
if (isset($_POST['idPrestacion'])) {
    $idPrestacion = $_POST['idPrestacion'];
    $query = "Delete from prestacionestm WHERE TM_idTM={$idtm} and prestaciones_idprestaciones={$idPrestacion} ";
    $resultadoborrar = mysql_query($query);
    if ($resultadoborrar) {
        //success
        echo "Borrado con exito";
    } else {
        //failure
Example #2
0
<?php

if (!isset($_SESSION)) {
    session_start();
    include_once dirname(dirname(__FILE__)) . "/conexionLocal.php";
    include_once dirname(__FILE__) . "/insertLog.php";
    include_once dirname(__FILE__) . "/getEmpresaRut.php";
    include_once dirname(__FILE__) . "/getTMRut.php";
    $user = $_POST['user'];
    $password = $_POST['password'];
    $rec = mysql_query("SELECT idTM FROM tm WHERE Rut = '{$user}' AND Password = '******'") or die(mysql_error());
    if (mysql_affected_rows() == 1) {
        insertLog('login', dirname(__FILE__) . '?&user='******'&IP=' . $_SERVER['REMOTE_ADDR']);
        $resultado = getTMRut($user);
        //var_dump($resultado34);
        $_SESSION['idusuario'] = $resultado['idTM'];
        $_SESSION["usuario"] = $resultado['Nombre'];
        $_SESSION["context"] = "tm";
        //header("location:index.php");
        //var_dump($user1);
        echo "Tm";
    }
    $rec2 = mysql_query("SELECT * FROM empresa WHERE Rut = '{$user}' AND Password = '******'") or die(mysql_error());
    if (mysql_affected_rows() == 1) {
        //se inserta log de ingreso
        insertLog('login', dirname(__FILE__) . '?&user='******'&IP=' . $_SERVER['REMOTE_ADDR']);
        //se buscan los datos del a empresa
        $resultado34 = getEmpresaRut($user);
        if ($resultado34) {
            $_SESSION['idusuario'] = $resultado34['idEmpresa'];
            $_SESSION["usuario"] = $resultado34['Nombre'];
<?php

/*
 * getPrestacion funcion que se conecta a la base de datos para entregar la informacion de todas
 * las prestaciones de un tm especifico, dado su Rut y dado que el no este asociado anteriormente a esta prestacion
 *
 */
include_once dirname(__FILE__) . '/../conexionLocal.php';
// archivo de conexion local
include_once dirname(__FILE__) . '/getTMRut.php';
if (isset($_POST['idEmpresa'])) {
    $rut = $_POST['rut'];
    $tm = getTMRut($rut);
    $idtm = $tm['idTM'];
    $empresa = $_POST['idEmpresa'];
    function getAllPrestaciones($idtm, $empresa)
    {
        $query = "Select idprestaciones as idPrestacion, Grupo, Especifico from prestaciones\nwhere idprestaciones not in (Select idPrestacion from(Select idprestaciones as idPrestacion, Grupo, Especifico from prestaciones\ninner join prestacionestm on ( prestaciones.idprestaciones = prestacionestm.prestaciones_idprestaciones )\nwhere prestacionestm.TM_idTM = {$idtm} and prestacionestm.Empresa_idEmpresa = {$empresa}) x) order by Grupo asc";
        $res = mysql_query($query) or die(mysql_error());
        if (mysql_num_rows($res) >= 1) {
            while ($row = mysql_fetch_assoc($res)) {
                $result[] = $row;
            }
            echo json_encode($result);
        } else {
            return false;
        }
    }
    getAllPrestaciones($idtm, $empresa);
}