db = $db; } /** * @Callback(table="tl_vr_wa_slot", target="list.sorting.child_record") */ public function onChildRecordCallback(array $row) { $Slot = WeinanlieferungSlotsModel::findByPk($row['id']); $arrSorten = []; $Sorten = StringUtil::deserialize($Slot->sorten,true); foreach($Sorten as $sorte) { $objSorte = WeinanlieferungRebsorteModel::findByPk($sorte['sorte']); $objLeseart = WeinanlieferungLeseartModel::findByPk($sorte['leseart']); $arrSorten[] = ($objSorte !== null ? $objSorte->title : '') . ' ' . ($objLeseart !== null ? $objLeseart->title : ''); } return sprintf('
%s %s
Buchbar ab
%s
Buchbar bis
%s
Behälterkapazität
%s
Sorten
%s
',Date::parse(Date::getNumericDateFormat(),$row['date']), Date::parse(Date::getNumericTimeFormat(),$row['time']),Date::parse(Date::getNumericDatimFormat(),$row['buchbar_ab']),Date::parse(Date::getNumericDatimFormat(),$row['buchbar_bis']),$Slot->behaelter,implode(', ',$arrSorten)); } /** * @Callback(table="tl_vr_wa_slot", target="fields.time.save", priority=1) */ public function checkAndAdjustTime($varValue, DataContainer $dc) { /** @var SlotChecker $slotchecker */ $slotchecker = System::getContainer()->get('vonrotenberg.wa.slot_checker'); // Return if there is no active record (override all) or no start date has been set yet if (!$dc->activeRecord || empty($dc->activeRecord->date)) { throw new \Exception($this->translator->trans('ERR.wa_slot_nodate', [], 'contao_tl_vr_wa_slot')); } $start = strtotime(date('Y-m-d', $dc->activeRecord->date) . ' ' . date('H:i:s', $varValue)); $duration = \intval(Input::post('duration')) !== null ? intval(Input::post('duration'))*60 : $dc->activeRecord->duration*60; // Todo: Introduce duration in a later update /*if ($slotchecker->checkTimeApplicableForSite($dc->activeRecord->pid,$start,$start+$duration,0,\intval($dc->id))) { throw new \Exception($this->translator->trans('ERR.wa_slot_conflict', [], 'contao_tl_vr_wa_slot')); }*/ return $start; } }