require '.././libs/Slim/Slim.php';
require_once 'dbHelper.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app = \Slim\Slim::getInstance();
$db = new dbHelper();
$app->get('/products', function () {
    global $db;
    $rows = $db->select("products", "id,sku,name,description,price,mrp,stock,image,packing,status", array());
    echoResponse(200, $rows);
});
$app->post('/products', function () use($app) {
    $data = json_decode($app->request->getBody());
    $mandatory = array('name');
    global $db;
    $rows = $db->insert("products", $data, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product added successfully.";
    }
    echoResponse(200, $rows);
});
$app->put('/products/:id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('id' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("products", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product information updated successfully.";
    }
    echoResponse(200, $rows);
 $article = new stdClass();
 $article->code_barre = $product->code_barre;
 $article->nom = $product->nom;
 $article->description_f = $product->description_f;
 $article->mark = $product->mark;
 $article->type_article = $product->type_article;
 $article->price = $product->price;
 $article->vat = $product->vat;
 $article->unite = $product->unite;
 $article->id_family = $product->id_family;
 $article->quantite = 0;
 $article->status = "Active";
 $article->id_service = 15;
 // Rva Service
 $article->dt_creation = date("Y-m-d H:i:s");
 $rows = $db->insert("gestion_article", $article, $mandatory);
 $lastInsertId = $rows['data'];
 array_push($results, $rows);
 // Insert SUPPLIER Stock
 $stockSupplier = new stdClass();
 $stockSupplier->id_article = $lastInsertId;
 $stockSupplier->id_location = $product->id_supplier;
 $stockSupplier->type_stock = "SUPPLIER";
 $stockSupplier->prix_current = $product->price;
 $stockSupplier->dt_creation = date("Y-m-d H:i");
 $stockSupplier->status = 'Active';
 $stockSupplier->stock_min = 0;
 $stockSupplier->stock_alert = 0;
 $stockSupplier->quantite_current = 0;
 $stockSupplier->id_service = 15;
 // Rva Service
示例#3
0
         $ir->ModelState->ErrorMessage = array("Invalid FullName.");
     } elseif (strpos($userusername, "<") !== false && strpos($userusername, ">") !== false) {
         $ir = new InvalidRequest();
         $ir->ModelState->ErrorCode = array("9");
         $ir->ModelState->ErrorMessage = array("Invalid UserName.");
     }
     if ($ir !== null) {
         echoResponse(400, array($ir));
     } else {
         $user = new user();
         $user->username = $userusername;
         $user->password = passwordHash::hash($userpassword);
         $user->fullname = $userfullname;
         $user->email = $useremail;
         $mandatory = array('username', 'password', 'fullname', 'email');
         $rows = $db->insert("users", $user, $mandatory);
         if ($rows["status"] == "success") {
             $rows["message"] = "";
             $app->setCookie('.AspNet.ApplicationCookie', sha1('cookie'));
             echoResponse(200, $rows);
         } else {
             echoResponse(400, $rows);
         }
     }
 } catch (Exception $e) {
     $ir = new InvalidRequest();
     $ir->ModelState->ErrorCode = array("11");
     $ir->ModelState->ErrorMessage = array($e->getMessage());
     error_log($e->getMessage());
     echoResponse(500, array($ir));
 }
