Ejemplo n.º 1
0
 /**
  * Certicates / revokes certification of the booking
  *
  * @throws  Exception - if query fails
  * @return  void
  */
 public function certificate()
 {
     $input = JFactory::getApplication()->input;
     $booking_ids = $input->get("cid", array(), 'array');
     $database = JFactory::getDBO();
     if (count($booking_ids)) {
         $uids = implode(',', $booking_ids);
         $database->setQuery("SELECT * FROM #__matukio_bookings WHERE id IN ({$uids})");
         $rows = $database->loadObjectList();
         if ($database->getErrorNum()) {
             throw new Exception($database->stderr(), 42);
         }
         foreach ($rows as $row) {
             if ($this->task == "certificate") {
                 $database->setQuery("UPDATE #__matukio_bookings SET certificated='1' WHERE id='{$row->id}'");
                 $certmail = 6;
             }
             if ($this->task == "uncertificate") {
                 $database->setQuery("UPDATE #__matukio_bookings SET certificated='0' WHERE id='{$row->id}'");
                 $certmail = 7;
             }
             if (!$database->execute()) {
                 throw new Exception($database->stderr(), 42);
             }
             $event = MatukioHelperUtilsEvents::getEventRecurring($row->semid);
             MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $row->id, $certmail);
         }
     }
     $link = 'index.php?option=com_matukio&view=bookings';
     $this->setRedirect($link);
 }
Ejemplo n.º 2
0
 /**
  * Generates the file and outputs it as $filetype
  *
  * @return  string
  */
 public function downloadFile()
 {
     $my = JFactory::getUser();
     $daten = trim(JFactory::getApplication()->input->get('a6d5dgdee4cu7eho8e7fc6ed4e76z', ''));
     $cid = substr($daten, 40);
     $dat = substr($daten, 0, 40);
     $kurs = MatukioHelperUtilsEvents::getEventRecurring($cid);
     $datfeld = MatukioHelperUtilsEvents::getEventFileArray($kurs);
     for ($i = 0; $i < count($datfeld[0]); $i++) {
         if (sha1(md5($datfeld[0][$i])) == $dat and ($datfeld[2][$i] == 0 or $my->id > 0 and $datfeld[2][$i] > 0)) {
             $datname = $datfeld[0][$i];
             $datcode = "file" . ($i + 1) . "code";
             $daten = base64_decode($kurs->{$datcode});
             $datext = array_pop(explode(".", strtolower($datname)));
             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
             header("Pragma: public");
             header("Content-Type: application/{$datext}");
             header("Content-Disposition: inline; filename=\"{$datname}\"");
             header("Content-Length: " . strlen($daten));
             echo $daten;
             exit;
         }
     }
 }
Ejemplo n.º 3
0
 public static function generateCSVFile($backend, $cid = 0, $bookings = null, $kurs = null)
 {
     $db = JFactory::getDbo();
     // Load event only if we are not in the backend / or got an whole event to print
     if (!$backend) {
         $kurs = MatukioHelperUtilsEvents::getEventRecurring($cid);
     }
     $tmpl = MatukioHelperTemplates::getTemplate("export_csv");
     if (!empty($kurs)) {
         $db->setQuery("SELECT a.*, cc.*, a.id AS sid, a.name AS aname, a.email AS aemail FROM #__matukio_bookings AS a " . "LEFT JOIN #__users AS cc ON cc.id = a.userid WHERE a.semid = '" . $kurs->id . "' AND (a.status = 0 OR a.status = 1) ORDER BY a.id");
     } elseif (count($bookings)) {
         $db->setQuery("SELECT a.*, cc.*, a.id AS sid, a.name AS aname, a.email AS aemail FROM #__matukio_bookings AS a " . "LEFT JOIN #__users AS cc ON cc.id = a.userid WHERE a.id IN (" . implode(",", $bookings) . ") ORDER BY a.id");
     } else {
         throw new Exception("No data supplied (bookings / event)");
     }
     $bookings = $db->loadObjectList();
     if ($db->getErrorNum()) {
         throw new Exception($db->stderr());
     }
     $csvdata = MatukioHelperTemplates::getCSVHeader($tmpl, $kurs);
     $csvdata .= MatukioHelperTemplates::getCSVData($tmpl, $bookings, $kurs);
     return $csvdata;
 }
