|
|
@@ -1,10 +1,13 @@ |
|
|
|
<?php |
|
|
|
namespace Store; |
|
|
|
namespace Shop; |
|
|
|
|
|
|
|
use Psr\Http\Message\ResponseInterface as Response; |
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request; |
|
|
|
use Slim\Factory\AppFactory; |
|
|
|
use Store\DB\DB; |
|
|
|
use Shop\DB\Client; |
|
|
|
use Shop\DB\DB; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
require __DIR__ . '/../vendor/autoload.php'; |
|
|
|
|
|
|
@@ -13,7 +16,7 @@ require __DIR__ . '/../vendor/autoload.php'; |
|
|
|
$app = AppFactory::create(); |
|
|
|
|
|
|
|
$app->map(['GET', 'POST'], "/orders/{client}/create", function (Request $request, Response $response, array $args) { |
|
|
|
$db2 = new DB(); |
|
|
|
$db2 = new Client(); |
|
|
|
$client = $args['client']; |
|
|
|
$a = $db2->getClientInfo($client); |
|
|
|
if ($request->getMethod() == "GET") { |
|
|
@@ -26,10 +29,10 @@ $app->map(['GET', 'POST'], "/orders/{client}/create", function (Request $request |
|
|
|
|
|
|
|
return $response; |
|
|
|
} else { |
|
|
|
$db2 = new Client(); |
|
|
|
$ref = $request->getParsedBody()['reference']; |
|
|
|
$db2 = new DB(); |
|
|
|
$sql = "insert into orders (reference, customer_id, vat, subtotal, total) values ('" . $ref . "', " . $args['client'] . ",0,0,0)"; |
|
|
|
$db2->exec($sql); |
|
|
|
$client = $args['client']; |
|
|
|
$db2->getClientInfo($client, $ref); |
|
|
|
return $response->withHeader('Location', '/orders/' . $args['client']); |
|
|
|
}; |
|
|
|
}); |