|
|
@@ -33,33 +33,7 @@ $container->set( |
|
|
|
|
|
|
|
|
|
|
|
$app->get("/orders/{client}/create", \Shop\Controller\ClientCreate::class . ':createGet'); |
|
|
|
|
|
|
|
// $app->map(['GET', 'POST'], "/orders/{client}/create", function (Request $request, Response $response, array $args) { |
|
|
|
// if ($request->getMethod() == "GET") { |
|
|
|
// // $db2 = new myDB(); |
|
|
|
// // $stmt2 = $db2->prepare("SELECT * FROM clients WHERE id = " . $args['client']); |
|
|
|
// // $res2 = $stmt2->execute(); |
|
|
|
// // $a = $res2->fetchArray(SQLITE3_ASSOC); |
|
|
|
// $db2 = new Order($this->container); |
|
|
|
// $res2 = $db2->getClient($args['client']); |
|
|
|
// $a = $res2->fetchArray(SQLITE3_ASSOC); |
|
|
|
|
|
|
|
// $response->getBody()->write("<h1>Create order for" . $a['firstname'] . " " . $a['lastname'] . "</h1><hr/>"); |
|
|
|
// $response->getBody()->write('<form action="/orders/' . $args['client'] . '/create" method="post">'); |
|
|
|
// $response->getBody()->write('<label for="id">Reference: </label>'); |
|
|
|
// $response->getBody()->write('<input type="text" name="reference">'); |
|
|
|
// $response->getBody()->write('<input type="submit">'); |
|
|
|
// $response->getBody()->write('</form>'); |
|
|
|
|
|
|
|
// return $response; |
|
|
|
// } else { |
|
|
|
// $ref = $request->getParsedBody()['reference']; |
|
|
|
// $db2 = new myDB(); |
|
|
|
// $sql = "insert into orders (reference, customer_id, vat, subtotal, total) values ('" . $ref . "', " . $args['client'] . ",0,0,0)"; |
|
|
|
// $db2->exec($sql); |
|
|
|
// return $response->withHeader('Location', '/orders/' . $args['client']); |
|
|
|
// }; |
|
|
|
// }); |
|
|
|
$app->post("/orders/{client}/create", \Shop\Controller\ClientCreate::class . ':createPost'); |
|
|
|
|
|
|
|
// Route with optional params, see https://www.slimframework.com/docs/v4/objects/routing.html#how-to-create-routes section Optional segments |
|
|
|
$app->get('/orders[/{client}]', function (Request $request, Response $response, array $args) { |