public static function calcularPercentilMargens($imc, $sexo, $nascimento)
 {
     $curva = new Curva();
     // Margens dos percentis baseado no cálculo inicial.
     $margemIMCInferior = $imc - MARGEM_LIMITE_PERCENTIL;
     $margemIMCSuperior = $imc + MARGEM_LIMITE_PERCENTIL;
     // Valores crescentes e decrescentes do IMC.
     $imcDecrescente = $imc;
     $imcCrescente = $imc;
     $idadeMeses = DataUtil::calcularIdadeMeses($nascimento);
     $db = new DbHandler();
     // Verificação do percentil inferior.
     $percentilInferior = NULL;
     while (empty($percentilInferior) && $imcDecrescente >= $margemIMCInferior) {
         // Decrescer gradativamente os valores do IMC na escala.
         $imcDecrescente = $imcDecrescente - ESCALA_IMC_PERCENTIL;
         $percentilInferior = $db->selecionarPercentil($imcDecrescente, $sexo, $idadeMeses);
     }
     $curva->setPercentilInferior($percentilInferior);
     // Verificação do percentil superior.
     $percentilSuperior = NULL;
     while (empty($percentilSuperior) && $imcCrescente <= $margemIMCSuperior) {
         // Crescer gradativamente os valores do IMC na escala.
         $imcCrescente = $imcCrescente + ESCALA_IMC_PERCENTIL;
         $percentilSuperior = $db->selecionarPercentil($imcCrescente, $sexo, $idadeMeses);
     }
     $curva->setPercentilSuperior($percentilSuperior);
     return $curva;
 }
/**
* Checking if the request has valid api key in the "Authorization" header
*/
function authenticate(\Slim\Route $route)
{
    $headers = apache_request_headers();
    $response = array();
    $app = \Slim\Slim::getInstance();
    if (isset($headers["Authorization"])) {
        $db = new DbHandler();
        $api_key = $headers["Authorization"];
        $user = $db->isValidApiKey($api_key);
        if ($user == null) {
            $response["error"] = true;
            $response["message"] = "Access Denied. Invalid Api key";
            echoResponse(FAILURE_CODE, $response);
            $app->stop();
        } else {
            global $user_name;
            $user_name = $user;
        }
    } else {
        $response["error"] = true;
        $response["message"] = "Api key is misssing";
        echoResponse(404, $response);
        $app->stop();
    }
}
Example #3
0
/**
 * Adding Middle Layer to authenticate every request
 * Checking if the request has valid api key in the 'Authorization' header
 */
function authenticate(\Slim\Route $route)
{
    // Getting request headers
    $headers = apache_request_headers();
    $response = array();
    $app = \Slim\Slim::getInstance();
    // Verifying Authorization Header
    if (isset($headers['Authorization'])) {
        $db = new DbHandler();
        // get the api key
        $api_key = $headers['Authorization'];
        // validating api key
        if (!$db->isValidApiKey($api_key)) {
            // api key is not present in users table
            $response["error"] = true;
            $response["message"] = "Access Denied. Invalid Api key";
            echoRespnse(401, $response);
            $app->stop();
        } else {
            global $user_id;
            // get user primary key id
            $user_id = $db->getUserId($api_key);
        }
    } else {
        // api key is missing in header
        $response["error"] = true;
        $response["message"] = "Api key is misssing";
        echoRespnse(400, $response);
        $app->stop();
    }
}
Example #4
0
function doLog($Mesaj)
{
    $db = new DbHandler();
    $useragent = $_SERVER["HTTP_USER_AGENT"];
    $IPAdres = $_SERVER["REMOTE_ADDR"];
    $db->Log($IPAdres, $useragent, $Mesaj);
}
 public function notifyAdmins($id, $title, $description, $author, $email, $time = "", $geo = "", $source = "")
 {
     $dbHandler = new DbHandler();
     $emails = $dbHandler->getAdminsEmails();
     if (count($emails) == 0) {
         return;
     }
     $emails_comma_separated = $this->recieversString($emails);
     $subject = $this->constructEmailSubject($id);
     $body = $this->constructEmailBody($id, $title, $description, $author, $email, $time, $geo, $source);
     $headers = $this->makeHeaders();
     mail($emails_comma_separated, $subject, $body, $headers);
 }
