|
|
@@ -4,7 +4,6 @@ namespace Shop; |
|
|
|
use Psr\Http\Message\ResponseInterface as Response; |
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request; |
|
|
|
use Slim\Factory\AppFactory; |
|
|
|
use Shop\DB\DB; |
|
|
|
use Shop\DB\Client; |
|
|
|
use Shop\DB\Order_lines; |
|
|
|
use Shop\DB\Products; |
|
|
@@ -16,10 +15,17 @@ require __DIR__ . '/../vendor/autoload.php'; |
|
|
|
|
|
|
|
$app = AppFactory::create(); |
|
|
|
|
|
|
|
$loader = new \Twig\Loader\FilesystemLoader('../templates'); |
|
|
|
$twig = new \Twig\Environment($loader, ); |
|
|
|
|
|
|
|
$app->map(['GET', 'POST'], "/orders/{client}/create", function (Request $request, Response $response, array $args) { |
|
|
|
$db2 = new Client(); |
|
|
|
$client = $args['client']; |
|
|
|
$a = $db2->getClientName($client); |
|
|
|
global $twig; |
|
|
|
$template = $twig->load('clientcreate.html.twig'); |
|
|
|
$b = $template->render(); |
|
|
|
$response->getBody()->write($b); |
|
|
|
if ($request->getMethod() == "GET") { |
|
|
|
$response->getBody()->write("<h1>Create order for" . $a['firstname'] . " " . $a['lastname'] . "</h1><hr/>"); |
|
|
|
$response->getBody()->write('<form action="/orders/' . $args['client'] . '/create" method="post">'); |