Exemple #1
0
     }
     break;
 case "insert_note":
     if ($_SESSION['user']['type'] == ADMIN || $_SESSION['user']['type'] == SUPERADMIN) {
         $note = new Notes($db);
         $data['note']['id_admin'] = $_SESSION['user']['id'];
         $result = $note->insertNote($data['note']);
         if ($result->resultado) {
             echo 'ok';
         }
     }
     break;
 case "update_note":
     if ($_SESSION['user']['type'] == ADMIN || $_SESSION['user']['type'] == SUPERADMIN) {
         $note = new Notes($db);
         $result = $note->updateNote($data['note'], $data['id']);
         if ($result->resultado) {
             echo 'ok';
         }
     }
     break;
 case "delete_note":
     if ($_SESSION['user']['type'] == ADMIN || $_SESSION['user']['type'] == SUPERADMIN) {
         $note = new Notes($db);
         $result = $note->delete($data['id']);
         if ($result->resultado) {
             echo 'ok';
         }
     }
     break;
 case "insert_cita":
Exemple #2
0
        $response->json(Result::error('Note Creation Failed.'));
    }
});
$this->respond(['GET', 'POST'], '/get/[i:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Notes::getNote($id);
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('Note not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body());
    $result = Notes::updateNote($id, $data);
    if ($result > 0) {
        $response->json(Result::success('Note Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('Note not Updated.'));
    } else {
        $response->json(Result::error('Note not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = Notes::deleteNote($id);
    if ($result > 0) {
        $response->json(Result::success('Note Deleted.'));
    } else {
        $response->json(Result::error('Note not Deleted'));