| 0 | 4 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,40 @@ |
| 1 |
+<div class="modal-content"> |
|
| 2 |
+ <div id="wa-slot-{{ id }}">
|
|
| 3 |
+ <dl> |
|
| 4 |
+ <dt>Tag/Uhrzeit</dt> |
|
| 5 |
+ <dd>{{ slot.time|date('d.m.Y H:i') }}</dd>
|
|
| 6 |
+ |
|
| 7 |
+ <dt>Verfügbare Behälterkapazität</dt> |
|
| 8 |
+ <dd>{{ slot.behaelter }}</dd>
|
|
| 9 |
+ |
|
| 10 |
+ <dt>Verarbeitete Sorten</dt> |
|
| 11 |
+ <dd>{{ slot.sorte }}</dd>
|
|
| 12 |
+ </dl> |
|
| 13 |
+ |
|
| 14 |
+ </div> |
|
| 15 |
+</div> |
|
| 16 |
+<script> |
|
| 17 |
+ |
|
| 18 |
+ (function ($) {
|
|
| 19 |
+ |
|
| 20 |
+ window.modals = window.modals || [] |
|
| 21 |
+ window.modals.wa_slots = window.modals.wa_slots || [] |
|
| 22 |
+ |
|
| 23 |
+ if (window.modals.wa_slots.details{{ id }} === undefined)
|
|
| 24 |
+ {
|
|
| 25 |
+ window.modals.wa_slots.details{{ id }} = new jBox('Modal', {
|
|
| 26 |
+ closeButton: 'box', |
|
| 27 |
+ content: $('#wa-slot-{{ id }}'),
|
|
| 28 |
+ maxWidth: 650, |
|
| 29 |
+ minWidth: 100, |
|
| 30 |
+ minHeight: 100, |
|
| 31 |
+ width: 650, |
|
| 32 |
+ addClass: '' |
|
| 33 |
+ }).open(); |
|
| 34 |
+ } else {
|
|
| 35 |
+ window.modals.wa_slots.details{{ id }}.content.empty();
|
|
| 36 |
+ window.modals.wa_slots.details{{ id }}.setContent($('#wa-slot-{{ id }}')).open();
|
|
| 37 |
+ } |
|
| 38 |
+ |
|
| 39 |
+ })(jQuery); |
|
| 40 |
+</script> |
| ... | ... |
@@ -16,10 +16,16 @@ use Contao\CoreBundle\ContaoCoreBundle; |
| 16 | 16 |
use Contao\ManagerPlugin\Bundle\BundlePluginInterface; |
| 17 | 17 |
use Contao\ManagerPlugin\Bundle\Config\BundleConfig; |
| 18 | 18 |
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; |
| 19 |
+use Contao\ManagerPlugin\Routing\RoutingPluginInterface; |
|
| 20 |
+use Symfony\Component\Config\Loader\LoaderResolverInterface; |
|
| 21 |
+use Symfony\Component\HttpKernel\KernelInterface; |
|
| 19 | 22 |
use vonRotenberg\WeinanlieferungBundle\VonrotenbergWeinanlieferungBundle; |
| 20 | 23 |
|
| 21 |
-class Plugin implements BundlePluginInterface |
|
| 24 |
+class Plugin implements BundlePluginInterface, RoutingPluginInterface |
|
| 22 | 25 |
{
|
| 26 |
+ /** |
|
| 27 |
+ * {@inheritdoc}
|
|
| 28 |
+ */ |
|
| 23 | 29 |
public function getBundles(ParserInterface $parser): array |
| 24 | 30 |
{
|
| 25 | 31 |
return [ |
| ... | ... |
@@ -27,4 +33,13 @@ class Plugin implements BundlePluginInterface |
| 27 | 33 |
->setLoadAfter([ContaoCoreBundle::class]), |
| 28 | 34 |
]; |
| 29 | 35 |
} |
| 36 |
+ |
|
| 37 |
+ /** |
|
| 38 |
+ * {@inheritdoc}
|
|
| 39 |
+ */ |
|
| 40 |
+ public function getRouteCollection(LoaderResolverInterface $resolver, KernelInterface $kernel) |
|
| 41 |
+ {
|
|
| 42 |
+ $path = __DIR__.'/../../config/routing.yml'; |
|
| 43 |
+ return $resolver->resolve($path)->load($path); |
|
| 44 |
+ } |
|
| 30 | 45 |
} |
| 31 | 46 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,82 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+declare(strict_types=1); |
|
| 4 |
+ |
|
| 5 |
+/* |
|
| 6 |
+ * This file is part of contao-weinanlieferung-bundle. |
|
| 7 |
+ * |
|
| 8 |
+ * (c) vonRotenberg |
|
| 9 |
+ * |
|
| 10 |
+ * @license commercial |
|
| 11 |
+ */ |
|
| 12 |
+ |
|
| 13 |
+namespace vonRotenberg\WeinanlieferungBundle\Controller\Frontend\Ajax; |
|
| 14 |
+ |
|
| 15 |
+use Contao\CoreBundle\Controller\AbstractController; |
|
| 16 |
+use Contao\CoreBundle\Framework\ContaoFramework; |
|
| 17 |
+use Contao\CoreBundle\Security\Authentication\Token\TokenChecker; |
|
| 18 |
+use Contao\System; |
|
| 19 |
+use Symfony\Component\HttpFoundation\Request; |
|
| 20 |
+use Symfony\Component\HttpFoundation\Response; |
|
| 21 |
+use Symfony\Component\Routing\Annotation\Route; |
|
| 22 |
+use Symfony\Contracts\Translation\TranslatorInterface; |
|
| 23 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
|
| 24 |
+ |
|
| 25 |
+/** |
|
| 26 |
+ * @Route("/_ajax/vr_wa/v1/slot", name="vr_wa_slot_ajax", defaults={"_scope" = "frontend", "_token_check" = false})
|
|
| 27 |
+ */ |
|
| 28 |
+class SlotAjaxController extends AbstractController |
|
| 29 |
+{
|
|
| 30 |
+ private $tokenChecker; |
|
| 31 |
+ private $translator; |
|
| 32 |
+ private $framework; |
|
| 33 |
+ |
|
| 34 |
+ public function __construct(ContaoFramework $framework, TokenChecker $tokenChecker, TranslatorInterface $translator) |
|
| 35 |
+ {
|
|
| 36 |
+ $this->framework = $framework; |
|
| 37 |
+ $this->tokenChecker = $tokenChecker; |
|
| 38 |
+ $this->translator = $translator; |
|
| 39 |
+ } |
|
| 40 |
+ |
|
| 41 |
+ public function __invoke(Request $request) |
|
| 42 |
+ {
|
|
| 43 |
+ System::loadLanguageFile('default');
|
|
| 44 |
+ |
|
| 45 |
+ if (empty($_REQUEST['do'])) |
|
| 46 |
+ {
|
|
| 47 |
+ return new Response('Required parameter missing',412);
|
|
| 48 |
+ } |
|
| 49 |
+ |
|
| 50 |
+ switch ($_REQUEST['do']) |
|
| 51 |
+ {
|
|
| 52 |
+ case 'details': |
|
| 53 |
+ return $this->renderDetails(); |
|
| 54 |
+ break; |
|
| 55 |
+ } |
|
| 56 |
+ |
|
| 57 |
+ return new Response('',500);
|
|
| 58 |
+ return new Response(null,203); |
|
| 59 |
+ } |
|
| 60 |
+ |
|
| 61 |
+ protected function renderDetails() |
|
| 62 |
+ {
|
|
| 63 |
+ if (empty($_REQUEST['id'])) |
|
| 64 |
+ {
|
|
| 65 |
+ return new Response('Required parameter missing',412);
|
|
| 66 |
+ } |
|
| 67 |
+ |
|
| 68 |
+ if (($Slot = WeinanlieferungSlotsModel::findPublishedById($_REQUEST['id'])) === null) |
|
| 69 |
+ {
|
|
| 70 |
+ return new Response('Could not load slot data',500);
|
|
| 71 |
+ } |
|
| 72 |
+ |
|
| 73 |
+ $arrData = [ |
|
| 74 |
+ 'id' => $Slot->id, |
|
| 75 |
+ 'slot' => $Slot->row(), |
|
| 76 |
+ 'standort' => $Slot->getRelated('pid')
|
|
| 77 |
+ ]; |
|
| 78 |
+ |
|
| 79 |
+ return $this->render('@Contao/modal_slot_details.html.twig',$arrData);
|
|
| 80 |
+ } |
|
| 81 |
+ |
|
| 82 |
+} |
| ... | ... |
@@ -24,6 +24,25 @@ class WeinanlieferungSlotsModel extends Model |
| 24 | 24 |
*/ |
| 25 | 25 |
protected static $strTable = 'tl_vr_wa_slot'; |
| 26 | 26 |
|
| 27 |
+ public static function findPublishedById($intId, array $arrOptions=array()) |
|
| 28 |
+ {
|
|
| 29 |
+ $time = time(); |
|
| 30 |
+ $t = static::$strTable; |
|
| 31 |
+ $arrColumns = array("$t.id=?");
|
|
| 32 |
+ |
|
| 33 |
+ // Skip unsaved elements (see #2708) |
|
| 34 |
+ $arrColumns[] = "$t.tstamp!=0"; |
|
| 35 |
+ |
|
| 36 |
+ $arrColumns[] = "$t.buchbar='1' AND $t.buchbar_bis>$time"; |
|
| 37 |
+ |
|
| 38 |
+ if (!isset($arrOptions['order'])) |
|
| 39 |
+ {
|
|
| 40 |
+ $arrOptions['order'] = "$t.time ASC"; |
|
| 41 |
+ } |
|
| 42 |
+ |
|
| 43 |
+ return static::findBy($arrColumns, $intId, $arrOptions); |
|
| 44 |
+ } |
|
| 45 |
+ |
|
| 27 | 46 |
public static function findPublishedByPid($intPid, array $arrOptions=array()) |
| 28 | 47 |
{
|
| 29 | 48 |
$time = time(); |