Example #6
0
 function getTable()
 {
     $db = new DbHandler();
     $result = $db->getEbookAll();
     $response["error"] = false;
     $response["ebooks"] = array();
     $allEbooksArray = array();
     if ($result != null) {
         while ($row = $result->fetch_assoc()) {
             $allEbooksArray[] = array("Id" => $row['id'], "nazwa" => $row['nazwa'], "opis" => $row['opis'], "dane" => $row['dane']);
         }
     }
     $this->allEbooksArray = $allEbooksArray;
 }
Example #7
0
 protected static function getUserId($username)
 {
     $conn = DbHandler::getConnection();
     $query = "SELECT id FROM users WHERE username = '******'";
     $user_id = $conn->querySingle($query);
     return $user_id;
 }
Example #8
0
 public static function insertMessage($user_id, $chat_id, $message)
 {
     $conn = DbHandler::getConnection();
     $query = "INSERT INTO messages (chat_id, user_id, message, insert_time) " . "VALUES (" . $conn->escapeString($chat_id) . ", " . $conn->escapeString($user_id) . ", '" . $conn->escapeString($message) . "', " . $conn->escapeString(getMicrotime()) . ")";
     $conn->exec($query);
     UserHandler::setUserActivity();
     return true;
 }
Example #9
0
 function __construct()
 {
     parent::__construct();
     try {
         $this->handler = new mysqli($this->hostname, $this->username, $this->password, $this->schema);
         if ($this->handler->connect_error) {
             throw new Exception('DB Connection Error');
         }
     } catch (Exception $exception) {
         echo 'Cannot connect to selected DB: ' . $exception->getMessage() . "\n";
     }
     $this->handler->autocommit(FALSE);
 }
        $sheet = $objPHPExcel->getActiveSheet();
        $highestRow = $sheet->getHighestRow();
        $highestColumn = $sheet->getHighestColumn();
        //  Loop through each row of the worksheet in turn
        $array['cols'][] = array('type' => 'date', 'id' => 'date', 'label' => 'Date');
        $array['cols'][] = array('type' => 'number', 'id' => 'Theorique', 'label' => 'Théorique');
        $array['cols'][] = array('type' => 'number', 'id' => 'Centres_ouverts', 'label' => 'Centres ouverts');
        $array['cols'][] = array('type' => 'number', 'id' => 'Centres_actifs', 'label' => 'Centres actifs');
        for ($row = 2; $row <= $highestRow; $row++) {
            $array['rows'][] = array('c' => array(array('v' => 'Date(' . date('Y, m , j', strtotime('-1 month', strtotime(date('Y-m-j', PHPExcel_Shared_Date::ExcelToPHP($sheet->getCellByColumnAndRow(0, $row)->getValue()))))) . ')'), array('v' => $sheet->getCellByColumnAndRow('1', $row)->getValue()), array('v' => $sheet->getCellByColumnAndRow('2', $row)->getValue()), array('v' => $sheet->getCellByColumnAndRow('3', $row)->getValue())));
        }
        echoResponse(200, $array);
    }
});
$app->get('/etude/:id/courbe/patient', function ($id) {
    $db = new DbHandler();
    $query = "SELECT laboratoire.libelle as lab,etude.libelle as et FROM etude , laboratoire WHERE etude.id_laboratoire=laboratoire.id and etude.id={$id}";
    $response = $db->execute($query);
    foreach ($response as &$value) {
        $rep = "../../data/" . $value['lab'] . "/" . $value['et'] . "/Courbe_Patients.xlsx";
    }
    date_default_timezone_set('Europe/Paris');
    $objReader = PHPExcel_IOFactory::createReader('Excel2007');
    $objReader->setReadDataOnly(true);
    if (file_exists($rep)) {
        $objPHPExcel = $objReader->load($rep);
        $sheet = $objPHPExcel->getActiveSheet();
        $highestRow = $sheet->getHighestRow();
        $highestColumn = $sheet->getHighestColumn();
        //  Loop through each row of the worksheet in turn
        $array['cols'][] = array('type' => 'date', 'id' => 'date', 'label' => 'Date');
Example #11
0
<?php

require_once '../include/DbHandler.php';
require_once '../include/PassHash.php';
require '.././libs/Slim/Slim.php';
define('DB_HOST', 'localhost');
define('DB_NAME', 'task_manager');
define('DB_USER', 'vyk');
define('DB_PASSWORD', 'navneeta');
$con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db = mysql_select_db(DB_NAME, $con) or die("Failed to connect to MySQL: " . mysql_error());
$u = $_POST['user'];
$p = $_POST['pass'];
$db = new DbHandler();
// check for correct email and password
if ($db->checkLogin($email, $password)) {
    // get the user by email
    $user = $db->getUserByEmail($email);
    if ($user != NULL) {
        echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE...";
    } else {
        echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY...";
    }
}
Example #12
0
 $pdf->Open();
 $pdf->AddPage();
 $pdf->SetMargins(5, 3, 5);
 // margen, left, top y right
 //$pdf->Ln(03);
 //$pdf->SetWidths(array(65, 60, 55, 50, 20));
 $pdf->SetFont('Arial', 'B', 8);
 $pdf->SetFillColor(85, 107, 47);
 $pdf->SetTextColor(0);
 $pdf->ln();
 //
 $response = array();
 $lisPreguntas = json_decode($app->request->getBody());
 $idUser = intval($_SESSION['uid']);
 $lista = implode(",", $lisPreguntas);
 $db = new DbHandler();
 $impresas = $db->get1Record("select fn_num_respuesta_print( '{$lista}' ) as cantidad");
 //var_dump($impresas);
 if ($impresas['cantidad'] == 0) {
     // genera las respuestas en el documento PDF
     // $target_dir = $_SERVER['DOCUMENT_ROOT'] . "/server/uploaded_files/";
     // registra el nuevo lote de preguntas impresas
     // insert into pyr_respuesta_print ( id, fecha, id_usuario ) values ( now(), now(), 12 );
     $idLote = $db->get1Record("select fn_ins_pyr_respuesta_print( {$idUser} ) as id");
     if ($idLote != NULL && $idLote > 0) {
         $ok = true;
         foreach ($lisPreguntas as $respuesta) {
             // registra el detalle de preguntas incluidas en el lote
             // insert into pyr_respuesta_print_det ( id_print, id_pregunta ) values ( '2015-11-13 01:04:40', 63 );
             if ($ok == true) {
                 $idDet = $db->get1Record("select fn_ins_pyr_respuesta_print_det( '" . $idLote['id'] . "', {$respuesta} ) as idDet");
Example #13
0
    }
});
$app->post('/resetPassword', function () use($app) {
    require_once 'passwordHash.php';
    $response = array();
    $r = json_decode($app->request->getBody());
    $password_non = $r->password;
    if (strtolower($password) == $password_non) {
        $response["status"] = "error";
        $response["message"] = "Need at least 1 capital letter in password";
        echoResponse(201, $response);
        $app->stop();
    }
    if (!preg_match('/[0-9]+/', $password_non)) {
        $response["status"] = "error";
        $response["message"] = "Need at least 1 number in password";
        echoResponse(201, $response);
        $app->stop();
    }
    $password = passwordHash::hash($password_non);
    $key = $r->key;
    $db = new DbHandler();
    $dbemail = $db->getOneRecord("select email from confirm where validation_key='{$key}'");
    $email = $dbemail['email'];
    $dbuid = $db->getOneRecord("select uid from users where email='{$email}'");
    $uid = $dbuid['uid'];
    $db->updateOneRecord("update users set password = '******' where uid='{$uid}'");
    $response["status"] = "success";
    $response["message"] = "Account password sucessfully reset.";
    echoResponse(200, $response);
});
<?php

include_once "utility.php";
include_once "db.php";
/**
 * Created by PhpStorm.
 * User: Steve
 * Date: 9/22/14
 * Time: 8:09 PM
 */
$user = "******";
$pw = "Zero";
if (strtolower($_POST['user_name']) != $user || $_POST['user_password'] != $pw) {
    exit("INVALID CREDENTIALS");
}
$week = $_POST["week"];
$scorecard = $_POST["scorecard"];
if ($scorecard == 'true') {
    $scorecard = 1;
} else {
    $scorecard = 0;
}
$news1 = $_POST["news1"];
$news2 = $_POST["news2"];
$news3 = $_POST["news3"];
$db = new DbHandler();
$db->insertVariables($week, $scorecard, $news1, $news2, $news3);
exit("Status: Content inserted successfully");
Example #15
0
    $response["message"] = array();
    // looping through result and preparing tasks array
    while ($project = $result->fetch_assoc()) {
        $tmp = array();
        $tmp["nombre"] = $project["nombre"];
        $tmp["socialID"] = $project["socialID"];
        $tmp["proyectoID"] = $project["proyectoID"];
        $tmp["comentario"] = $project["comentario"];
        $tmp["fecha_comentario"] = $project["fecha_comentario"];
        array_push($response["message"], $tmp);
    }
    echoRespnse(200, $response);
});
$app->post('/donar', function () use($app) {
    $response = array();
    $db = new DbHandler();
    // fetching all user tasks
    $result = $db->getAllProjects();
    $response["error"] = false;
    $response["message"] = array();
    // looping through result and preparing tasks array
    while ($project = $result->fetch_assoc()) {
        $tmp = array();
        $tmp["nombre"] = $project["nombre"];
        $tmp["descripcionLarga"] = $project["descripcion_larga"];
        $tmp["descripcionCorta"] = $project["descripcion_corta"];
        $tmp["monto"] = $project["monto"];
        $tmp["diasVigencia"] = $project["diasvigencia"];
        $tmp["proyectoID"] = $project["proyectoID"];
        $tmp["categoria"] = $project["categoria"];
        $tmp["ciudad"] = $project["ciudad"];
Example #16
0
<?php

require_once '../include/DbHandler.php';
$db = new DbHandler();
$result = $db->crearRespuesta("Hola hola bla bla", 6, 1);
if (is_null($result)) {
    echo "Es NULL";
} else {
    print_r($result);
}
Example #17
0
    if ($datos != NULL) {
        $response['data'] = $datos;
        $response['status'] = "success";
        $response['message'] = '';
    } else {
        $response['status'] = "info";
        $response['message'] = 'No hay municipios';
    }
    echoResponse(200, $response);
});
// Opción para actualizar un registro de la tabla cat_municipio
// Opción para eliminar un registro de la tabla cat_municipio
$app->get('/municipioD/:id', 'sessionAlive', function ($id) use($app) {
    // Recupera los datos de la forma
    //
    $response = array();
    //
    //
    $db = new DbHandler();
    $resId = $db->deleteRecord("call sp_del_cat_municipio(?)", $id);
    if ($resId == 0) {
        $response['status'] = "success";
        $response['message'] = 'Datos eliminados';
    } else {
        if ($resId < 0) {
            $response['status'] = "error " . $resId;
            $response['message'] = 'No pudo eliminar los Datos';
        }
    }
    echoResponse(200, $response);
});
Example #18
0
<?php

include './include/DbHandler.php';
$db = new DbHandler();
header('Content-Type: application/json');
$response = array();
$response["error"] = false;
if (isset($_POST['mobile']) && $_POST['mobile'] != '') {
    $mobile = $_POST['mobile'];
    $result = $db->logoutUser($mobile);
    if ($result != NULL) {
        $response["message"] = "User Logged out successfully!";
    } else {
        $response["error"] = true;
        $response["message"] = "Sorry! Failed to Logout your account.";
    }
} else {
    $response["error"] = true;
    $response["message"] = "Sorry! Mobile is missing.";
}
echo json_encode($response);
Example #19
0
    $db = new DbHandler();
    $res = $db->addProject($name, $start_date, $end_date, $description, $team_lead, $target_audience, $estimated_funds);
    if ($res != PROJECT_CREATE_FAILED) {
        $response["error"] = false;
        $response["message"] = "project successfully registered with id" + $res;
        echoRespnse(201, $response);
    } else {
        $response["error"] = TRUE;
        $response["message"] = "oops! an error occured while registering project";
        echoRespnse(200, $response);
    }
});
$app->get('/projects/:id', function ($project_id) {
    global $user_id;
    $response = array();
    $db = new DbHandler();
    // fetch project
    $result = $db->getProject($project_id);
    if ($result != NULL) {
        $response["error"] = false;
        $response["id"] = $result["id"];
        $response["name"] = $result["name"];
        $response["start_date"] = $result["start_date"];
        $response["end_date"] = $result["end_date"];
        $response["description"] = $result["description"];
        $response["team_lead"] = $result["team_lead"];
        $response["estimated_funds"] = $result["estimated_funds"];
        echoRespnse(200, $response);
    } else {
        $response["error"] = true;
        $response["message"] = "The requested resource doesn't exists";
Example #20
0
<?php

/**
 * Register a new user
 *
 * By Kai Rune Orten
 */
$app->post('/register', function () use($app) {
    $r = json_decode($app->request->getBody());
    verifyRequiredParams(array('phone', 'birth'), $r->user);
    validateRequest($r->user);
    $db = new DbHandler();
    $tabble_name = "user";
    $phone = $r->user->phone;
    $birth = $r->user->birth;
    //We need to format the date to MySQL standard yyyy-mm-dd.
    $r->user->birth = Date('Y-m-d', strtotime($birth));
    //If we dont care if the user register multiple time, remove the following function and condition
    $userExists = $db->getOneRecord("select 1 from {$tabble_name} where phone='{$phone}'");
    if (!$userExists) {
        $column_names = array('first_name', 'last_name', 'email', 'phone', 'birth');
        $result = $db->insertIntoTable($r->user, $column_names, $tabble_name);
        if ($result !== NULL) {
            $response["status"] = "success";
            $response["message"] = array("Registrering fullført");
            echoResponse(200, $response);
        } else {
            $response["status"] = "error";
            $response["message"] = array("En feil oppstod i registreringen, vennligst prøv igjen");
            echoResponse(200, $response);
        }
Example #21
0
        var_dump($qid);
        var_dump($iscorrect);*/
    $db = new DbHandler();
    $res = $db->submitAnswer($input);
    if ($res == 0) {
        $response = array("error" => false, "message" => "successful insert");
        echoResponse(201, $response);
    } else {
        if ($res == 1) {
            $response = array("error" => true, "message" => "failed to insert user response");
            echoResponse(200, $response);
        }
    }
});
$app->get('/lumitrivia/usersubmit/:username', function ($username) use($app) {
    $db = new DbHandler();
    $res = $db->getSubmissionsByUsername($username);
    if ($res == 1) {
        $response = array("error" => true, "message" => "failed getting user submissions");
        echoResponse(201, $response);
    } else {
        echoResponse(200, $res);
    }
});
/**
 * Verifying required params posted or not
 */
function verifyRequiredParams($required_fields)
{
    $error = false;
    $error_fields = "";
Example #22
0
        }
        $response["message"] = "Query Successful";
    } else {
        $response["error"] = true;
        $response["message"] = "One or more field(s) missing or invalid.";
    }
    echoResponse(200, $response);
});
/*
 *  NOTIFICATION RELATED METHODS
 * 
 */
$app->get('/allnotifications', function () use($app) {
    $response = array();
    $userId = $app->request()->get('userId');
    $db = new DbHandler();
    //echo "testing";
    // fetching all user tasks
    $result = $db->getAllNotifications($userId);
    // looping through result and preparing updates array
    if ($result) {
        $response["error"] = false;
        $response["notifications"] = array();
        $notification = $result->fetch_assoc();
        if ($notification == NULL) {
            $response["message"] = "No Notifications Found";
            echoResponse(200, $response);
            return;
        }
        // looping through result and preparing updates array
        while ($notification) {
Example #23
0
    $datos = $db->getAllRecord("call sp_sel_cat_ice( )");
    //var_dump($datos);
    if ($datos != NULL) {
        $response = $datos;
    } else {
        $response['status'] = "info";
        $response['message'] = "No hay ICE's";
    }
    echoResponse(200, $response);
});
// Opción para actualizar un registro de la tabla cat_ice
// Opción para eliminar un registro de la tabla cat_ice
$app->get('/iceD/:id', 'sessionAlive', function ($id) use($app) {
    // Recupera los datos de la forma
    //
    $response = array();
    //
    //
    $db = new DbHandler();
    $resId = $db->deleteRecord("call sp_del_cat_ice(?)", $id);
    if ($resId == 0) {
        $response['status'] = "success";
        $response['message'] = 'Datos eliminados';
    } else {
        if ($resId < 0) {
            $response['status'] = "error " . $resId;
            $response['message'] = 'No pudo eliminar los Datos';
        }
    }
    echoResponse(200, $response);
});
<?php

include './include/DbHandler.php';
$db = new DbHandler();
header('Content-Type: application/json');
$response = array();
if (isset($_POST['mobile']) && $_POST['mobile'] != '') {
    $name = $_POST['name'];
    $vehicle_reg_no = $_POST['vehicle_reg_no'];
    $mobile = $_POST['mobile'];
    $otp = rand(100000, 999999);
    $res = $db->createUser($name, $vehicle_reg_no, $mobile, $otp);
    if ($res == USER_CREATED_SUCCESSFULLY) {
        // send sms
        sendSms($mobile, $otp);
        $response["error"] = false;
        $response["message"] = "SMS request is initiated! You will be receiving it shortly.";
    } else {
        if ($res == USER_CREATE_FAILED) {
            $response["error"] = true;
            $response["message"] = "Sorry! Error occurred in registration.";
        } else {
            if ($res == USER_ALREADY_EXISTED) {
                $response["error"] = true;
                $response["message"] = "Mobile number already existed!";
            }
        }
    }
} else {
    $response["error"] = true;
    $response["message"] = "Sorry! mobile number is not valid or missing.";
Example #25
0
        $result = $db->insertIntoTable($r->user, $column_names, $tabble_name);
        if ($result != NULL) {
            $response["status"] = "success";
            $response["message"] = "User account created successfully";
            $response["uid"] = $result;
            if (!isset($_SESSION)) {
                session_start();
            }
            $_SESSION['uid'] = $response["uid"];
            $_SESSION['phone'] = $phone;
            $_SESSION['name'] = $name;
            $_SESSION['email'] = $email;
            echoResponse(200, $response);
        } else {
            $response["status"] = "error";
            $response["message"] = "Failed to create user. Please try again";
            echoResponse(201, $response);
        }
    } else {
        $response["status"] = "error";
        $response["message"] = "An user with the provided phone or email exists!";
        echoResponse(201, $response);
    }
});
$app->get('/logout', function () {
    $db = new DbHandler();
    $session = $db->destroySession();
    $response["status"] = "info";
    $response["message"] = "Logged out successfully";
    echoResponse(200, $response);
});
Example #26
0
/**
 * Get revision data of a particular generator ID
 * @param String $name nameString of User in database
 * method GET
 * url /names/name
 */
function getAnImplementedDateGenRevision($date, $genID, $revId)
{
    $response = array();
    $db = new DbHandler();
    if ($revId == 'count' && !is_numeric($revId)) {
        $result = $db->getImplementedDateGenRevisionCount($date, $genID);
        if (gettype($result) == "string") {
            $response["error"] = true;
            $response["message"] = $result;
        } else {
            $response["error"] = false;
            $response["count"] = $result->fetch_assoc()['count'];
        }
        echoResponse(200, $response);
    } else {
        if ($revId == 'latest' && !is_numeric($revId)) {
            $result = $db->getImplementedDateRevisionCount($date);
            if (gettype($result) == "string") {
                $response["error"] = true;
                $response["message"] = $result;
                echoResponse(200, $response);
            } else {
                $count = $result->fetch_assoc()['count'];
                getAnImplementedDateGenRevision($date, $genID, $count);
            }
        } else {
            if (is_numeric($revId) || $revId == null) {
                // fetching all users with a particular name
                $result = $db->getAnImplementedDateGenRevisionData($date, $genID, $revId);
                //$result1 = $db->getAnImplementedDateGenRevisionParams($date, $revId);
                if (gettype($result) == "string") {
                    $response["error"] = true;
                    $response["message"] = $result;
                } else {
                    $response["error"] = false;
                    $response["revNumber"] = $revId;
                    $response["date"] = $date;
                    $response["revData"] = array();
                    // looping through result and preparing names array
                    while ($task = $result->fetch_assoc()) {
                        $tmp = array();
                        $tmp["p_id"] = $task["p_id"];
                        $tmp["from_b"] = $task["from_b"];
                        $tmp["to_b"] = $task["to_b"];
                        $tmp["cat"] = $task["cat"];
                        $tmp["val"] = $task["val"];
                        array_push($response["revData"], $tmp);
                    }
                    // looping through result and preparing names array
                    /*while ($task = $result1->fetch_assoc()) {
                          $response["comment"] = $task["comment"];
                          $response["TO"] = $task["time"];
                      }*/
                }
                echoResponse(200, $response);
            } else {
                $response["error"] = true;
                $response["message"] = "Invalid Revision data request url";
                echoResponse(200, $response);
            }
        }
    }
}
Example #27
0
    $datos = $db->getAllRecord("call sp_sel_sip_tipo_precalificado( )");
    //var_dump($datos);
    if ($datos != NULL) {
        $response = $datos;
    } else {
        $response['status'] = "info";
        $response['message'] = 'No hay sectores';
    }
    echoResponse(200, $response);
});
// Opción para actualizar un registro de la tabla sip_tipo_precalificado
// Opción para eliminar un registro de la tabla sip_tipo_precalificado
$app->get('/tpD/:id', 'sessionAlive', function ($id) use($app) {
    // Recupera los datos de la forma
    //
    $response = array();
    //
    //
    $db = new DbHandler();
    $resId = $db->deleteRecord("call sp_del_sip_tipo_precalificado(?)", $id);
    if ($resId == 0) {
        $response['status'] = "success";
        $response['message'] = 'Datos eliminados';
    } else {
        if ($resId < 0) {
            $response['status'] = "error " . $resId;
            $response['message'] = 'No pudo eliminar los Datos';
        }
    }
    echoResponse(200, $response);
});
        $response["message"] = "Failed to create company. Please try again";
        echoRespnse(200, $response);
    }
});
/**
 * Updating existing company
 * method PUT
 * params company, status
 * url - /companies/:id
 */
