@ -12,6 +12,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\RequestStack;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;
use App\Service\HandleLocations;
use App\Service\HandleLocations;
use Doctrine\DBAL\Connection;
//use App\Utils\PageRender;
//use App\Utils\PageRender;
//use App\Utils\StringTools;
//use App\Utils\StringTools;
use App\Service\Auth;
use App\Service\Auth;
@ -36,6 +37,8 @@ class Locations extends AbstractController
RequestStack $requestStack,
RequestStack $requestStack,
Auth $auth,
Auth $auth,
HandleLocations $locations,
HandleLocations $locations,
ManagerRegistry $doctrine,
Connection $connection,
string $pageNum
string $pageNum
): Response {
): Response {
$result = $auth->status();
$result = $auth->status();
@ -43,6 +46,11 @@ class Locations extends AbstractController
$session = $requestStack->getSession();
$session = $requestStack->getSession();
$member = $session->get("member");
$member = $session->get("member");
$list = $locations->getLocationsPage($pageNum);
$list = $locations->getLocationsPage($pageNum);
//$search = $connection->fetchAllAssociative("SELECT * FROM searchlocations('agenda')");
//var_dump($search[0]["name"]);
return $this->render("back/locations.twig", [
return $this->render("back/locations.twig", [
"title" => "Bad Space | Locations",
"title" => "Bad Space | Locations",
"handle" => $member->getHandle(),
"handle" => $member->getHandle(),
@ -140,6 +148,86 @@ class Locations extends AbstractController
}
}
}
}
/**
* @Route("/den/locations/bulk-add", name="location-bulk-add")
*/
public function bulkAddLocation(
Request $request,
Auth $auth,
HandleLocations $locations,
ManagerRegistry $doctrine,
FileUploader $uploader
): Response {
$result = $auth->status();
if ($result["status"]) {
if ($request->getMethod() == "GET") {
return $this->render("back/locations.twig", [
"title" => "Bad Space | Locations | Bulk Add",
"mode" => "bulk-add"
]);
} else {
// do posting stuff
$token = $request->get("token");
$entityManager = $doctrine->getManager();
$notice = '';
if (!$this->isCsrfTokenValid("upload", $token)) {
$logger->info("CSRF failure");
return new Response(
"Operation not allowed",
Response::HTTP_BAD_REQUEST,
[
"content-type" => "text/plain",
]
);
}
//get file from post
$file = $request->files->get("myfile");
//grab extension
if (!empty($file)) {
$extention = substr(strrchr($file->getClientOriginalName(), "."), 1);
}
//check it out to make sure it's cool
if (
empty($file) ||
$extention != "csv"
) {
if (empty($file)) {
$notice = 'You didn\'t select a file, boss';
} elseif ($extention != "csv") {
$notice = "Only files of type .csv are accepted, slick. " . $extention;
}
return $this->render("back/locations.twig", [
"title" => "Bad Space | Locations | Add",
"notice" => $notice,
"mode" => "bulk-add"
]);
}
//if it's cool, send it to be processed
$response = $locations->addMultipleLocations($file, $result["id"]);
if ($response["status"]) {
$notice = "New locations added! Take a break.";
return $this->render("back/locations.twig", [
"title" => "Bad Space | Locations | Add",
"notice" => $response["message"],
"mode" => "bulk-add"
]);
} else {
return $this->render("back/locations.twig", [
"title" => "Bad Space | Locations | Add",
"notice" => $response["message"],
"mode" => "bulk-add"
]);
}
}
} else {
header("Location:/den");
return new Response("< html > < body > LOGGED IN< / body > < / html > ");
}
}
/**
/**
* @Route("/den/locations/edit/{uuid}", name="location-edit")
* @Route("/den/locations/edit/{uuid}", name="location-edit")
*/
*/