/** * Method to get a JDatabaseQuery object for retrieving the data set from a database. * * @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set. */ public function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery('true'); $curdate = MatukioHelperUtilsDate::getCurrentDate(); // Spaces: event = e, cc = category, u = checkout $query->select('r.*, e.title as eventname, e.id as eventid, e.maxpupil, e.stopbooking, e.catid')->from('#__matukio_recurring AS r')->leftJoin("#__matukio AS e ON e.id = r.event_id"); // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { $searchfields = array('r.semnum', 'r.begin', 'r.end', 'e.title'); if (stripos($search, 'id:') === 0) { $query->where('r.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where(implode(" LIKE " . $search . " OR ", $searchfields) . " LIKE " . $search); } } $status = $this->getState('filter.status'); if (!empty($status)) { switch ($status) { case "published": $query->where("r.published = '1'"); break; case "unpublished": $query->where("r.published = '0'"); break; case "current": $query->where("r.end > " . $db->quote($curdate)); break; case "old": $query->where("r.end <= " . $db->quote($curdate)); break; case "all": break; } } else { $this->setState('filter.status', 'current'); $query->where("r.end > " . $db->quote($curdate)); } $category = $this->getState('filter.categories'); if (!empty($category)) { $query->where($db->qn('e.catid') . ' = ' . $db->q($category)); } $realevent = $this->getState('filter.events'); if (!empty($realevent)) { $query->where($db->qn('r.event_id') . ' = ' . $db->q($realevent)); } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); $query->order($db->escape($orderCol . ' ' . $orderDirn)); return $query; }
/** * Method to get a JDatabaseQuery object for retrieving the data set from a database. * * @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set. */ public function getListQuery() { $db = JFactory::getDbo(); $query = $db->getQuery('true'); $curdate = MatukioHelperUtilsDate::getCurrentDate(); // Spaces: event = e, cc = category, u = checkout $query->select('e.*, cc.title AS category, u.name AS editor')->from('#__matukio AS e')->leftJoin("#__categories AS cc ON cc.id = e.catid")->leftJoin("#__users AS u ON u.id = e.checked_out"); // Filter by search in title $search = $this->getState('filter.search'); if (!empty($search)) { $searchfields = array('e.title', 'e.semnum', 'e.begin', 'e.end', 'e.target', 'e.teacher', 'e.fees', 'e.shortdesc', 'e.catid', 'e.place', 'e.zusatz1', 'e.gmaploc', 'e.zusatz2', 'e.description'); if (stripos($search, 'id:') === 0) { $query->where('e.id = ' . (int) substr($search, 3)); } else { $search = $db->Quote('%' . $db->escape($search, true) . '%'); $query->where(implode(" LIKE " . $search . " OR ", $searchfields) . " LIKE " . $search); } } $status = $this->getState('filter.status'); if (!empty($status)) { switch ($status) { case "published": $query->where("e.published = '1'"); break; case "unpublished": $query->where("e.published = '0'"); break; case "current": $query->where("e.end > " . $db->quote($curdate)); break; case "old": $query->where("e.end <= " . $db->quote($curdate)); break; case "all": break; } } else { $this->setState('filter.status', 'current'); $query->where("e.end > " . $db->quote($curdate)); } $category = $this->getState('filter.categories'); if (!empty($category)) { $query->where('e.catid = ' . $db->q($category)); } // Add the list ordering clause. $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); $query->order($db->escape($orderCol . ' ' . $orderDirn)); return $query; }
/** * Displays the raw calendar file * * @param string $tpl - The template * * @return mixed|void */ public function display($tpl = null) { if (MatukioHelperSettings::getSettings('frontend_usericsdownload', 1) == 0) { JError::raiseError(403, JText::_("ALERTNOTAUTH")); return; } $cid = JFactory::getApplication()->input->getInt('cid', 0); $events = array(); if (!empty($cid)) { // Just one event $model = JModelLegacy::getInstance('Event', 'MatukioModel'); $event = $model->getItem($cid); $events[] = $event; } else { $database = JFactory::getDBO(); $neudatum = MatukioHelperUtilsDate::getCurrentDate(); // ICS File with all Events $where = array(); $database->setQuery("SELECT id, access FROM #__categories WHERE extension = '" . JFactory::getApplication()->input->get('option') . "'"); $cats = $database->loadObjectList(); $allowedcat = array(); foreach ($cats as $cat) { if ($cat->access < 1) { $allowedcat[] = $cat->id; } } if (count($allowedcat) > 0) { $allowedcat = implode(',', $allowedcat); $where[] = "a.catid IN (" . $allowedcat . ")"; } $where[] = "a.published = '1'"; $where[] = "a.end > '{$neudatum}'"; $where[] = "a.booked > '{$neudatum}'"; $database->setQuery("SELECT a.*, r.*, cat.title AS category FROM #__matukio_recurring AS r\r\n\t\t\t LEFT JOIN #__matukio AS a ON r.event_id = a.id\r\n\t\t\t LEFT JOIN #__categories AS cat ON cat.id = a.catid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY r.begin DESC" . "\nLIMIT 0, 1000"); $events = $database->loadObjectList(); } $this->events = $events; parent::display($tpl); }
* @author Yves Hoppe <*****@*****.**> * @date 11.11.13 * * @copyright Copyright (C) 2008 - 2013 Yves Hoppe - compojoom.com . All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ /** * art 0 = display normal event list (not logged in user) * art 1 = my Bookings * art 2 = my Offers */ defined('_JEXEC') or die('Restricted access'); $document = JFactory::getDocument(); $database = JFactory::getDBO(); $user = JFactory::getuser(); $current_date = MatukioHelperUtilsDate::getCurrentDate(); $confusers = JComponentHelper::getParams('com_users'); JHTML::_('stylesheet', 'media/com_matukio/css/matukio.css'); JHTML::_('stylesheet', 'media/com_matukio/css/modern.css'); JHTML::_('script', 'media/com_matukio/js/matukio.js'); JHTML::_('stylesheet', 'media/com_matukio/css/strapper.css'); if (JVERSION > 3) { JHTML::_('bootstrap.tooltip'); JHtml::_('formbehavior.chosen', 'select'); JHTML::_('behavior.modal'); } else { JHTML::_('behavior.tooltip'); JHTML::_('behavior.modal'); } JHTML::_('behavior.multiselect'); ?>
public static function saveEvent($frontend = false) { $database = JFactory::getDBO(); $input = JFactory::getApplication()->input; $caid = $input->getInt('caid', 0); $cancel = $input->getInt('cancel', 0); $deldatei1 = $input->get('deldatei1', 0); $deldatei2 = $input->get('deldatei2', 0); $deldatei3 = $input->get('deldatei3', 0); $deldatei4 = $input->get('deldatei4', 0); $deldatei5 = $input->get('deldatei5', 0); $vorlage = $input->getInt('vorlage', 0, 'string'); $id = $input->getInt('id', 0); $art = $input->getInt('art', 2); $neudatum = MatukioHelperUtilsDate::getCurrentDate(); $recurring = $input->getInt("recurring", 0); $isNew = true; JPluginHelper::importPlugin('content'); $dispatcher = JDispatcher::getInstance(); // Zeit formatieren $_begin_date = $input->get('_begin_date', '0000-00-00', 'string'); $_end_date = $input->get('_end_date', '0000-00-00', 'string'); $_booked_date = $input->get('_booked_date', '0000-00-00', 'string'); if ($id > 0) { $kurs = JTable::getInstance('Matukio', 'Table'); $kurs->load($id); $isNew = false; } if ($vorlage > 0) { $kurs = JTable::getInstance('Matukio', 'Table'); $kurs->load($vorlage); } $post = JRequest::get('post'); // Allow HTML for certain fields $post['description'] = JRequest::getVar('description', '', 'post', 'html', JREQUEST_ALLOWHTML); $post['booking_mail'] = JRequest::getVar('booking_mail', '', 'post', 'html', JREQUEST_ALLOWHTML); $post['certificate_code'] = JRequest::getVar('certificate_code', '', 'post', 'html', JREQUEST_ALLOWHTML); $post['shortdesc'] = JRequest::getVar('shortdesc', '', 'post', 'html', JREQUEST_ALLOWHTML); $post['place'] = JRequest::getVar('place', '', 'post', 'html', JREQUEST_ALLOWHTML); $row = JTable::getInstance('Matukio', 'Table'); $row->load($id); if (!$row->bind($post)) { throw new Exception($row->getError(), 42); } // Zuweisung der aktuellen Zeit if ($id == 0) { $row->publishdate = $neudatum; } $row->updated = $neudatum; if ($cancel != $row->cancelled && MatukioHelperSettings::_("notify_participants_cancel", 1)) { $tempmail = 9 + $cancel; $events = MatukioHelperUtilsEvents::getEventsRecurringOnEventId($row->id); foreach ($events as $e) { $database->setQuery("SELECT * FROM #__matukio_bookings WHERE semid='{$e->id}'"); $rows = $database->loadObjectList(); for ($i = 0, $n = count($rows); $i < $n; $i++) { MatukioHelperUtilsEvents::sendBookingConfirmationMail($e, $rows[$i]->id, $tempmail); } } } $row->cancelled = $cancel; $row->catid = $caid; // Zuweisung der Startzeit $row->begin = JFactory::getDate($_begin_date, MatukioHelperUtilsBasic::getTimeZone())->format('Y-m-d H:i:s', false, false); // Zuweisung der Endzeit $row->end = JFactory::getDate($_end_date, MatukioHelperUtilsBasic::getTimeZone())->format('Y-m-d H:i:s', false, false); // Zuweisung der Buchungszeit $row->booked = JFactory::getDate($_booked_date, MatukioHelperUtilsBasic::getTimeZone())->format('Y-m-d H:i:s', false, false); // Neue Daten eintragen $row->description = str_replace('<br>', '<br />', $row->description); $row->description = str_replace('\\"', '"', $row->description); $row->description = str_replace("'", "'", $row->description); $row->fees = str_replace(",", ".", $row->fees); $row->different_fees_override = ""; $different_fees_override = $input->get("different_fees_override", array(), 'Array'); if (count($different_fees_override)) { // Check if element 0 is not empty if (!empty($different_fees_override[0]["title"])) { $row->different_fees_override = json_encode($different_fees_override); } } if ($row->id > 0 or $vorlage > 0) { if ($deldatei1 != 1) { $row->file1 = $kurs->file1; $row->file1code = $kurs->file1code; } if ($deldatei2 != 1) { $row->file2 = $kurs->file2; $row->file2code = $kurs->file2code; } if ($deldatei3 != 1) { $row->file3 = $kurs->file3; $row->file3code = $kurs->file3code; } if ($deldatei4 != 1) { $row->file4 = $kurs->file4; $row->file4code = $kurs->file4code; } if ($deldatei5 != 1) { $row->file5 = $kurs->file5; $row->file5code = $kurs->file5code; } } if ($row->id > 0) { $row->hits = $kurs->hits; } $fileext = explode(' ', strtolower(MatukioHelperSettings::getSettings('file_endings', 'txt zip pdf'))); $filesize = MatukioHelperSettings::getSettings('file_maxsize', 500) * 1024; $fehler = array('', '', '', '', '', '', '', '', '', ''); if (!empty($_FILES['datei1'])) { if (is_file($_FILES['datei1']['tmp_name']) and $_FILES['datei1']['size'] > 0) { if ($_FILES['datei1']['size'] > $filesize) { $fehler[0] = str_replace("SEM_FILE", $_FILES['datei1']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_MAX_SIZE')); } $datei1ext = array_pop(explode(".", strtolower($_FILES['datei1']['name']))); if (!in_array($datei1ext, $fileext)) { $fehler[1] = str_replace("SEM_FILE", $_FILES['datei1']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_FILE_TYPE')); } if ($fehler[0] == "" and $fehler[1] == "") { if ($deldatei1 != 1) { $row->file1 = $_FILES['datei1']['name']; $row->file1code = base64_encode(file_get_contents($_FILES['datei1']['tmp_name'])); } else { $row->file1 = ""; $row->file1code = ""; } } } } else { // Delete file if ($deldatei1 == 1) { $row->file1 = ""; $row->file1code = ""; } } if (!empty($_FILES['datei2'])) { if (is_file($_FILES['datei2']['tmp_name']) and $_FILES['datei2']['size'] > 0) { if ($_FILES['datei2']['size'] > $filesize) { $fehler[2] = str_replace("SEM_FILE", $_FILES['datei2']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_MAX_SIZE')); } $datei2ext = array_pop(explode(".", strtolower($_FILES['datei2']['name']))); if (!in_array($datei2ext, $fileext)) { $fehler[3] = str_replace("SEM_FILE", $_FILES['datei2']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_FILE_TYPE')); } if ($fehler[2] == "" and $fehler[3] == "") { $row->file2 = $_FILES['datei2']['name']; $row->file2code = base64_encode(file_get_contents($_FILES['datei2']['tmp_name'])); } } } else { // Delete file if ($deldatei2 == 1) { $row->file2 = ""; $row->file2code = ""; } } if (!empty($_FILES['datei3'])) { if (is_file($_FILES['datei3']['tmp_name']) and $_FILES['datei3']['size'] > 0) { if ($_FILES['datei3']['size'] > $filesize) { $fehler[4] = str_replace("SEM_FILE", $_FILES['datei3']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_MAX_SIZE')); } $datei3ext = array_pop(explode(".", strtolower($_FILES['datei3']['name']))); if (!in_array($datei3ext, $fileext)) { $fehler[5] = str_replace("SEM_FILE", $_FILES['datei3']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_FILE_TYPE')); } if ($fehler[4] == "" and $fehler[5] == "") { $row->file3 = $_FILES['datei3']['name']; $row->file3code = base64_encode(file_get_contents($_FILES['datei3']['tmp_name'])); } } } else { // Delete file if ($deldatei3 == 1) { $row->file3 = ""; $row->file3code = ""; } } if (!empty($_FILES['datei4'])) { if (is_file($_FILES['datei4']['tmp_name']) and $_FILES['datei4']['size'] > 0) { if ($_FILES['datei4']['size'] > $filesize) { $fehler[6] = str_replace("SEM_FILE", $_FILES['datei4']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_MAX_SIZE')); } $datei4ext = array_pop(explode(".", strtolower($_FILES['datei4']['name']))); if (!in_array($datei4ext, $fileext)) { $fehler[7] = str_replace("SEM_FILE", $_FILES['datei4']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_FILE_TYPE')); } if ($fehler[6] == "" and $fehler[7] == "") { $row->file4 = $_FILES['datei4']['name']; $row->file4code = base64_encode(file_get_contents($_FILES['datei4']['tmp_name'])); } } } else { // Delete file if ($deldatei4 == 1) { $row->file4 = ""; $row->file4code = ""; } } if (!empty($_FILES['datei5'])) { if (is_file($_FILES['datei5']['tmp_name']) and $_FILES['datei5']['size'] > 0) { if ($_FILES['datei5']['size'] > $filesize) { $fehler[8] = str_replace("SEM_FILE", $_FILES['datei5']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_MAX_SIZE')); } $datei5ext = array_pop(explode(".", strtolower($_FILES['datei5']['name']))); if (!in_array($datei5ext, $fileext)) { $fehler[9] = str_replace("SEM_FILE", $_FILES['datei5']['name'], JTEXT::_('COM_MATUKIO_UPLOAD_FAILED_FILE_TYPE')); } if ($fehler[8] == "" and $fehler[9] == "") { $row->file5 = $_FILES['datei5']['name']; $row->file5code = base64_encode(file_get_contents($_FILES['datei5']['tmp_name'])); } } } else { // Delete file if ($deldatei5 == 1) { $row->file5 = ""; $row->file5code = ""; } } // Eingaben ueberpruefen $speichern = true; // Template?? Deprecated if ($art == 3) { if (!MatukioHelperUtilsEvents::checkRequiredFieldValues($row->pattern, 'leer')) { $speichern = false; $fehler[] = JTEXT::_('COM_MATUKIO_YOU_HAVENT_FILLED_OUT_ALL_REQUIRED_FIELDS'); } } else { if (!MatukioHelperUtilsEvents::checkRequiredFieldValues($row->semnum, 'leer') or !MatukioHelperUtilsEvents::checkRequiredFieldValues($row->title, 'leer') or $row->catid == 0 or !MatukioHelperUtilsEvents::checkRequiredFieldValues($row->shortdesc, 'leer')) { $speichern = false; $fehler[] = JTEXT::_('COM_MATUKIO_YOU_HAVENT_FILLED_OUT_ALL_REQUIRED_FIELDS'); } elseif (!MatukioHelperUtilsEvents::checkRequiredFieldValues($row->maxpupil, 'nummer') or !MatukioHelperUtilsEvents::checkRequiredFieldValues($row->nrbooked, 'nummer')) { $speichern = false; $fehler[] = JTEXT::_('COM_MATUKIO_YOU_HAVENT_TYPED_A_NUMBER'); } else { $database->setQuery("SELECT id FROM #__matukio WHERE semnum='{$row->semnum}' AND id!='{$row->id}'"); $rows = $database->loadObjectList(); if (count($rows) > 0) { $speichern = false; $htxt = JTEXT::_('COM_MATUKIO_NOT_UNIQUE_NUMBERS'); if ($id < 1) { $htxt .= " " . JTEXT::_('COM_MATUKIO_EVENT_NOT_STORED'); } $fehler[] = $htxt; } } } // Kurs speichern if ($speichern == true) { // Trigger plugin event $results = $dispatcher->trigger('onBeforeSaveEvent', $row); // Check if we already created recurring events if ($recurring == 1) { $edited = $input->getInt("recurring_edited", 0); if ($row->recurring_created && $edited && $row->id > 0) { // Delete old recurring events $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->delete("#__matukio_recurring")->where("event_id = " . $row->id); $db->setQuery($query); $db->execute(); // Maybe set booking status to deleted too? } else { // Set it to 1 $row->recurring_created = 1; } } if (!$row->check()) { throw new Exception($database->stderr(), 42); } if (!$row->store()) { throw new Exception($database->stderr(), 42); } $row->checkin(); // Trigger plugin event $results = $dispatcher->trigger('onAfterSaveEvent', array('com_matukio.event', &$row, $isNew)); // Create recurring events if ($recurring == 1) { $dates_string = $input->get("recurring_dates", '', 'string'); if (!empty($dates_string)) { $bdate = explode(" ", $row->begin); $bdate = $bdate[0]; // Add begin date (if not already in there) if (strpos($dates_string, $bdate) === false) { $dates_string = $bdate . "," . "{$dates_string}"; } $dates = explode(",", $dates_string); $begin_date = new DateTime($row->begin); $end_date = new DateTime($row->end); $closing_date = new DateTime($row->booked); $diff = $begin_date->diff($end_date); $diff2 = $begin_date->diff($closing_date); $start_time = $begin_date->format("H:i:s"); $year = date('Y'); foreach ($dates as $d) { $rec_start = new DateTime($d . " " . $start_time); $rec_end = clone $rec_start; $rec_end->add($diff); $rec_close = clone $rec_start; $rec_close->add($diff2); $robj = new stdClass(); $robj->event_id = $row->id; $robj->semnum = MatukioHelperUtilsEvents::createNewEventNumber($year); $robj->begin = $rec_start->format("Y-m-d H:i:s"); $robj->end = $rec_end->format("Y-m-d H:i:s"); $robj->booked = $rec_close->format("Y-m-d H:i:s"); $robj->published = 1; $rect = JTable::getInstance('Recurring', 'MatukioTable'); if (!$rect->bind($robj)) { throw new Exception($rect->getError(), 42); } if (!$rect->check()) { throw new Exception($rect->getError(), 42); } if (!$rect->store()) { throw new Exception($rect->getError(), 42); } } } } else { // Delete the current date from recurring table and insert the new one // Delete old recurring events $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select("*")->from("#__matukio_recurring")->where("event_id = " . $row->id); $db->setQuery($query); $recd = $db->loadObjectList(); // Switch from recurring events to none recurring if (count($recd) > 1) { $query = $db->getQuery(true); $query->delete("#__matukio_recurring")->where("event_id = " . $row->id); $db->setQuery($query); $db->execute(); // Insert it ones MatukioHelperRecurring::saveRecurringDateForEvent($row); } elseif (count($recd) == 1) { // Ugly hack $recd = $recd[0]; $rect = JTable::getInstance('Recurring', 'MatukioTable'); $recd->semnum = $row->semnum; $recd->begin = $row->begin; $recd->end = $row->end; $recd->booked = $row->booked; $recd->published = $row->published; // We just update the date if (!$rect->bind($recd)) { throw new Exception($rect->getError(), 42); } if (!$rect->check()) { throw new Exception($rect->getError(), 42); } if (!$rect->store()) { throw new Exception($rect->getError(), 42); } } else { // Insert date into recurring table // Add recurring date MatukioHelperRecurring::saveRecurringDateForEvent($row); } } // Trigger plugin event $results = $dispatcher->trigger('onAfterSaveRecurring', $row); } // Ausgabe der Kurse $fehlerzahl = array_unique($fehler); if (count($fehlerzahl) > 1) { $fehler = array_unique($fehler); if ($fehler[0] == "") { $fehler = array_slice($fehler, 1); } $fehler = implode("<br />", $fehler); JFactory::getApplication()->enqueueMessage($fehler, 'Warning'); } // Notify Admin BCC of event creation if (MatukioHelperSettings::getSettings('sendmail_operator', '') != '' && $isNew && $speichern) { $mailer = JFactory::getMailer(); $mainframe = JFactory::getApplication(); $sender = $mainframe->getCfg('fromname'); $from = $mainframe->getCfg('mailfrom'); $user = JFactory::getUser($row->publisher); $replyname = $user->name; $replyto = $user->email; $subject = JText::_("COM_MATUKIO_NEW_EVENT_CREATED"); $body = JText::_("COM_MATUKIO_NEW_EVENT_CREATED") . "\n\n"; $body .= JText::_("COM_MATUKIO_EVENT_DETAILS") . ":\n\n"; $body .= JText::_("COM_MATUKIO_TITLE") . ":\t\t" . $row->title . "\n"; $body .= JText::_("COM_MATUKIO_RECURRING_SEMNUM") . ":\t\t" . $row->semnum . "\n"; $body .= JText::_("COM_MATUKIO_BEGIN") . ":\t\t" . $row->begin . "\n"; $body .= JText::_("COM_MATUKIO_END") . ":\t\t" . $row->end . "\n"; $body .= JText::_("COM_MATUKIO_EVENT_DEFAULT_PLACE") . ":\t\t" . $row->place . "\n"; $body .= JText::_("COM_MATUKIO_EVENT_DEFAULT_SHORT_DESCRIPTION") . ":\t\t" . $row->shortdesc . "\n"; $body .= JText::_("COM_MATUKIO_PUBLISHER") . ":\t\t" . $user->name . "\n"; $success = $mailer->sendMail($from, $sender, explode(",", MatukioHelperSettings::getSettings('sendmail_operator', '')), $subject, $body, MatukioHelperSettings::getSettings('email_html', 1), null, null, null, $replyto, $replyname); } // Send an notification email to all users with new event details @since 4.3.0 if (MatukioHelperSettings::getSettings('sendmail_newevent', 1) && $isNew && $speichern) { // We send an notification of the new event to all users / user group if (MatukioHelperSettings::_("sendmail_newevent_group", 0)) { // Filter users to the given group if not 0 (all) given jimport('joomla.access.access'); $ids = JAccess::getUsersByGroup(MatukioHelperSettings::_("sendmail_newevent_group", 0)); $query = "SELECT * FROM #__users WHERE block = 0 AND id IN (" . implode(",", $ids) . ")"; $db->setQuery($query); $users = $db->loadObjectList(); } else { // Get all users $query = "SELECT * FROM #__users WHERE block = 0"; $db->setQuery($query); $users = $db->loadObjectList(); } $mailer = JFactory::getMailer(); // Set an empty category here - TODO query it from #__category table $row->category = ""; $tmpl = MatukioHelperTemplates::getEmailBody("mail_newevent", $row, null); // Use HTML or text E-Mail if (MatukioHelperSettings::getSettings('email_html', 1)) { // Start html output $body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n"; $body .= '<html xmlns="http://www.w3.org/1999/xhtml">' . "\n"; $body .= "<head>\n"; $body .= "</head>\n"; $body .= "<body>\n"; $body .= $tmpl->value; $body .= "</body>\n</html>"; } else { $body = $tmpl->value_text; } $subject = $tmpl->subject; $mainframe = JFactory::getApplication(); $sender = $mainframe->getCfg('fromname'); $from = $mainframe->getCfg('mailfrom'); // Loop and sent mail foreach ($users as $u) { $success = $mailer->sendMail($from, $sender, $u->email, $subject, $body, MatukioHelperSettings::getSettings('email_html', 1), null, null, null); $mailer->ClearAllRecipients(); } // E-Mail to Admin / Operator etc. if (MatukioHelperSettings::getSettings('sendmail_operator', '') != "") { $success = $mailer->sendMail($from, $sender, explode(",", MatukioHelperSettings::getSettings('sendmail_operator', '')), $subject, $body, MatukioHelperSettings::getSettings('email_html', 1), null, null, null); $mailer->ClearAllRecipients(); } } $obj = new StdClass(); $obj->id = $row->id; $obj->error = $row->fehler; $obj->error_count = count($fehlerzahl); $obj->saved = $speichern; $obj->event = $row; return $obj; }
/** * Gets the bookable image (used in backend and frontend) * * @param object $event - The event * * @return string */ public static function getBookableImage($event) { $curdate = MatukioHelperUtilsDate::getCurrentDate(); $bbild = "2502.png"; $altbbild = JTEXT::_('COM_MATUKIO_NOT_EXCEEDED'); if ($curdate > $event->booked) { $bbild = "2500.png"; $altbbild = JTEXT::_('COM_MATUKIO_EXCEEDED'); } return "<img src=\"" . self::getComponentImagePath() . $bbild . "\" border=\"0\" alt=\"" . $altbbild . "\" title=\"" . $altbbild . "\" />"; }
/** * Shows the form * * @param string $tpl - The tmpl * * @return bool|mixed|object */ public function display($tpl = NULL) { $database = JFactory::getDBO(); $my = JFactory::getuser(); $dateid = JFactory::getApplication()->input->getInt('dateid', 1); $catid = JFactory::getApplication()->input->getInt('catid', 0); $search = JFactory::getApplication()->input->get('search', '', 'string'); $limit = JFactory::getApplication()->input->getInt('limit', 5); $limitstart = JFactory::getApplication()->input->getInt('limitstart', 0); $cid = JFactory::getApplication()->input->getInt('cid', 0); $uid = JFactory::getApplication()->input->getInt('uid', 0); $todo = JFactory::getApplication()->input->get('todo', 'print_eventlist'); // print_eventlist, print_booking, print_myevents, print $rows = null; $status = null; $headertext = null; $neudatum = MatukioHelperUtilsDate::getCurrentDate(); if ($limitstart < 0) { $limitstart = 0; } $ttlimit = ""; if ($limit > 0) { $ttlimit = "\nLIMIT {$limitstart}, {$limit}"; } /** * 65O9805443904 = public ?! * 653O875032490 = Meine Angebote * 6530387504345 = Meine Buchungen / Buchungsbestätigung ?! * * 3728763872762 = * csv */ $where = array(); $where[] = "a.pattern = ''"; $where[] = "a.published = '1'"; switch ($todo) { case "print_eventlist": $navioben = explode(" ", MatukioHelperSettings::getSettings('frontend_topnavshowmodules', 'SEM_NUMBER SEM_SEARCH SEM_CATEGORIES SEM_RESET')); break; case "print_booking": $navioben = explode(" ", MatukioHelperSettings::getSettings('frontend_topnavbookingmodules', 'SEM_NUMBER SEM_SEARCH SEM_CATEGORIES SEM_RESET')); break; case "print_myevents": $navioben = explode(" ", MatukioHelperSettings::getSettings('frontend_topnavoffermodules', 'SEM_NUMBER SEM_SEARCH SEM_CATEGORIES SEM_RESET')); break; case "print_teilnehmerliste": $navioben = ""; break; } if ($todo != "print_teilnehmerliste" && $todo != "csvlist" && $todo != "certificate" && $todo != "invoice") { if (in_array('SEM_TYPES', $navioben)) { switch ($dateid) { case "1": $where[] = "a.end > '{$neudatum}'"; break; case "2": $where[] = "a.end <= '{$neudatum}'"; break; } } } switch ($todo) { default: case "print_eventlist": if (!in_array('SEM_TYPES', $navioben)) { $where[] = "r.end > '{$neudatum}'"; } if ((isset($_GET["catid"]) or in_array('SEM_CATEGORIES', $navioben)) and $catid > 0) { $where[] = "a.catid ='{$catid}'"; } $headertext = JTEXT::_('COM_MATUKIO_EVENTS'); if ($cid) { $where[] = "r.id= '{$cid}'"; $headertext = JTEXT::_('COM_MATUKIO_EVENT'); } $database->setQuery("SELECT a.*, r.*, cc.title AS category FROM #__matukio_recurring AS r" . "\nLEFT JOIN #__matukio AS a ON r.event_id = a.id" . "\nLEFT JOIN #__categories AS cc ON cc.id = a.catid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nAND (r.semnum LIKE'%{$search}%' OR a.teacher LIKE '%{$search}%' OR a.title LIKE '%{$search}%'" . " OR a.shortdesc LIKE '%{$search}%' OR a.description LIKE '%{$search}%')"); $rows = $database->loadObjectList(); // Abzug der Kurse, die wegen Ausbuchung nicht angezeigt werden sollen if (!$cid) { $abid = array(); foreach ($rows as $row) { if ($row->stopbooking == 2) { $gebucht = MatukioHelperUtilsEvents::calculateBookedPlaces($row); if ($row->maxpupil - $gebucht->booked < 1) { $abid[] = $row->id; } } } if (count($abid) > 0) { $abid = implode(',', $abid); $where[] = "r.id NOT IN ({$abid})"; } } $database->setQuery("SELECT a.*, r.*, cc.title AS category FROM #__matukio_recurring AS r" . "\nLEFT JOIN #__matukio AS a ON r.event_id = a.id" . "\nLEFT JOIN #__categories AS cc" . "\nON cc.id = a.catid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nAND (a.semnum LIKE'%{$search}%' OR a.teacher LIKE '%{$search}%' OR a.title LIKE '%{$search}%' OR a.shortdesc LIKE '%{$search}%' OR a.description LIKE '%{$search}%')" . "\nORDER BY r.begin" . $ttlimit); $rows = $database->loadObjectList(); $status = array(); $paid = array(); $abid = array(); for ($i = 0, $n = count($rows); $i < $n; $i++) { $row =& $rows[$i]; $gebucht = MatukioHelperUtilsEvents::calculateBookedPlaces($row); $gebucht = $gebucht->booked; if (MatukioHelperUtilsDate::getCurrentDate() > $row->booked or $row->maxpupil - $gebucht < 1 and $row->stopbooking == 1 or $my->id == $row->publisher and MatukioHelperSettings::getSettings('booking_ownevents', 1) == 0) { $status[$i] = JTEXT::_('COM_MATUKIO_UNBOOKABLE'); } elseif ($row->maxpupil - $gebucht < 1 && $row->stopbooking == 0) { $status[$i] = JTEXT::_('COM_MATUKIO_BOOKING_ON_WAITLIST'); } elseif ($row->maxpupil - $gebucht < 1 && $row->stopbooking == 2) { $abid[] = $row->id; } else { $status[$i] = JTEXT::_('COM_MATUKIO_NOT_EXCEEDED'); } $database->setQuery("SELECT * FROM #__matukio_bookings WHERE semid='{$row->id}' AND userid='{$my->id}'"); $temp = $database->loadObjectList(); if (count($temp) > 0) { $status[$i] = JTEXT::_('COM_MATUKIO_ALREADY_BOOKED'); if ($temp[0]->paid == 1) { $rows[$i]->fees = $rows[$i]->fees . " - " . JTEXT::_('COM_MATUKIO_PAID'); } } $rows[$i]->codepic = ""; } break; // My bookings ?! // My bookings ?! case "print_booking": $headertext = JTEXT::_('COM_MATUKIO_MY_BOOKINGS') . " - " . $my->name; if (in_array('SEM_CATEGORIES', $navioben) and $catid > 0) { $where[] = "a.catid ='{$catid}'"; } $where[] = "cc.userid = '" . $my->id . "'"; if ($cid) { $where[] = "cc.semid = '" . $cid . "'"; $headertext = JTEXT::_('COM_MATUKIO_BOOKING_CONFIRMATION') . " - " . $my->name; } $database->setQuery("SELECT a.*, r.*, cat.title AS category, cc.bookingdate AS bookingdate, cc.id AS bookid, cc.status AS bookingstatus\r\n\t\t\t\t\tFROM #__matukio_recurring AS r\r\n\t\t\t\t\tLEFT JOIN #__matukio AS a ON r.event_id = a.id\r\n\t\t\t\t\tLEFT JOIN #__matukio_bookings AS cc ON cc.semid = r.id\r\n\t\t\t\t\tLEFT JOIN #__categories AS cat ON cat.id = a.catid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nAND (r.semnum LIKE'%{$search}%' OR a.teacher LIKE '%{$search}%' OR a.title LIKE '%{$search}%' OR a.shortdesc LIKE '%{$search}%'\r\n OR a.description LIKE '%{$search}%')" . "\nORDER BY r.begin" . $ttlimit); $rows = $database->loadObjectList(); $status = array(); for ($i = 0, $n = count($rows); $i < $n; $i++) { $row =& $rows[$i]; $database->setQuery("SELECT * FROM #__matukio_bookings WHERE semid = '{$row->id}' ORDER BY id"); $temps = $database->loadObjectList(); $status[$i] = MatukioHelperUtilsBooking::getBookingStatusName($row->bookingstatus); $rows[$i]->codepic = $row->bookid; if ($temps[0]->paid == 1) { $rows[$i]->fees = $rows[$i]->fees . " - " . JTEXT::_('COM_MATUKIO_PAID'); } } break; // My events ?! // My events ?! case "print_myevents": if (in_array('SEM_CATEGORIES', $navioben) and $catid > 0) { $where[] = "a.catid ='{$catid}'"; } $where[] = "a.publisher = '" . $my->id . "'"; $database->setQuery("SELECT a.*, r.* cat.title AS category FROM #__matukio_recurring AS r\r\n\t\t\t \t LEFT JOIN #__matukio AS a ON r.eventid = a.id\r\n\t\t\t\t\tLEFT JOIN #__categories AS cat ON cat.id = a.catid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nAND (r.semnum LIKE'%{$search}%' OR a.teacher LIKE '%{$search}%' OR a.title LIKE '%{$search}%' OR a.shortdesc LIKE '%{$search}%' OR a.description LIKE '%{$search}%')" . "\nORDER BY r.begin" . $ttlimit); $rows = $database->loadObjectList(); $status = array(); $headertext = JTEXT::_('COM_MATUKIO_MY_OFFERS') . " - " . $my->name; for ($i = 0, $n = count($rows); $i < $n; $i++) { $row =& $rows[$i]; $status[$i] = MatukioHelperUtilsBooking::getBookingStatusName($row->bookingstatus); $rows[$i]->codepic = ""; } break; case "print_teilnehmerliste": // TODO implement userchecking $art = JFactory::getApplication()->input->getInt('art', 0); $this->art = $art; if ($art == 1) { $this->setLayout("signaturelist"); } else { $this->setLayout("participants"); } break; case "csvlist": // TODO implement userchecking $art = JFactory::getApplication()->input->getInt('art', 0); $this->art = $art; $this->cid = $cid; $this->setLayout("csv"); break; case "certificate": // TODO implement userchecking $art = JFactory::getApplication()->input->getInt('art', 0); $uid = JFactory::getApplication()->input->getInt('uid', 0); $this->art = $art; $this->uid = $uid; $this->setLayout("certificate"); break; case "invoice": // TODO implement userchecking $art = JFactory::getApplication()->input->getInt('art', 0); $uid = JFactory::getApplication()->input->getInt('uid', 0); $this->art = $art; $this->uid = $uid; $this->setLayout("invoice"); break; } $this->rows = $rows; $this->status = $status; $this->headertext = $headertext; parent::display($tpl); }
<?php /** * @package Matukio * @author Yves Hoppe <*****@*****.**> * @date 03.04.13 * * @copyright Copyright (C) 2008 - 2014 Yves Hoppe - compojoom.com . All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE */ defined('_JEXEC') or die('Restricted access'); $document = JFactory::getDocument(); $database = JFactory::getDBO(); $my = JFactory::getuser(); $neudatum = MatukioHelperUtilsDate::getCurrentDate(); JHTML::_('behavior.modal'); JHTML::_('stylesheet', 'media/com_matukio/css/matukio.css'); JHTML::_('script', 'media/com_matukio/js/matukio.js'); $params = JComponentHelper::getParams('com_matukio'); $menuitemid = JFactory::getApplication()->input->get('Itemid'); if ($menuitemid) { $site = new JSite(); $menu = $site->getMenu(); $menuparams = $menu->getParams($menuitemid); $params->merge($menuparams); } ?> <!-- Matukio by compojoom.com --> <div id="matukio_holder"> <?php // Heading
/** * OLD Booking method for old form * * @todo move into a nice function for both backend / Frontend / old and new form * @return mixed */ public function bookevent() { $database = JFactory::getDBO(); $my = JFactory::getUser(); $id = JFactory::getApplication()->input->getInt('cid', 0); $uid = JFactory::getApplication()->input->getInt('uid', 0); $catid = JFactory::getApplication()->input->getInt('catid', 0); $nrbooked = JFactory::getApplication()->input->getInt('nrbooked', 0); $name = JFactory::getApplication()->input->get('name', '', 'string'); $email = JFactory::getApplication()->input->get('email', '', 'string'); $dispatcher = JDispatcher::getInstance(); // Edit own booking $booking_id = JFactory::getApplication()->input->getInt('booking_id', 0); // AGBs $veragb = JFactory::getApplication()->input->get('veragb', 0, 'string'); $isWaitlist = false; $reason = ""; // Load event (use model function) $emodel = JModelLegacy::getInstance('Event', 'MatukioModel'); $row = $emodel->getItem($id); $usrid = $my->id; $art = 2; if ($uid > 0) { $usrid = $uid; $art = 4; } $sqlid = $usrid; if ($name != "" and $email != "" or $usrid == 0) { $usrid = 0; $sqlid = -1; } // Pruefung ob Buchung erfolgreich durchfuehrbar $database->setQuery("SELECT * FROM #__matukio_bookings WHERE semid='{$id}' AND userid='{$sqlid}'"); $temp = $database->loadObjectList(); if (!empty($booking_id)) { $temp = null; } $gebucht = MatukioHelperUtilsEvents::calculateBookedPlaces($row); $gebucht = $gebucht->booked; $allesok = 1; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_SUCCESSFULL'); $pflichtfeld = false; $fields = MatukioHelperUtilsEvents::getAdditionalFieldsFrontend($row); for ($i = 0; $i < 20; $i++) { $test = $fields[0][$i]; if (!empty($test)) { $res = explode("|", $test); if (trim($res[1]) == "1") { $value = JFactory::getApplication()->input->get("zusatz" . ($i + 1), '', 'string'); if (empty($value)) { $pflichtfeld = true; } } } } if ($my->id > 0) { $name = $my->name; $email = $my->email; } // } if (empty($name) || empty($email)) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_NO_NAME_OR_EMAIL'); } elseif ($pflichtfeld) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_REQUIRED_ADDITIONAL_FIELD_EMPTY'); } elseif (count($temp) > 0) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_REGISTERED_FOR_THIS_EVENT'); } elseif (MatukioHelperUtilsDate::getCurrentDate() > $row->booked) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_EXCEEDED'); } elseif ($row->maxpupil - $gebucht - $nrbooked < 0 && $row->stopbooking == 1) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_MAX_PARTICIPANT_NUMBER_REACHED'); } elseif ($row->maxpupil - $gebucht - $nrbooked < 0 && $row->stopbooking == 0) { $allesok = 2; $ueber1 = JTEXT::_('COM_MATUKIO_ADDED_WAITLIST'); $reason = JTEXT::_('COM_MATUKIO_YOU_ARE_BOOKED_ON_THE_WAITING_LIST'); $isWaitlist = true; } elseif (MatukioHelperSettings::getSettings('agb_text', '') != "" && $veragb != "1") { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_AGB_NOT_ACCEPTED'); } if ($art == 4) { $allesok = 1; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_SUCCESSFULL'); } $link = JRoute::_(MatukioHelperRoute::getEventRoute($row->id, $catid), false); $msg = ""; $neu = ""; // Alles in Ordnung if ($allesok > 0) { // Buchung eintragen $neu = JTable::getInstance('bookings', 'Table'); if (!$neu->bind(JRequest::get('post'))) { return JError::raiseError(500, $database->stderr()); } if (!empty($booking_id)) { $neu->id = $booking_id; } $neu->semid = $id; $neu->userid = $usrid; // Hmm really do that? $neu->name = $name; $neu->email = $email; $neu->bookingdate = MatukioHelperUtilsDate::getCurrentDate(); $neu->name = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->name); $neu->email = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->email); $neu->zusatz1 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz1); $neu->zusatz2 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz2); $neu->zusatz3 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz3); $neu->zusatz4 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz4); $neu->zusatz5 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz5); $neu->zusatz6 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz6); $neu->zusatz7 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz7); $neu->zusatz8 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz8); $neu->zusatz9 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz9); $neu->zusatz10 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz10); $neu->zusatz11 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz11); $neu->zusatz12 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz12); $neu->zusatz13 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz13); $neu->zusatz14 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz14); $neu->zusatz15 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz15); $neu->zusatz16 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz16); $neu->zusatz17 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz17); $neu->zusatz18 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz18); $neu->zusatz19 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz19); $neu->zusatz20 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz20); // Set booking status to active @since 3.1 $neu->status = MatukioHelperUtilsBooking::$ACTIVE; if (!empty($row->fees)) { $neu->payment_method = "cash"; $payment_brutto = $row->fees * $neu->nrbooked; $coupon_code = $neu->coupon_code; if (!empty($coupon_code)) { $cdate = new DateTime(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('*')->from('#__matukio_booking_coupons')->where('code = ' . $db->quote($coupon_code) . ' AND published = 1 AND published_up < ' . $db->quote($cdate->format('Y-m-d H:i:s')) . " AND published_down > " . $db->quote($cdate->format('Y-m-d H:i:s'))); $db->setQuery($query); $coupon = $db->loadObject(); if (!empty($coupon)) { if ($coupon->procent == 1) { // Get a procent value $payment_brutto = round($payment_brutto * ((100 - $coupon->value) / 100), 2); } else { $payment_brutto = $payment_brutto - $coupon->value; } } else { // Perhaps delete this invalid field, or display an error?! TODO } } $neu->payment_brutto = $payment_brutto; } $results = $dispatcher->trigger('onBeforeSaveBooking', $neu, $row); // Set status since @3.1 if ($isWaitlist) { // We book to the waitlist, let's set the booking like that then $neu->status = MatukioHelperUtilsBooking::$WAITLIST; } elseif (empty($row->fees)) { // We set the status to active because no payment is done.. so no reason to not confirm them $neu->status = MatukioHelperUtilsBooking::$ACTIVE; } elseif (MatukioHelperSettings::_("booking_always_active", 0)) { // We check if the booking always active setting is set - if yes the booking is always!! active (except waitlist delete etc.) $neu->status = MatukioHelperUtilsBooking::$ACTIVE; } else { // We set the status to pending - this is going to be overwritten by the payment API (if paid etc.) $neu->status = MatukioHelperUtilsBooking::$PENDING; } if (!$neu->check()) { JError::raiseError(500, $database->stderr()); exit; } if (!$neu->store()) { JError::raiseError(500, $database->stderr()); exit; } $neu->checkin(); $ueber1 = JText::_("COM_MATUKIO_BOOKING_WAS_SUCCESSFULL"); if ($usrid == 0) { $usrid = $neu->id * -1; } if (MatukioHelperSettings::getSettings("oldbooking_redirect_after", "bookingpage") == "bookingpage") { $link = JRoute::_(MatukioHelperRoute::getEventRoute($row->id, $catid, 1, $neu->id), false); } elseif (MatukioHelperSettings::getSettings("oldbooking_redirect_after", "bookingpage") == "eventpage") { $link = JRoute::_(MatukioHelperRoute::getEventRoute($row->id, $catid, 0, $neu->id), false); } else { // Eventlist overview $link = JRoute::_("index.php?option=com_matukio&view=eventlist"); } if ($art == 4) { MatukioHelperUtilsEvents::sendBookingConfirmationMail($row, $neu->id, 8); } else { MatukioHelperUtilsEvents::sendBookingConfirmationMail($row, $neu->id, 1); } } else { $link = JRoute::_(MatukioHelperRoute::getEventRoute($row->id, $catid), false); } $this->setRedirect($link, $ueber1 . " " . $reason); }
$user = JFactory::getuser($event->publisher); $icsdata .= "BEGIN:VEVENT\n"; $icsdata .= "UID:" . MatukioHelperUtilsBooking::getBookingId($event->id) . "\n"; $icsdata .= "ORGANIZER;CN=\"" . $user->name . "\":MAILTO:" . $user->email . "\n"; $icsdata .= "SUMMARY:" . JText::_($event->title) . "\n"; if ($event->webinar == 1) { $location = JText::_("COM_MATUKIO_WEBINAR"); } elseif ($event->place_id != 0) { $locobj = MatukioHelperUtilsEvents::getLocation($event->place_id); $location = $locobj->location; } else { $location = $event->place; } $icsdata .= "LOCATION:" . str_replace("(\r\n|\n|\r)", ", ", $location) . "\n"; $icsdata .= "DESCRIPTION:" . str_replace("(\r\n|\n|\r)", " ", $event->shortdesc) . "\n"; $icsdata .= "CLASS:PUBLIC\n"; $icsdata .= "DTSTART:" . strftime("%Y%m%dT%H%M%S", JFactory::getDate($event->begin)->toUnix()) . "\n"; $icsdata .= "DTEND:" . strftime("%Y%m%dT%H%M%S", JFactory::getDate($event->end)->toUnix()) . "\n"; $icsdata .= "DTSTAMP:" . strftime("%Y%m%dT%H%M%S", JFactory::getDate(MatukioHelperUtilsDate::getCurrentDate())->toUnix()) . "\n"; $icsdata .= "BEGIN:VALARM\n"; $icsdata .= "TRIGGER:-PT1440M\n"; $icsdata .= "ACTION:DISPLAY\n"; $icsdata .= "END:VALARM\n"; $icsdata .= "END:VEVENT\n"; } $icsdata .= "END:VCALENDAR"; header("Content-Type: text/calendar; charset=utf-8"); header("Content-Length: " . strlen($icsdata)); header("Content-Disposition: attachment; filename=\"" . $filename . ".ics\""); header('Pragma: no-cache'); echo $icsdata;
/** * NEW Booking method for old and new form * * @throws Exception - if db query fails * @return mixed */ public function book() { $payment_brutto = 0; $database = JFactory::getDBO(); $post = JRequest::get('post'); $my = JFactory::getUser(); $input = JFactory::getApplication()->input; $event_id = $input->getInt('event_id', 0); $uid = $input->getInt('uid', 0); $steps = $input->getInt('steps', 3); $uuid = $input->get('uuid', 0, 'string'); $id = $input->getInt('id', 0); $booking = null; if (!empty($id)) { // check if there is really such a booking $model = JModelLegacy::getInstance('Booking', 'MatukioModel'); $booking = $model->getBooking($uuid); if (empty($booking)) { throw new Exception(JText::_("COM_MATUKIO_NO_BOOKING_FOUND"), 404); } if ($booking->id != $id) { throw new Exception(JText::_("COM_MATUKIO_NO_BOOKING_FOUND"), 404); } } $nrbooked = $input->getInt('nrbooked', 1); $catid = $input->getInt('catid', 0); $payment_method = $input->get('payment', '', 'string'); $agb = $input->get('agb', '', 'string'); $isWaitlist = false; $dispatcher = JDispatcher::getInstance(); if (empty($event_id)) { throw new Exception(JText::_("COM_MATUKIO_NO_ID"), 404); } // Load event (use model function) $emodel = JModelLegacy::getInstance('Event', 'MatukioModel'); $event = $emodel->getItem($event_id); $userid = $my->id; // Different fees @since 3.0 $different_fees = $event->different_fees; $reason = ""; $art = 2; $temp = null; $gebucht = MatukioHelperUtilsEvents::calculateBookedPlaces($event); $gebucht = $gebucht->booked; $allesok = 1; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_SUCCESSFULL'); $pflichtfeld = false; $fields = MatukioHelperUtilsEvents::getAdditionalFieldsFrontend($event); // Checking old required fields - backward compatibilty for ($i = 0; $i < 20; $i++) { $test = $fields[0][$i]; if (!empty($test)) { $res = explode("|", $test); if (trim($res[1]) == "1") { $value = $input->get("zusatz" . ($i + 1), '', 'string'); if (empty($value)) { $pflichtfeld = true; } } } } if (MatukioHelperSettings::getSettings("captcha", 0) == 1) { $ccval = $input->get("ccval", '', 'string'); $captcha = $input->get("captcha", '', 'string'); if (empty($captcha)) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_CAPTCHA_WRONG'); } elseif (md5($captcha) != $ccval) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_CAPTCHA_WRONG'); } } if (MatukioHelperSettings::getSettings("recaptcha", 0) == 1) { require_once JPATH_COMPONENT_ADMINISTRATOR . '/include/recaptcha/recaptchalib.php'; $key = MatukioHelperSettings::getSettings("recaptcha_private_key", ""); if (empty($key)) { throw new Exception("COM_MATUKIO_YOU_HAVE_TO_SET_A_RECAPTCHA_KEY", 500); } $resp = recaptcha_check_answer($key, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_CAPTCHA_WRONG') . $resp->error; } } $agbtext = MatukioHelperSettings::getSettings("agb_text", ""); if ($pflichtfeld) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_REQUIRED_ADDITIONAL_FIELD_EMPTY'); } elseif (count($temp) > 0) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_REGISTERED_FOR_THIS_EVENT'); } elseif (MatukioHelperUtilsDate::getCurrentDate() > $event->booked) { echo "current: " . MatukioHelperUtilsDate::getCurrentDate(); echo " booking: " . $event->booked; $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_EXCEEDED'); } elseif ($event->maxpupil - $gebucht - $nrbooked < 0 && $event->stopbooking == 1) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_MAX_PARTICIPANT_NUMBER_REACHED'); } elseif (!empty($agbtext)) { // Has to be on the end if (empty($agb)) { $allesok = 0; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_NOT_SUCCESSFULL'); $reason = JTEXT::_('COM_MATUKIO_AGB_NOT_ACCEPTED'); } } if ($event->maxpupil - $gebucht - $nrbooked < 0 && $event->stopbooking == 0) { $allesok = 2; $ueber1 = JTEXT::_('COM_MATUKIO_ADDED_WAITLIST'); $reason = JTEXT::_('COM_MATUKIO_YOU_ARE_BOOKED_ON_THE_WAITING_LIST'); if (empty($booking)) { $isWaitlist = true; } else { // Prevent switching old booking to waitlist if ($booking->status == MatukioHelperUtilsBooking::$WAITLIST) { $isWaitlist = true; } else { $isWaitlist = false; } } } if ($art == 4) { $allesok = 1; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_SUCCESSFULL'); } $results = $dispatcher->trigger('onValidateBooking', $post, $event, $allesok); // Alles in Ordnung if ($allesok > 0) { // Buchung eintragen $neu = JTable::getInstance('bookings', 'Table'); if (!$neu->bind($post)) { return JError::raiseError(500, $database->stderr()); } $neu->semid = $event->id; $neu->userid = $userid; $firstname = $input->get('firstname', '', 'string'); $lastname = $input->get('lastname', '', 'string'); $neu->bookingdate = MatukioHelperUtilsDate::getCurrentDate(); $neu->name = MatukioHelperUtilsBasic::cleanHTMLfromText($firstname . " " . $lastname); $neu->email = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->email); $neu->zusatz1 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz1); $neu->zusatz2 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz2); $neu->zusatz3 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz3); $neu->zusatz4 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz4); $neu->zusatz5 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz5); $neu->zusatz6 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz6); $neu->zusatz7 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz7); $neu->zusatz8 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz8); $neu->zusatz9 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz9); $neu->zusatz10 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz10); $neu->zusatz11 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz11); $neu->zusatz12 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz12); $neu->zusatz13 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz13); $neu->zusatz14 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz14); $neu->zusatz15 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz15); $neu->zusatz16 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz16); $neu->zusatz17 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz17); $neu->zusatz18 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz18); $neu->zusatz19 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz19); $neu->zusatz20 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz20); $fields = MatukioHelperUtilsBooking::getBookingFields(); if (!empty($fields)) { $newfields = ""; for ($i = 0; $i < count($fields); $i++) { $field = $fields[$i]; $name = $field->field_name; $newfields .= $field->id; $newfields .= "::"; $newfields .= $input->get($name, '', 'string'); $newfields .= ";"; } $neu->newfields = $newfields; if (!empty($event->fees) && $steps > 2) { $neu->payment_method = $payment_method; if ($different_fees == 0) { $payment_brutto = $event->fees * $neu->nrbooked; $coupon_code = $neu->coupon_code; if (!empty($coupon_code)) { $cdate = new DateTime(); $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('*')->from('#__matukio_booking_coupons')->where('code = ' . $db->quote($coupon_code) . ' AND published = 1 AND (published_up < ' . $db->quote($cdate->format('Y-m-d H:i:s')) . ' OR published_up = ' . $db->quote("0000-00-00 00:00:00") . ') ' . 'AND (published_down > ' . $db->quote($cdate->format('Y-m-d H:i:s')) . ' OR published_down = ' . $db->quote("0000-00-00 00:00:00") . ')'); $db->setQuery($query); $coupon = $db->loadObject(); if (!empty($coupon)) { if ($coupon->procent == 1) { // Get a procent value $payment_brutto = round($payment_brutto * ((100 - $coupon->value) / 100), 2); } else { // Get a real value $payment_brutto = $payment_brutto - $coupon->value; } // Check how often the coupon is used and if used to often set published to 0 (since 3.0.0) $coupon->hits++; // Check if coupon has to be disabled now if (!empty($coupon->max_hits) && $coupon->hits >= $coupon->max_hits) { $coupon->published = 0; } $coupontable = JTable::getInstance('coupons', 'Table'); if (!$coupontable->bind($coupon)) { throw new Exception(42, $database->stderr()); } if (!$coupontable->check()) { throw new Exception(42, $database->stderr()); } if (!$coupontable->store()) { throw new Exception(42, $database->stderr()); } $coupontable->checkin(); } else { // Perhaps delete this invalid field, or display an error?! Should be validated through js normally throw new Exception(JText::_("COM_MATUKIO_INVALID_COUPON_CODE"), 42); } } $neu->payment_brutto = $payment_brutto; } else { // Different fees $payment_brutto = MatukioHelperFees::getPaymentTotal($event); $neu->payment_brutto = $payment_brutto; $difarray = array("places" => $input->get("places", array(), 'Array'), "types" => $input->get("ticket_fees", array(), 'Array')); $neu->different_fees = json_encode($difarray); } } elseif (!empty($event->fees)) { if ($different_fees == 0) { // We have disabled payment plugins but a fee // Only calculate total amount $payment_brutto = $event->fees * $neu->nrbooked; $neu->payment_brutto = $payment_brutto; } else { // Different fees $payment_brutto = MatukioHelperFees::getPaymentTotal($event); $neu->payment_brutto = $payment_brutto; $difarray = array("places" => $input->get("places", array(), 'Array'), "types" => $input->get("ticket_fees", array(), 'Array')); $neu->different_fees = json_encode($difarray); } } } else { // Only calculate total amount $payment_brutto = $event->fees * $neu->nrbooked; $neu->payment_brutto = $event->fees * $neu->nrbooked; } // Taxes if ($neu->payment_brutto > 0) { // Lets check if there are any if ($event->tax_id == 0) { // No taxes $neu->payment_netto = $neu->payment_brutto; $neu->payment_tax = 0.0; } else { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select("*")->from("#__matukio_taxes")->where("id = " . $db->quote($event->tax_id) . " AND published = 1"); $db->setQuery($query); $tax = $db->loadObject(); if (empty($tax)) { // Houston we have a problem throw new Exception("Invalid tax value! Please select the correct tax in the event edit form."); } else { // Calculate netto $minfac = 100 / (100 + $tax->value); $neu->payment_netto = $neu->payment_brutto * $minfac; $neu->payment_tax = $neu->payment_brutto - $neu->payment_netto; } } } $results = $dispatcher->trigger('onBeforeSaveBooking', $neu, $event); // Set status since @3.1 if (!empty($booking)) { // We don't update the status for old bookings $neu->status = $booking->status; } elseif ($isWaitlist) { // We book to the waitlist, let's set the booking like that then $neu->status = MatukioHelperUtilsBooking::$WAITLIST; } elseif (MatukioHelperSettings::_("booking_always_inactive", 0)) { // We set the status to pending $neu->status = MatukioHelperUtilsBooking::$PENDING; } elseif (empty($event->fees)) { // We set the status to active because no payment is done.. so no reason to not confirm them $neu->status = MatukioHelperUtilsBooking::$ACTIVE; } elseif ($steps == 2) { // We set the status to active because no payment can be done.. so no reason to not confirm them $neu->status = MatukioHelperUtilsBooking::$ACTIVE; } elseif ($payment_method == "cash") { // We check if the booking always active setting is set - if yes the booking is always!! active (except waitlist delete etc.) $neu->status = MatukioHelperUtilsBooking::$ACTIVE; } elseif (MatukioHelperSettings::_("booking_always_active", 0)) { // We check if the booking always active setting is set - if yes the booking is always!! active (except waitlist delete etc.) $neu->status = MatukioHelperUtilsBooking::$ACTIVE; } else { // We set the status to pending - this is going to be overwritten by the payment API (if paid etc.) $neu->status = MatukioHelperUtilsBooking::$PENDING; } if (!$neu->check()) { JError::raiseError(500, $database->stderr()); } if (!$neu->store()) { JError::raiseError(500, $database->stderr()); } $neu->checkin(); $results = $dispatcher->trigger('onAfterBookingSave', $neu, $event); $ueber1 = JText::_("COM_MATUKIO_BOOKING_WAS_SUCCESSFULL"); $booking_id = $neu->id; } if ($payment_brutto > 0 && $steps > 2) { // Link to the payment form $link = JRoute::_("index.php?option=com_matukio&view=paymentform&uuid=" . $uuid); $this->setRedirect($link, $reason); } else { if ($allesok > 0) { // We need to send the confirmation here.. we don't send it yet if the event has payment processing MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $neu->id, 1); } // Link to the bookingpage if (MatukioHelperSettings::getSettings("oldbooking_redirect_after", "bookingpage") == "bookingpage") { $link = JRoute::_("index.php?option=com_matukio&view=booking&uuid=" . $neu->uuid); } elseif (MatukioHelperSettings::getSettings("oldbooking_redirect_after", "bookingpage") == "eventpage") { $link = JRoute::_(MatukioHelperRoute::getEventRoute($event->id, $catid, 0, $booking_id), false); } else { // Eventlist overview $link = JRoute::_("index.php?option=com_matukio&view=eventlist"); } $this->setRedirect($link, $ueber1 . " " . $reason); } }
/** * Save old booking form event * * @return object */ function saveoldevent() { // Check authorization if (!JFactory::getUser()->authorise('core.edit', 'com_matukio')) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } $database = JFactory::getDBO(); $input = JFactory::getApplication()->input; $art = 4; $event_id = $input->getInt('event_id', 0); $uid = 0; $notify_participant = $input->getInt("notify_participant", 0); $notify_participant_invoice = $input->getInt("notify_participant_invoice", 0); $uuid = $input->get('uuid', 0, 'string'); $nrbooked = $input->getInt('nrbooked', 1); $userid = $input->getInt('userid', 0); if (empty($event_id)) { return JError::raiseError(404, 'COM_MATUKIO_NO_ID'); } // Load event (use model function) $emodel = JModelLegacy::getInstance('Event', 'MatukioModel'); $event = $emodel->getItem($event_id); $reason = ""; if (!empty($uid)) { // Setting booking to changed booking $userid = $uid; // uid = Negativ } if ($art == 4) { $allesok = 1; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_SUCCESSFULL'); } // Buchung eintragen $neu = JTable::getInstance('bookings', 'Table'); if (!$neu->bind(JRequest::get('post'))) { return JError::raiseError(500, $database->stderr()); } $neu->semid = $event->id; $neu->userid = $userid; $neu->bookingdate = MatukioHelperUtilsDate::getCurrentDate(); $neu->name = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->name); $neu->email = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->email); $neu->zusatz1 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz1); $neu->zusatz2 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz2); $neu->zusatz3 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz3); $neu->zusatz4 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz4); $neu->zusatz5 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz5); $neu->zusatz6 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz6); $neu->zusatz7 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz7); $neu->zusatz8 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz8); $neu->zusatz9 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz9); $neu->zusatz10 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz10); $neu->zusatz11 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz11); $neu->zusatz12 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz12); $neu->zusatz13 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz13); $neu->zusatz14 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz14); $neu->zusatz15 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz15); $neu->zusatz16 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz16); $neu->zusatz17 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz17); $neu->zusatz18 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz18); $neu->zusatz19 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz19); $neu->zusatz20 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz20); $neu->nrbooked = $nrbooked; if (!empty($event->fees)) { $neu->payment_method = "cash"; // TODO Update to diffrent fees if ($nrbooked > 0) { $neu->payment_brutto = $event->fees * $nrbooked; } else { $neu->payment_brutto = $event->fees; } } if (empty($neu->uuid)) { $neu->uuid = MatukioHelperPayment::getUuid(true); } if (!$neu->check()) { return JError::raiseError(500, $database->stderr()); } if (!$neu->store()) { return JError::raiseError(500, $database->stderr()); } $neu->checkin(); $ueber1 = JText::_("COM_MATUKIO_BOOKING_WAS_SUCCESSFULL"); if ($userid == 0) { $userid = $neu->id * -1; } // Send new confirmation mail if ($notify_participant) { MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $neu->id, 11, false, $neu, false); } $viewteilnehmerlink = JRoute::_("index.php?option=com_matukio&view=participants&cid=" . $event->id . "&art=2"); $msg = JText::_("COM_MATUKIO_BOOKING_EDITED"); $this->setRedirect($viewteilnehmerlink, $msg); }
/** * Duplicate an event * * @return object */ public function duplicateEvent() { $msg = JText::_("COM_MATUKIO_EVENT_DUPLICATE_SUCCESS"); $database = JFactory::getDBO(); $cid = JFactory::getApplication()->input->getInt('cid', 0); // Check authorization if (!JFactory::getUser()->authorise('core.edit', 'com_matukio', $cid)) { return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR')); } $database->setQuery("SELECT * FROM #__matukio WHERE id='{$cid}'"); $item = $database->loadObject(); if ($database->getErrorNum()) { JError::raiseError(500, $database->getError()); $msg = "COM_MATUKIO_EVENT_DUPLICATE_FAILURE_" . $database->getError(); } $item->id = null; $row = JTable::getInstance('matukio', 'Table'); if (!$row->bind($item)) { JError::raiseError(500, $row->getError()); $msg = "COM_MATUKIO_EVENT_DUPLICATE_FAILURE_" . $row->getError(); } $row->id = null; $row->hits = 0; $row->grade = 0; $row->certificated = 0; $row->sid = $item->id; $row->publishdate = MatukioHelperUtilsDate::getCurrentDate(); $row->semnum = MatukioHelperUtilsEvents::createNewEventNumber(date('Y')); if (!$row->check()) { JError::raiseError(500, $row->getError()); $msg = "COM_MATUKIO_EVENT_DUPLICATE_FAILURE_" . $row->getError(); } if (!$row->store()) { JError::raiseError(500, $row->getError()); $msg = "COM_MATUKIO_EVENT_DUPLICATE_FAILURE_" . $row->getError(); } $row->checkin(); // Add recurring date MatukioHelperRecurring::saveRecurringDateForEvent($row); $link = JRoute::_("index.php?option=com_matukio&view=eventlist&art=2"); $this->setRedirect($link, $msg); }
/** * OLD booking form * * @return object */ public function saveOld() { $database = JFactory::getDBO(); $input = JFactory::getApplication()->input; // Backend $art = 4; $id = $input->getInt("id", 0); $event_id = $input->getInt('event_id', 0); // Hardcoded to get it working, could cause some new bugs $uid = 0; $uuid = $input->getInt('uuid', 0); $nrbooked = $input->getInt('nrbooked', 1); $userid = $input->getInt('userid', 0); $notify_participant = $input->getInt("notify_participant", 0); $notify_participant_invoice = $input->getInt("notify_participant_invoice", 0); if (empty($event_id)) { return JError::raiseError(404, 'COM_MATUKIO_NO_ID'); } $event = JTable::getInstance('matukio', 'Table'); $event->load($event_id); $reason = ""; if (!empty($uid)) { if ($uid < 0) { // Setting booking to changed booking $userid = $uid; // uid = Negativ $art = 4; } } // Checking old required fields - backward compatibilty - only frontend if ($art == 4) { $allesok = 1; $ueber1 = JTEXT::_('COM_MATUKIO_BOOKING_WAS_SUCCESSFULL'); } // Buchung eintragen $neu = JTable::getInstance('bookings', 'Table'); if (!$neu->bind(JRequest::get('post'))) { return JError::raiseError(500, $database->stderr()); } $neu->semid = $event->id; $neu->userid = $userid; if (empty($id)) { $neu->bookingdate = MatukioHelperUtilsDate::getCurrentDate(); } $neu->name = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->name); $neu->email = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->email); $neu->zusatz1 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz1); $neu->zusatz2 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz2); $neu->zusatz3 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz3); $neu->zusatz4 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz4); $neu->zusatz5 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz5); $neu->zusatz6 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz6); $neu->zusatz7 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz7); $neu->zusatz8 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz8); $neu->zusatz9 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz9); $neu->zusatz10 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz10); $neu->zusatz11 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz11); $neu->zusatz12 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz12); $neu->zusatz13 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz13); $neu->zusatz14 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz14); $neu->zusatz15 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz15); $neu->zusatz16 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz16); $neu->zusatz17 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz17); $neu->zusatz18 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz18); $neu->zusatz19 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz19); $neu->zusatz20 = MatukioHelperUtilsBasic::cleanHTMLfromText($neu->zusatz20); $neu->nrbooked = $nrbooked; if (!empty($event->fees)) { $neu->payment_method = "cash"; if ($nrbooked > 0) { $neu->payment_brutto = $event->fees * $nrbooked; } else { $neu->payment_brutto = $event->fees; } } if (!$neu->check()) { return JError::raiseError(500, $database->stderr()); } if (!$neu->store()) { return JError::raiseError(500, $database->stderr()); } $neu->checkin(); $ueber1 = JText::_("COM_MATUKIO_BOOKING_WAS_SUCCESSFULL"); // Send new confirmation mail if ($notify_participant) { MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $neu->id, 11, false, $neu, $notify_participant_invoice); } switch ($this->task) { case 'apply': $msg = JText::_('COM_MATUKIO_BOOKING_FIELD_APPLY'); $link = 'index.php?option=com_matukio&controller=bookings&task=editBooking&booking_id=' . $neu->id; break; case 'save': default: $msg = JText::_('COM_MATUKIO_BOOKING_FIELD_SAVE'); $link = 'index.php?option=com_matukio&view=bookings'; break; } $this->setRedirect($link, $msg); }
$htx2 = "</del>)"; } // Beginn anzeigen if ($this->event->showbegin > 0) { $html .= "\n<tr>" . MatukioHelperUtilsEvents::getTableCell(JTEXT::_('COM_MATUKIO_BEGIN') . ':', 'd', 'l', '20%', 'sem_rowd') . MatukioHelperUtilsEvents::getTableCell($htx1 . JHTML::_('date', $this->event->begin, MatukioHelperSettings::getSettings('date_format', 'd-m-Y, H:i')) . MatukioHelperUtilsDate::getTimezone($this->event->begin) . $htx2, 'd', 'l', '80%', 'sem_rowd') . "</tr>"; } // Ende anzeigen if ($this->event->showend > 0) { $html .= "\n<tr>" . MatukioHelperUtilsEvents::getTableCell(JTEXT::_('COM_MATUKIO_END') . ':', 'd', 'l', '20%', 'sem_rowd') . MatukioHelperUtilsEvents::getTableCell($htx1 . JHTML::_('date', $this->event->end, MatukioHelperSettings::getSettings('date_format', 'd-m-Y, H:i')) . MatukioHelperUtilsDate::getTimezone($this->event->end) . $htx2, 'd', 'l', '80%', 'sem_rowd') . "</tr>"; } // Anmeldeschluss bzw. Buchungsdatum anzeigen if ($this->event->showbooked > 0) { if ($this->art == 0 or $this->art == 3 and $usrid == 0) { $html .= "\n<tr>" . MatukioHelperUtilsEvents::getTableCell(JTEXT::_('COM_MATUKIO_CLOSING_DATE') . ':', 'd', 'l', '20%', 'sem_rowd') . MatukioHelperUtilsEvents::getTableCell($htx1 . JHTML::_('date', $this->event->booked, MatukioHelperSettings::getSettings('date_format', 'd-m-Y, H:i')) . MatukioHelperUtilsDate::getTimezone($this->event->booked) . $htx2, 'd', 'l', '80%', 'sem_rowd') . "</tr>"; } else { $html .= "\n<tr>" . MatukioHelperUtilsEvents::getTableCell(JTEXT::_('COM_MATUKIO_DATE_OF_BOOKING') . ':', 'd', 'l', '20%', 'sem_rowd') . MatukioHelperUtilsEvents::getTableCell(JHTML::_('date', $buchopt[2][0]->bookingdate, MatukioHelperSettings::getSettings('date_format', 'd-m-Y, H:i')) . MatukioHelperUtilsDate::getTimezone($buchopt[2][0]->bookingdate), 'd', 'l', '80%', 'sem_rowd') . "</tr>"; } } // Seminarleiter anzeigen if (MatukioHelperSettings::getSettings('organizer_pages', 1)) { $organizer = MatukioHelperOrganizer::getOrganizer($this->event->publisher); if (!empty($organizer)) { $link = JRoute::_("index.php?option=com_matukio&view=organizer&id=" . $organizer->id . ":" . JFilterOutput::stringURLSafe($organizer->name)); $tmp = "<a href=\"" . $link . "\" title=\"" . $organizer->name . "\">"; $tmp .= $organizer->name; $tmp .= "</a>"; $html .= "\n<tr>" . MatukioHelperUtilsEvents::getTableCell(JTEXT::_('COM_MATUKIO_ORGANIZER') . ':', 'd', 'l', '20%', 'sem_rowd') . MatukioHelperUtilsEvents::getTableCell($tmp, 'd', 'l', '80%', 'sem_rowd') . "</tr>"; } } // Show teacher / tutor if ($this->event->teacher != "") {
/** * Displays the form * * @param string $tpl - The tmpl * * @return mixed|void */ public function display($tpl = null) { if (MatukioHelperSettings::getSettings('rss_feed', 1) == 0) { JError::raiseError(403, JText::_("ALERTNOTAUTH")); } $database = JFactory::getDBO(); $neudatum = MatukioHelperUtilsDate::getCurrentDate(); $where = array(); $database->setQuery("SELECT id, access FROM #__categories WHERE extension='" . JFactory::getApplication()->input->get('option') . "'"); $cats = $database->loadObjectList(); $allowedcat = array(); foreach ($cats as $cat) { if ($cat->access < 1) { $allowedcat[] = $cat->id; } } if (count($allowedcat) > 0) { $allowedcat = implode(',', $allowedcat); $where[] = "a.catid IN ({$allowedcat})"; } $where[] = "a.published = '1'"; $where[] = "a.end > '{$neudatum}'"; $where[] = "a.booked > '{$neudatum}'"; $database->setQuery("SELECT a.*, r.*, cat.title AS category FROM #__matukio_recurring AS r\r\n\t\t LEFT JOIN #__matukio AS a ON r.event_id = a.id\r\n\t\t LEFT JOIN #__categories AS cat ON cat.id = a.catid" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\nORDER BY r.begin ASC" . "\nLIMIT 0, 1000"); $rows = $database->loadObjectList(); $this->rows = $rows; parent::display($tpl); }