$app->put('/companies/:id', 'authenticate', function ($company_id) use($app) {
    // check for required params
    verifyRequiredParams(array('name', 'status'));
    global $user_id;
    $name = $app->request->put('name');
    $status = $app->request->put('status');
    $db = new DbHandler();
    $response = array();
    // updating company
    $result = $db->updateCompany($company_id, $name, $status);
    if ($result) {
        // company updated successfully
        $response["error"] = false;
        $response["message"] = "company updated successfully";
    } else {
        // company failed to update
        $response["error"] = true;
        $response["message"] = "company failed to update. Please try again!";
    }
    echoRespnse(200, $response);
});
Example #29
0
    $response = array();
    //
    $db = new DbHandler();
    $datos = $db->getAllRecord("call sp_sel_sip_organo( )");
    //var_dump($datos);
    if ($datos != NULL) {
        $response = $datos;
    } else {
        $response['status'] = "info";
        $response['message'] = 'No hay información';
    }
    echoResponse(200, $response);
});
// Opción para eliminar un registro de la tabla sip_organo
$app->get('/organoD/:id', 'sessionAlive', function ($id) use($app) {
    $response = array();
    //
    //
    $db = new DbHandler();
    $resId = $db->deleteRecord("call sp_del_sip_organo(?)", $id);
    if ($resId == 0) {
        $response['status'] = "success";
        $response['message'] = 'Datos eliminados';
    } else {
        if ($resId < 0) {
            $response['status'] = "error " . $resId;
            $response['message'] = 'No pudo eliminar los Datos';
        }
    }
    echoResponse(200, $response);
});
 public function getAll()
 {
     $dbHandler = new DbHandler();
     $allSubmissions = $dbHandler->getAll();
     return $allSubmissions;
 }