/** * Administer user registrations. * This will appear in the admin area for administrators, and as part of * the event detail for event owners. Owners can delete registrations. * * @param integer $rp_id Repeat ID being viewed or checked * @return string HTML for admin list */ function EVLIST_adminRSVP($rp_id) { global $LANG_EVLIST, $LANG_ADMIN, $_TABLES, $_CONF, $_IMAGE_TYPE; /* +-------------------+----------+-------------------+-------+-------+-------+-----+------+------+ | tic_id | tic_type | ev_id | rp_id | fee | paid | uid | used | dt | +-------------------+----------+-------------------+-------+-------+-------+-----+------+------+ | 20150209083155975 | 1 | 20150209081055236 | 7552 | 15.00 | 15.00 | 3 | 0 | 0 | +-------------------+----------+-------------------+-------+-------+-------+-----+------+------+ 1 row in set (0.00 sec) */ USES_lib_admin(); USES_evlist_class_repeat(); $Ev = new evRepeat($rp_id); if ($Ev->rp_id == 0) { return ''; } DB_query("SET @tk_count = 0;"); $sql = "SELECT @tk_count := @tk_count +1 as tic_count,\n tk.dt, tk.tic_id, tk.tic_type, tk.rp_id, tk.fee, tk.paid,\n tk.uid, tk.used, tt.description, u.fullname,\n {$Ev->Event->options['max_rsvp']} as max_rsvp\n FROM {$_TABLES['evlist_tickets']} tk\n LEFT JOIN {$_TABLES['evlist_tickettypes']} tt\n ON tt.id = tk.tic_type\n LEFT JOIN {$_TABLES['users']} u\n ON u.uid = tk.uid\n WHERE tk.ev_id = '{$Ev->Event->id}' "; $title = $LANG_EVLIST['pi_title'] . ': ' . $LANG_EVLIST['admin_rsvp'] . ' -- ' . COM_createLink($Ev->Event->Detail->title . ' (' . $Ev->date_start . ')', EVLIST_URL . '/event.php?eid=' . $rp_id); $title .= ' <a href="' . $_CONF['site_admin_url'] . '/plugins/evlist/index.php?printtickets&eid=' . $Ev->ev_id . '" class="lgButton blue" target="_new">' . $LANG_EVLIST['print_tickets'] . '</a>'; $title .= ' <a href="' . $_CONF['site_admin_url'] . '/plugins/evlist/index.php?exporttickets&eid=' . $Ev->rp_id . '" class="lgButton blue">' . $LANG_EVLIST['export_list'] . '</a>'; if ($Ev->Event->options['use_reg'] == EV_RSVP_REPEAT) { $sql .= " AND rp_id = '{$Ev->rp_id}' "; } $defsort_arr = array('field' => 'dt', 'direction' => 'ASC'); $text_arr = array('has_menu' => false, 'has_extras' => false, 'title' => $title, 'form_url' => EVLIST_URL . '/event.php?rp_id=' . $rp_id, 'help_url' => ''); $header_arr = array(array('text' => $LANG_EVLIST['rsvp_date'], 'field' => 'dt', 'sort' => true), array('text' => $LANG_EVLIST['name'], 'field' => 'fullname', 'sort' => false), array('text' => $LANG_EVLIST['fee'], 'field' => 'fee', 'sort' => false), array('text' => $LANG_EVLIST['paid'], 'field' => 'paid', 'sort' => false), array('text' => $LANG_EVLIST['ticket_num'], 'field' => 'tic_id', 'sort' => false), array('text' => $LANG_EVLIST['date_used'], 'field' => 'used', 'sort' => false), array('text' => $LANG_EVLIST['waitlisted'], 'field' => 'tic_count', 'sort' => false)); $options_arr = array('chkdelete' => true, 'chkfield' => 'tic_id', 'chkname' => 'delrsvp', 'chkactions' => '<input data-uk-tooltip name="tickdelete" type="image" src="' . $_CONF['layout_url'] . '/images/admin/delete.' . $_IMAGE_TYPE . '" style="vertical-align:text-bottom;" title="' . $LANG_ADMIN['delete'] . '" class="gl_mootip"' . ' onclick="return confirm(\'' . $LANG_EVLIST['conf_del_item'] . '\');" /> ' . $LANG_ADMIN['delete'] . ' ' . '<input data-uk-tooltip name="tickreset" type="image" src="' . $_CONF['site_url'] . '/evlist/images/reset.png' . '" style="vertical-align:text-bottom;" title="' . $LANG_EVLIST['reset_usage'] . '" class="gl_mootip"' . ' onclick="return confirm(\'' . $LANG_EVLIST['conf_reset'] . '\');" /> ' . $LANG_EVLIST['reset_usage'] . '<input type="hidden" name="ev_id" value="' . $rp_id . '"/>'); $query_arr = array('sql' => $sql); $retval .= ADMIN_list('evlist', 'EVLIST_getField_rsvp', $header_arr, $text_arr, $query_arr, $defsort_arr, '', '', $options_arr); return $retval; }
$doc = evTicket::PrintTickets($eid, 0, $_USER['uid']); echo $doc; exit; } else { $content .= 'Function not available'; } break; case 'view': default: if (empty($eid)) { // Default action, view the calendar or event COM_setArgNames(array('eid', 'ts', 'range', 'cat')); $eid = COM_sanitizeID(COM_getArgument('eid'), false); } if (!empty($eid)) { USES_evlist_class_repeat(); $Rep = new evRepeat($eid); $pagetitle = COM_stripslashes($Rep->Event->title); if ($view == 'print') { $template = 'event_print'; $query = ''; } $query = isset($_GET['query']) ? $_GET['query'] : ''; $content .= $Rep->Detail('', $query, $template); } else { // Shouldn't be in this file without an event ID to display or edit echo COM_refresh(EVLIST_URL . '/index.php'); exit; } break; }
/** * Handle the purchase of a product via IPN message. * * @param array $args Array of item and IPN data * @param array &$output Return array * @param string &$svc_msg Unused * @return integer Return value */ function service_handlePurchase_evlist($args, &$output, &$svc_msg) { global $_TABLES, $LANG_PHOTO, $_CONF; $item = $args['item']; $paypal_data = $args['ipn_data']; $item_id = explode(':', $item['item_id']); $quantity = (int) $item['quantity']; // Must have an item ID following the plugin name if (!is_array($item_id) || !isset($item_id[1])) { return PLG_RET_ERROR; } // Initialize the output array $output = array('product_id' => $item['item_id'], 'name' => $item['name'], 'short_description' => $item['name'], 'price' => (double) $item['price'], 'expiration' => NULL, 'download' => 0, 'file' => ''); // User ID is provided in the 'custom' field, so make sure it's numeric. if (is_numeric($paypal_data['custom']['uid'])) { $uid = (int) $paypal_data['custom']['uid']; } else { $uid = 1; } // Initialize an array of payment info to log $pmt_info = array('type' => 'payment', 'payment_date' => $paypal_data['sql_date'], 'txn_id' => $paypal_data['txn_id'], 'amount' => (double) $item['price']); switch ($item_id[1]) { case 'eventfee': // Get event, ticket_type and repeat ID $item_parts = explode('/', $item_id[2]); if (count($item_parts) < 3) { return PLG_RET_ERROR; } $ev_id = $item_parts[0]; $tick_type = $item_parts[1]; $rp_id = $item_parts[2]; USES_evlist_class_tickettype(); USES_evlist_class_repeat(); // includes event class $TickType = new evTicketType($tick_type); $repeats = array(); if ($rp_id > 0) { $repeats[] = $rp_id; // Ticket to a single occurrence $Rp = new evRepeat($rp_id); $Ev = $Rp->Event; $dt_info = $Rp->start_date1 . ' ' . $Rp->start_time1; } else { // rp_id = 0, make sure it's an event pass if ($TickType->event_pass) { $Ev = new evEvent($ev_id); $dt_info = $Ev->date_start1 . ' ' . $Ev->time_start1; } else { return PLG_RET_ERROR; } } $ev_fee = (double) $Ev->options['tickets'][$tick_type]['fee']; $output['price'] = $ev_fee; $output['name'] = $TickType->description . ': ' . $Ev->Detail->title . ', ' . $dt_info; $output['short_description'] = $output['name']; // TODO: fix to handle qty > 1, need loop and calc per-item pmt amt. USES_evlist_class_ticket(); $unpaid = evTicket::MarkPaid($quantity, $ev_id, $rp_id, $uid); if ($unpaid < 0) { EVLIST_Log("ALERT: {$quantity} tickets paid for user {$uid} for event {$ev_id}, exceeds unpaid count by {$unpaid}"); } else { EVLIST_Log("{$quantity} tickets paid for user {$uid}, event {$ev_id}/{$rp_id}"); } /*$tick = new evTicket(); $tick->ev_id = $ev_id; $tick->tic_type = $tick_type; $tick->fee = $ev_fee; $tick->uid = $uid; $tick->paid = $tick->fee; //foreach ($repeats as $save_rp_id) { $tick->rp_id = $rp_id; $tick->Save(); //} //$tick_id = evTicket::Create($ev_id, $rp_id, $tick_type, $ev_fee, $uid); //evTicket::AddPayment($tick_id, $ev_fee); */ break; } return PLG_RET_OK; }
function X_EVLIST_adminRSVP($rp_id) { global $LANG_EVLIST, $LANG_ADMIN, $_TABLES; USES_lib_admin(); USES_evlist_class_repeat(); $Ev = new evRepeat($rp_id); if ($Ev->rp_id == 0) { return ''; } $sql = "SELECT rsvp_id, uid, rp_id, FROM_UNIXTIME(dt_reg) as dt\n FROM {$_TABLES['evlist_rsvp']}\n WHERE ev_id = '{$Ev->Event->id}' "; $title = $LANG_EVLIST['pi_title'] . ': ' . $LANG_EVLIST['admin_rsvp'] . ' -- ' . COM_createLink($Ev->Event->Detail->title . ' (' . $Ev->date_start . ')', EVLIST_URL . '/event.php?eid=' . $rp_id); if ($Ev->Event->options['use_rsvp'] == EV_RSVP_REPEAT) { $sql .= " rp_id = '{$Ev->rp_id}' "; } $defsort_arr = array('field' => 'dt_reg', 'direction' => 'ASC'); $text_arr = array('has_menu' => false, 'has_extras' => false, 'title' => $title, 'form_url' => EVLIST_ADMIN_URL . '/index.php?rp_id=' . $rp_id, 'help_url' => ''); $query_arr = array('table' => 'evlist_calendars', 'sql' => $sql); $header_arr = array(array('text' => $LANG_EVLIST['date'], 'field' => 'dt', 'sort' => true), array('text' => 'Name', 'field' => 'uid', 'sort' => false)); $options_arr = array('chkdelete' => true, 'chkfield' => 'rsvp_id', 'chkname' => 'delrsvp'); $retval .= ADMIN_list('evlist', 'EVLIST_getField_rsvp', $header_arr, $text_arr, $query_arr, $defsort_arr, '', '', $options_arr); return $retval; }
/** * Export tickets to a CSV file for a single occurrence * * @param integer $rp_id Repeat ID * @return string CSV file containing all tickets */ public static function ExportTickets($rp_id = '') { global $_CONF, $LANG_EVLIST; $retval = ''; // get the tickets, paid and unpaid. Need event id and uid. $tickets = self::GetTickets($ev_id, $rp_id, $uid); USES_evlist_class_repeat(); USES_evlist_class_tickettype(); $Rp = new evRepeat($rp_id); $header = array($LANG_EVLIST['ticket_num'], $LANG_EVLIST['rsvp_date'], $LANG_EVLIST['name'], $LANG_EVLIST['fee'], $LANG_EVLIST['paid'], $LANG_EVLIST['date_used'], $LANG_EVLIST['waitlisted']); $retval .= '"' . implode('","', $header) . '"' . "\n"; //$tic_types = array(); $counter = 0; $dt_tick = new Date('now', $_CONF['timezone']); $dt_used = new Date('now', $_CONF['timezone']); foreach ($tickets as $tic_id => $ticket) { $counter++; $dt_tick->setTimestamp($ticket->dt); $dt_used->setTimestamp($ticket->used); $values = array($tic_id, $dt_tick->toMySQL(), str_replace('"', "'", COM_getDisplayName($ticket->uid)), $ticket->fee, $ticket->paid, $ticket->used > $ticket->dt ? $dt_used->toMySQL() : '', $counter > $Rp->Event->options['max_rsvp'] ? 'Yes' : 'No'); $retval .= '"' . implode('","', $values) . '"' . "\n"; } return $retval; }