Ejemplo n.º 4
0
<?php

/**
 * @package    Matukio
 * @author     Yves Hoppe <*****@*****.**>
 * @date       29.01.14
 *
 * @copyright  Copyright (C) 2008 - 2014 compojoom.com . All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */
defined('_JEXEC') or die('Restricted access');
$database = JFactory::getDBO();
if (!empty($this->uuid)) {
    $database->setQuery("SELECT * FROM #__matukio_bookings WHERE uuid='" . $this->uuid . "'");
}
$booking = $database->loadObject();
$kurs = MatukioHelperUtilsEvents::getEventRecurring($booking->semid);
$tmpl_code = MatukioHelperTemplates::getTemplate("ticket")->value;
// Parse language strings
$tmpl_code = MatukioHelperTemplates::replaceLanguageStrings($tmpl_code);
$replaces = MatukioHelperTemplates::getReplaces($kurs, $booking);
foreach ($replaces as $key => $replace) {
    $tmpl_code = str_replace($key, $replace, $tmpl_code);
}
$subject = "TICKET";
MatukioHelperPDF::generateTicket($booking, $tmpl_code, $subject);
exit;
Ejemplo n.º 5
0
 /**
  * Cancels an recurring event and notfies (if enabled) all participants
  *
  * @param   array  $ids        - Array of recurring events
  * @param   int    $cancelled  - Should it be cancelled or reactivated?
  *
  * @return  bool
  * @throws  Exception on Error
  */
 public static function cancelRecurringEvents($ids, $cancelled)
 {
     if (count($ids)) {
         // First update event
         $db = JFactory::getDbo();
         $cids = implode(',', $ids);
         $db->setQuery("UPDATE #__matukio_recurring SET cancelled = '" . $cancelled . "' WHERE id IN (" . $cids . ") ");
         if (!$db->execute()) {
             throw new Exception($db->getErrorMsg(), 42);
         }
         if (MatukioHelperSettings::_("booking_stornoconfirmation", 1)) {
             // Set bookings to deleted
             $db->setQuery("UPDATE #__matukio_bookings SET status = " . MatukioHelperUtilsBooking::$DELETED . " WHERE semid IN (" . $cids . ")");
             $db->execute();
             // Notify participants over the change
             $db->setQuery("SELECT * FROM #__matukio_bookings WHERE semid IN (" . $cids . ")");
             $rows = $db->loadObjectList();
             if ($db->getErrorNum()) {
                 throw new Exception($db->getErrorMsg(), 42);
             }
             foreach ($rows as $row) {
                 $event = MatukioHelperUtilsEvents::getEventRecurring($row->semid);
                 if ($cancelled == 0) {
                     MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $row->id, 9);
                 } else {
                     MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $row->id, 10);
                 }
             }
         }
     }
     return true;
 }
Ejemplo n.º 6
0
 * @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');
