| ... | ... |
@@ -8,6 +8,7 @@ |
| 8 | 8 |
* @license commercial |
| 9 | 9 |
*/ |
| 10 | 10 |
|
| 11 |
+use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungRebsorteModel; |
|
| 11 | 12 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungSlotsModel; |
| 12 | 13 |
use vonRotenberg\WeinanlieferungBundle\Model\WeinanlieferungStandortModel; |
| 13 | 14 |
|
| ... | ... |
@@ -19,3 +20,4 @@ $GLOBALS['BE_MOD']['content']['weinanlieferung'] = array |
| 19 | 20 |
|
| 20 | 21 |
$GLOBALS['TL_MODELS']['tl_vr_wa_slot'] = WeinanlieferungSlotsModel::class; |
| 21 | 22 |
$GLOBALS['TL_MODELS']['tl_vr_wa_standort'] = WeinanlieferungStandortModel::class; |
| 23 |
+$GLOBALS['TL_MODELS']['tl_vr_wa_rebsorte'] = WeinanlieferungRebsorteModel::class; |
| ... | ... |
@@ -118,6 +118,8 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array |
| 118 | 118 |
'date' => array |
| 119 | 119 |
( |
| 120 | 120 |
'exclude' => true, |
| 121 |
+ 'filter' => true, |
|
| 122 |
+ 'flag' => DataContainer::SORT_MONTH_ASC, |
|
| 121 | 123 |
'inputType' => 'text', |
| 122 | 124 |
'eval' => array('rgxp' => 'date', 'mandatory' => true, 'datepicker' => true, 'tl_class' => 'w50 wizard'),
|
| 123 | 125 |
'sql' => "int(10) unsigned NULL" |
| ... | ... |
@@ -126,9 +128,8 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array |
| 126 | 128 |
( |
| 127 | 129 |
'exclude' => true, |
| 128 | 130 |
'default' => time(), |
| 129 |
- 'filter' => true, |
|
| 130 | 131 |
'sorting' => true, |
| 131 |
- 'flag' => DataContainer::SORT_MONTH_DESC, |
|
| 132 |
+ 'flag' => DataContainer::SORT_MONTH_ASC, |
|
| 132 | 133 |
'inputType' => 'text', |
| 133 | 134 |
'eval' => array('rgxp' => 'time', 'mandatory' => true, 'tl_class' => 'w50'),
|
| 134 | 135 |
'sql' => "int(10) NULL" |
| ... | ... |
@@ -163,7 +164,8 @@ $GLOBALS['TL_DCA']['tl_vr_wa_slot'] = array |
| 163 | 164 |
'inputType' => 'select', |
| 164 | 165 |
'foreignKey' => 'tl_vr_wa_rebsorte.title', |
| 165 | 166 |
'eval' => array('rgxp' => 'natural', 'mandatory' => false, 'multiple'=>true,'chosen'=>true,'includeBlankOption' => true, 'tl_class' => 'w50','csv'=>','),
|
| 166 |
- 'sql' => "blob NULL" |
|
| 167 |
+ 'sql' => "blob NULL", |
|
| 168 |
+ 'relation' => array('type' => 'hasMany', 'load' => 'lazy')
|
|
| 167 | 169 |
), |
| 168 | 170 |
'anmerkungen' => array |
| 169 | 171 |
( |
| 170 | 172 |
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|join(', ') }}</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> |
| 0 | 41 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,29 @@ |
| 1 |
+<div class="modal-content"> |
|
| 2 |
+ <div id="wa-unauthorized"> |
|
| 3 |
+ <h1>Unauthorized</h1> |
|
| 4 |
+ </div> |
|
| 5 |
+</div> |
|
| 6 |
+<script> |
|
| 7 |
+ |
|
| 8 |
+ (function ($) {
|
|
| 9 |
+ |
|
| 10 |
+ window.modals = window.modals || [] |
|
| 11 |
+ |
|
| 12 |
+ if (window.modals.wa_unauthorized === undefined) |
|
| 13 |
+ {
|
|
| 14 |
+ window.modals.wa_unauthorized = new jBox('Modal', {
|
|
| 15 |
+ closeButton: 'box', |
|
| 16 |
+ content: $('#wa-unauthorized'),
|
|
| 17 |
+ maxWidth: 650, |
|
| 18 |
+ minWidth: 100, |
|
| 19 |
+ minHeight: 100, |
|
| 20 |
+ width: 650, |
|
| 21 |
+ addClass: '' |
|
| 22 |
+ }).open(); |
|
| 23 |
+ } else {
|
|
| 24 |
+ window.modals.wa_unauthorized.content.empty(); |
|
| 25 |
+ window.modals.wa_unauthorized.setContent($('#wa-unauthorized')).open();
|
|
| 26 |
+ } |
|
| 27 |
+ |
|
| 28 |
+ })(jQuery); |
|
| 29 |
+</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,100 @@ |
| 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 (!$this->tokenChecker->hasFrontendUser()) |
|
| 46 |
+ {
|
|
| 47 |
+ return $this->renderUnauthorized(); |
|
| 48 |
+ } |
|
| 49 |
+ |
|
| 50 |
+ if (empty($_REQUEST['do'])) |
|
| 51 |
+ {
|
|
| 52 |
+ return new Response('Required parameter missing',412);
|
|
| 53 |
+ } |
|
| 54 |
+ |
|
| 55 |
+ switch ($_REQUEST['do']) |
|
| 56 |
+ {
|
|
| 57 |
+ case 'details': |
|
| 58 |
+ return $this->renderDetails(); |
|
| 59 |
+ break; |
|
| 60 |
+ } |
|
| 61 |
+ |
|
| 62 |
+ return new Response('',500);
|
|
| 63 |
+ return new Response(null,203); |
|
| 64 |
+ } |
|
| 65 |
+ |
|
| 66 |
+ protected function renderDetails() |
|
| 67 |
+ {
|
|
| 68 |
+ if (empty($_REQUEST['id'])) |
|
| 69 |
+ {
|
|
| 70 |
+ return new Response('Required parameter missing',412);
|
|
| 71 |
+ } |
|
| 72 |
+ |
|
| 73 |
+ if (($Slot = WeinanlieferungSlotsModel::findPublishedById($_REQUEST['id'])) === null) |
|
| 74 |
+ {
|
|
| 75 |
+ return new Response('Could not load slot data',500);
|
|
| 76 |
+ } |
|
| 77 |
+ |
|
| 78 |
+ $arrSorten = []; |
|
| 79 |
+ if (($Sorten = $Slot->getRelated('sorte')) !== null)
|
|
| 80 |
+ {
|
|
| 81 |
+ $arrSorten = $Sorten->fetchEach('title');
|
|
| 82 |
+ } |
|
| 83 |
+ |
|
| 84 |
+ $arrData = [ |
|
| 85 |
+ 'id' => $Slot->id, |
|
| 86 |
+ 'slot' => array_merge($Slot->row(),[ |
|
| 87 |
+ 'sorte' => $arrSorten |
|
| 88 |
+ ]), |
|
| 89 |
+ 'standort' => $Slot->getRelated('pid')
|
|
| 90 |
+ ]; |
|
| 91 |
+ |
|
| 92 |
+ return $this->render('@Contao/modal_slot_details.html.twig',$arrData);
|
|
| 93 |
+ } |
|
| 94 |
+ |
|
| 95 |
+ protected function renderUnauthorized() |
|
| 96 |
+ {
|
|
| 97 |
+ return $this->render('@Contao/modal_unauthorized.html.twig');
|
|
| 98 |
+ } |
|
| 99 |
+ |
|
| 100 |
+} |
| 0 | 101 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,24 @@ |
| 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\Model; |
|
| 14 |
+ |
|
| 15 |
+use Contao\Model; |
|
| 16 |
+ |
|
| 17 |
+class WeinanlieferungRebsorteModel extends Model |
|
| 18 |
+{
|
|
| 19 |
+ /** |
|
| 20 |
+ * Table name |
|
| 21 |
+ * @var string |
|
| 22 |
+ */ |
|
| 23 |
+ protected static $strTable = 'tl_vr_wa_rebsorte'; |
|
| 24 |
+} |
| ... | ... |
@@ -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(); |