示例#4
0
function verifnbInscrit($idRDV)
{
    global $db;
    $rows = $db->selectEquals("nbInscription", "idAgenda,idRDV,DateDebut,DateFin,nbInscrits,inscriptionMax", array('idRDV' => $idRDV));
    return $rows["data"][0];
}
$app->get('/rendez_vousD/:DateDebut', function ($DateDebut) {
    global $db;
    $rows = $db->selectEquals("rendez_vous", "idRDV,DateDebut,DateFin,idAgenda", array('DateDebut' => $DateDebut));
    echoResponse(200, $rows);
});
$app->post('/agendas', function () use($app) {
    $data = json_decode($app->request->getBody());
    $mandatory = array('libAgenda', 'mail', 'nbJourOuverture', 'nbJourLimite', 'nbJourReins', 'inscriptionMax', 'dateCreation');
    global $db;
    $rows = $db->insert("agenda", $data, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Agenda crée !";
    }
    echoResponse(200, $rows);
});
$app->post('/ajoutInscription', function () use($app) {
    $data = json_decode($app->request->getBody());
    $mandatory = array('mail', 'idRDV');
    $nbInscription = verifnbInscrit($data->idRDV);
    if ($nbInscription["nbInscrits"] < $nbInscription["inscriptionMax"]) {
        global $db;
        $rows = $db->insert("inscription", $data, $mandatory);
        if ($rows["status"] == "success") {
            $rows["message"] = "Inscription ajoutée !";
        } else {
示例#5
0
文件: index.php 项目: rvyasg821/test
select(table name, where clause as associative array)
insert(table name, data as associative array, mandatory column names as array)
update(table name, column names as associative array, where clause as associative array, required columns as array)
delete(table name, where clause as array)
*/
// Companies
$app->get('/companies', function () {
    global $db;
    $rows = $db->select("companies", "CompanyID,Name,Address,City,Country,Email,Phone,status,Directors", array());
    echoResponse(200, $rows);
});
$app->post('/companies', function () use($app) {
    $data = json_decode($app->request->getBody());
    $mandatory = array('Name', 'Address', 'City', 'Country');
    global $db;
    $rows = $db->insert("companies", $data, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Company added successfully.";
    }
    echoResponse(200, $rows);
});
$app->put('/companies/:id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('CompanyID' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("companies", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Company information updated successfully.";
    }
    echoResponse(200, $rows);
示例#6
0
/*
select(table name, where clause as associative array)
insert(table name, data as associative array, mandatory column names as array)
update(table name, column names as associative array, where clause as associative array, required columns as array)
delete(table name, where clause as array)
*/
$app->get('/bolas', function () {
    global $db;
    $rows = $db->select("bolas", "*", array());
    echoResponse(200, $rows);
});
$app->post('/bolas', function () use($app) {
    $data = json_decode($app->request->getBody());
    $mandatory = array('code');
    global $db;
    $rows = $db->insert("bolas", $data, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product added successfully.";
    }
    echoResponse(200, $rows);
});
$app->put('/bolas/:id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('id' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("bolas", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product information updated successfully.";
    }
    echoResponse(200, $rows);
示例#7
0
文件: index.php 项目: jspautsch/Soku
             // If not, does THIS player have enough peices?
             if (hasOvertimePieces($game['turn'], $game['overtime'], array(), $piece)) {
                 // if yes, repeat player's turn
                 $nextPlayer = $game['turn'];
             } else {
                 // if not, call a draw
                 $newStatus = 'draw';
             }
         }
     }
 }
 // Update database
 try {
     $db->startTransaction();
     // insert played piece
     $db->insert("played", $newPieces);
     // are we in overtime? remove from overtime bin
     if ($game['status'] === 'overtime') {
         $db->deleteWhere("overtime", "id='" . $piece . "' AND player='" . $game['turn'] . "'");
     }
     if (sizeof($newLockouts) > 0) {
         // insert lockouts
         $db->insert("lockouts", $newLockouts);
         if ($jumpedPieces) {
             // delete jumped pieces
             $db->deleteIn("played", "tile", $jumpedPieces['tiles']);
             // delete lockouts from jumped pieces
             $db->deleteWhereAll("lockouts", array('fromTile', 'toTile'), $jumpedPieces['tiles'], "OR");
             // add jumped pieces to overtime bins
             $db->insert("overtime", $overtimePieces);
         }
示例#8
0
include_once './libs/Slim/Slim.php';
require_once './classes/dbHelper.php';
$app = new Slim();
$db = new dbHelper();
$app->get('/getperguntas/:idpalestra', function ($idpalestra) use($app) {
    global $db;
    $stmt = $db->selectperguntas("perguntaspalestras", "id,pergunta,nomeusuario", " idpalestra = '{$idpalestra}'");
    echo json_encode($stmt);
});
$app->post('/avaliarpalestra', function () use($app) {
    global $db;
    $idpalestra = "palestra01";
    $nota = 3;
    $email = "*****@*****.**";
    $db->insert("avaliacao", array("idpalestra" => $idpalestra, "email" => $email, "nota" => $nota));
});
$app->post('/cadastrapergunta', function () use($app) {
    global $db;
    $postvalores = $app->request()->post();
    $idpalestra = $postvalores['idpalestra'];
    $pergunta = $postvalores['pergunta'];
    $nomeusuario = $postvalores['nomeusuario'];
    $db->insert("perguntaspalestras", array("idpalestra" => $idpalestra, "pergunta" => $pergunta, "nomeusuario" => $nomeusuario));
});
$app->get('/', function () use($app) {
    $app->render('home.php');
});
$app->get('/iframe', function () use($app) {
    $app->render('iframe.php');
});
示例#9
0
select(table name, where clause as associative array)
insert(table name, data as associative array, mandatory column names as array)
update(table name, column names as associative array, where clause as associative array, required columns as array)
delete(table name, where clause as array)
*/
// Products
$app->get('/products', function () {
    global $db;
    $rows = $db->select("inventory", "id,environment,application,component,server_name,server_description,status,connectivity,server_ip_ctl,server_ip_nab,description,version,url", array());
    echoResponse(200, $rows);
});
$app->post('/products', function () use($app) {
    $data = json_decode($app->request->getBody());
    //    $mandatory = array('name');
    global $db;
    $rows = $db->insert("inventory", $data, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product added successfully.";
    }
    echoResponse(200, $rows);
});
$app->put('/products/:id', function ($id) use($app) {
    $data = json_decode($app->request->getBody());
    $condition = array('id' => $id);
    $mandatory = array();
    global $db;
    $rows = $db->update("inventory", $data, $condition, $mandatory);
    if ($rows["status"] == "success") {
        $rows["message"] = "Product information updated successfully.";
    }
    echoResponse(200, $rows);