$backend = true;
if (!isset($this->backend)) {
    $backend = false;
}
$kurs = null;
// Load event only if we are not in the backend / or got an whole event to print
if (!$backend) {
    $kurs = MatukioHelperUtilsEvents::getEventRecurring($this->cid);
}
if (!isset($this->cid)) {
    $this->cid = 0;
}
if (!isset($this->bookings)) {
    $this->bookings = null;
}
$konvert = MatukioHelperSettings::getSettings('csv_export_charset', 'UTF-8');
header("Content-Encoding: " . $konvert);
header("Content-Type: text/csv; charset=" . $konvert);
if (!empty($kurs)) {
    header("Content-Disposition: attachment; filename=\"" . $kurs->title . ".csv\"");
} else {
    $filename = "bookings-" . JHTML::_('date', 'now', MatukioHelperSettings::getSettings('date_format_without_time', 'd-m-Y')) . ".csv";
    header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
Ejemplo n.º 7
0
 /**
  * Removes an or multiple events
  *
  * @throws  Exception - If db queries fail
  * @return void
  */
 public function remove()
 {
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     $db = JFactory::getDBO();
     if (count($cid)) {
         $cids = implode(',', $cid);
         // Notify users
         if (MatukioHelperSettings::_("notify_participants_delete", 1)) {
             $db->setQuery("SELECT * FROM #__matukio_bookings WHERE id IN (" . $cids . ")");
             $bookings = $db->loadObjectList();
             if ($db->getErrorNum()) {
                 throw new Exception($db->getErrorMsg(), 42);
             }
             foreach ($bookings as $b) {
                 $event = MatukioHelperUtilsEvents::getEventRecurring($b->semid);
                 MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $b->id, 4);
             }
         }
         // Delete events
         $query = "DELETE FROM #__matukio_recurring where id IN (" . $cids . ")";
         $db->setQuery($query);
         if (!$db->execute()) {
             throw new Exception($db->getErrorMsg(), 42);
         }
         // Delete old bookings
         $db->setQuery("DELETE FROM #__matukio_bookings WHERE semid IN (" . $cids . ")");
         if (!$db->execute()) {
             throw new Exception($db->getErrorMsg(), 42);
         }
     }
     $msg = JText::_("COM_MATUKIO_DELETE_SUCCESS");
     $this->setRedirect('index.php?option=com_matukio&view=recurring', $msg);
 }
Ejemplo n.º 8
0
 * @copyright  Copyright (C) 2008 - 2013 Yves Hoppe - compojoom.com . All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE
 */
defined('_JEXEC') or die('Restricted access');
// We need Bootstrap since 3.0
MatukioHelperUtilsBasic::bootstrap();
if (JVERSION > 2.5) {
    JHtml::_('formbehavior.chosen', 'select');
}
JHTML::_('behavior.tooltip');
// Load formvalidator!
JHtml::_('behavior.formvalidation');
JHTML::_('stylesheet', 'media/com_matukio/css/strapper.css');
JHTML::_('stylesheet', 'media/com_matukio/backend/css/matukio.css');
// Load event (use events helper function)
$event = MatukioHelperUtilsEvents::getEventRecurring($this->booking->semid);
?>
	<div class="compojoom-bootstrap">
		<div id="matukio" class="matukio">
			<form action="index.php" method="post" name="adminForm" id="adminForm" class="form" enctype="multipart/form-data">
			<div class="row-fluid">
				<div class="span8">
				<legend><?php 
echo JText::_('COM_MATUKIO_EDIT_BOOKING');
?>
</legend>
				<table class="mat_table table">
					<tr>
						<td align="left" class="key">
							<?php 
echo JText::_('COM_MATUKIO_USER');
 /**
  * Change the booking status
  *
  * @param   array    $cid                - The cid
  * @param   int      $status             - The status to which the booking should be changed
  * @param   boolean  $notifyParticipant  - Should the participant be notified (by email)
  *
  * @throws  Exception - DB Error
  *
  * @return  bool
  */
 public static function changeStatusBooking($cid, $status = 1, $notifyParticipant = true)
 {
     if (count($cid)) {
         $db = JFactory::getDBO();
         $cids = implode(',', $cid);
         $db->setQuery("UPDATE #__matukio_bookings SET status = " . $db->quote($status) . " WHERE id IN (" . $cids . ")");
         if (!$db->execute()) {
             throw new Exception($db->getErrorMsg(), 42);
         }
         if ($notifyParticipant) {
             $db->setQuery("SELECT * FROM #__matukio_bookings WHERE id IN (" . $cids . ")");
             $bookings = $db->loadObjectList();
             if ($db->getErrorNum()) {
                 throw new Exception($db->getErrorMsg(), 42);
             }
             foreach ($bookings as $b) {
                 $event = MatukioHelperUtilsEvents::getEventRecurring($b->semid);
                 if ($status == self::$ACTIVE) {
                     // Notify users of the activation
                     MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $b->id, 1, false, $b);
                 } elseif ($status == self::$DELETED) {
                     // Notify users of the organizer delete
                     MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $b->id, 3, false, $b);
                 } elseif ($status == self::$PENDING) {
                     // Notify users of the organizer delete
                     MatukioHelperUtilsEvents::sendBookingConfirmationMail($event, $b->id, 1, false, $b);
                 } else {
                     throw new Exception("Uknown Status: " . $status, "42");
                 }
             }
         }
     }
     return true;
 }
 /**
  * Generates the CSV Data
  *
  * @param   object  $template  - The template
  * @param   array   $bookings  - The bookings
  * @param   object  $event     - The event
  *
  * @return string
  */
 public static function getCSVData($template, $bookings, $event)
 {
     $header_text = $template->value;
     $csvdata = "";
     $mixed = false;
     foreach ($bookings as $booking) {
         if (empty($event)) {
             $event = MatukioHelperUtilsEvents::getEventRecurring($booking->semid);
             $mixed = true;
         }
         $replaces = self::getReplaces($event, $booking);
         $line = $header_text;
         foreach ($replaces as $key => $replace) {
             $val = str_replace("\n", " ", $replace);
             $val = str_replace("\r", " ", $val);
             $line = str_replace($key, $val, $line);
         }
         $csvdata .= $line;
         $csvdata .= "\r\n";
         if ($mixed) {
             $event = null;
         }
     }
     return $csvdata;
 }
Ejemplo n.º 11
0
 /**
  * Saves the form
  *
  * @throws  Exception
  * @return  object
  */
 public function save()
 {
     $input = JFactory::getApplication()->input;
     if ($input->getInt("oldform", 0) == 1) {
         $this->saveOld();
         return;
     }
     $database = JFactory::getDBO();
     $dispatcher = JDispatcher::getInstance();
     // Backend
     $art = 4;
     $event_id = $input->getInt('event_id', 0);
     $uid = $input->getInt('uid', 0);
     $userid = $input->getInt('userid', 0);
     $id = $input->getInt("id", 0);
     $notify_participant = $input->getInt("notify_participant", 0);
     $notify_participant_invoice = $input->getInt("notify_participant_invoice", 0);
     $payment_method = $input->get('payment', '', 'string');
     if (empty($event_id)) {
         JError::raiseError(404, 'COM_MATUKIO_NO_ID');
     }
     // Load event (use events helper function)
     $event = MatukioHelperUtilsEvents::getEventRecurring($event_id);
     // Different fees @since 3.0
     $different_fees = $event->different_fees;
     $reason = "";
     if (!empty($uid)) {
         if ($uid < 0) {
             // Setting booking to changed booking
             $userid = $uid;
             // uid = Negativ
         }
     }
     // Checking old required fields - backward compatibilty - only frontend - we allow everything here..
     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;
     $firstname = $input->get('firstname', '', 'string');
     $lastname = $input->get('lastname', '', 'string');
     if (empty($id)) {
         $neu->bookingdate = MatukioHelperUtilsDate::getCurrentDate();
     }
     $neu->name = trim($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)) {
             $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));
                     $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 {
                         // Raise an error
                         JError::raise(E_ERROR, 500, JText::_("COM_MATUKIO_INVALID_COUPON_CODE"));
                     }
                 }
                 $neu->payment_brutto = $payment_brutto;
             } else {
                 // Different fees @since 3.0
                 $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);
             }
             // 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);
     if (!$neu->check()) {
         return JError::raiseError(500, $database->stderr());
     }
     if (!$neu->store()) {
         return JError::raiseError(500, $database->stderr());
     }
     $neu->checkin();
     $results = $dispatcher->trigger('onAfterBooking', $neu, $event);
     $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, $notify_participant_invoice);
     }
     switch ($this->task) {
         case 'apply':
             $msg = JText::_('COM_MATUKIO_BOOKING_APPLY');
             $link = 'index.php?option=com_matukio&controller=editbooking&task=editBooking&booking_id=' . $neu->id;
             break;
         case 'save':
         default:
             $msg = JText::_('COM_MATUKIO_BOOKING_SAVE');
             $link = 'index.php?option=com_matukio&view=bookings';
             break;
     }
     $this->setRedirect($link, $msg);
 }