function qem_process_payment_form($values)
{
    $payments = qem_get_stored_payment();
    global $post;
    $page_url = qem_current_page_url();
    $reference = $post->post_title;
    $paypalurl = 'https://www.paypal.com/cgi-bin/webscr';
    $cost = get_post_meta($post->ID, 'event_cost', true);
    $cost = preg_replace('/[^.0-9]/', '', $cost);
    $quantity = $values['yourplaces'] < 1 ? 1 : strip_tags($values['yourplaces']);
    $redirect = get_post_meta($post->ID, 'event_redirect', true);
    if (!$redirect && $register['redirectionurl']) {
        $redirect = $register['redirectionurl'];
    }
    $redirect = $redirect ? $redirect : $page_url;
    if ($payments['useprocess'] && $payments['processtype'] == 'processpercent') {
        $percent = preg_replace('/[^.,0-9]/', '', $payments['processpercent']) / 100;
        $handling = $cost * $quantity * $percent;
    }
    if ($payments['useprocess'] && $payments['processtype'] == 'processfixed') {
        $handling = preg_replace('/[^.,0-9]/', '', $payments['processfixed']);
    }
    if ($payments['usecoupon']) {
        $coupon = qem_get_stored_coupon();
        for ($i = 1; $i <= 10; $i++) {
            if ($values['couponcode'] == $coupon['code' . $i]) {
                if ($coupon['coupontype' . $i] == 'percent' . $i) {
                    $cost = $cost - $cost * $coupon['couponpercent' . $i] / 100;
                }
                if ($coupon['coupontype' . $i] == 'fixed' . $i) {
                    $cost = $cost - $coupon['couponfixed' . $i];
                }
            }
        }
    }
    $content = '<h2 id="qem_reload">' . $payments['waiting'] . '</h2>
    <form action="' . $paypalurl . '" method="post" name="qempay" id="qempay">
    <input type="hidden" name="cmd" value="_xclick">
    <input type="hidden" name="item_name" value="' . $reference . '"/>
    <input type="hidden" name="business" value="' . $payments['paypalemail'] . '">
    <input type="hidden" name="return" value="' . $redirect . '">
    <input type="hidden" name="cancel_return" value="' . $page_url . '">
    <input type="hidden" name="currency_code" value="' . $payments['currency'] . '">
    <input type="hidden" name="item_number" value="' . strip_tags($values['yourname']) . '">
    <input type="hidden" name="quantity" value="' . $quantity . '">
    <input type="hidden" name="amount" value="' . $cost . '">
    <input type="hidden" name="custom" value="' . $values['ipn'] . '">';
    if ($payments['useprocess']) {
        $content .= '<input type="hidden" name="handling" value="' . $handling . '">';
    }
    $content .= '</form>
    <script language="JavaScript">document.getElementById("qempay").submit();</script>';
    return $content;
}
function qem_ipn()
{
    $payment = qem_get_stored_payment();
    if (!$payment['ipn']) {
        return;
    }
    define("DEBUG", 1);
    define("LOG_FILE", "./ipn.log");
    $raw_post_data = file_get_contents('php://input');
    $raw_post_array = explode('&', $raw_post_data);
    $myPost = array();
    foreach ($raw_post_array as $keyval) {
        $keyval = explode('=', $keyval);
        if (count($keyval) == 2) {
            $myPost[$keyval[0]] = urldecode($keyval[1]);
        }
    }
    $req = 'cmd=_notify-validate';
    if (function_exists('get_magic_quotes_gpc')) {
        $get_magic_quotes_exists = true;
    }
    foreach ($myPost as $key => $value) {
        if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
            $value = urlencode(stripslashes($value));
        } else {
            $value = urlencode($value);
        }
        $req .= "&{$key}={$value}";
    }
    if ($payment['sandbox']) {
        $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
    } else {
        $paypal_url = "https://www.paypal.com/cgi-bin/webscr";
    }
    $ch = curl_init($paypal_url);
    if ($ch == FALSE) {
        return FALSE;
    }
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
    if (DEBUG == true) {
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
    }
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
    $res = curl_exec($ch);
    if (curl_errno($ch) != 0) {
        if (DEBUG == true) {
            error_log(date('[Y-m-d H:i e] ') . "Can't connect to PayPal to validate IPN message: " . curl_error($ch) . PHP_EOL, 3, LOG_FILE);
        }
        curl_close($ch);
        exit;
    } else {
        if (DEBUG == true) {
            error_log(date('[Y-m-d H:i e] ') . "HTTP request of validation request:" . curl_getinfo($ch, CURLINFO_HEADER_OUT) . " for IPN payload: {$req}" . PHP_EOL, 3, LOG_FILE);
            error_log(date('[Y-m-d H:i e] ') . "HTTP response of validation request: {$res}" . PHP_EOL, 3, LOG_FILE);
        }
        curl_close($ch);
    }
    $tokens = explode("\r\n\r\n", trim($res));
    $res = trim(end($tokens));
    if (strcmp($res, "VERIFIED") == 0) {
        $custom = $_POST['custom'];
        $args = array('post_type' => 'event');
        query_posts($args);
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $id = get_the_id();
                $message = get_option('qem_messages_' . $id);
                if ($message) {
                    $count = count($message);
                    for ($i = 0; $i <= $count; $i++) {
                        if ($message[$i]['ipn'] == $custom) {
                            $message[$i]['ipn'] = 'Paid';
                            update_option('qem_messages_' . $id, $message);
                        }
                    }
                }
            }
        }
        if (DEBUG == true) {
            error_log(date('[Y-m-d H:i e] ') . "Verified IPN: {$req} " . PHP_EOL, 3, LOG_FILE);
        }
    } else {
        if (strcmp($res, "INVALID") == 0) {
            if (DEBUG == true) {
                error_log(date('[Y-m-d H:i e] ') . "Invalid IPN: {$req}" . PHP_EOL, 3, LOG_FILE);
            }
        }
    }
}
function event_details_meta()
{
    global $post;
    $event = event_get_stored_options();
    $register = qem_get_stored_register();
    $payment = qem_get_stored_payment();
    $display = event_get_stored_display();
    $eventdate = get_event_field('event_date');
    if (empty($eventdate)) {
        $eventdate = time();
    }
    $date = date("d M Y", $eventdate);
    $localdate = date_i18n("d M Y", $eventdate);
    $eventenddate = get_event_field('event_end_date');
    if ($eventenddate) {
        $enddate = date("d M Y", $eventenddate);
        $localenddate = date_i18n("d M Y", $eventenddate);
    }
    if ($register['useform'] && !get_event_field("event_register")) {
        $useform = 'checked';
    } else {
        $useform = get_event_field("event_register");
    }
    $usepaypal = '';
    if ($register['paypal'] && !get_event_field('event_date') || get_event_field('event_paypal') == 'checked') {
        $usepaypal = 'checked';
    }
    $output .= '<p><em>' . __('Empty fields are not displayed', 'quick-event-manager') . ' ' . __('See the plugin', 'quick-event-manager') . ' <a href="options-general.php?page=quick-event-manager/settings.php">' . __('settings', 'quick-event-manager') . '</a> ' . __('page for options', 'quick-event-manager') . '.</em></p>
    <p>Event ID: ' . $post->ID . '</p>
    <table width="100%">
    <tr>
    <td width="20%"><label>' . __('Date', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="border:1px solid #415063;" id="qemdate" name="event_date" value="' . $date . '" /> <em>' . __('Local date', 'quick-event-manager') . ': ' . $localdate . '</em>.</td>
    <script type="text/javascript">jQuery(document).ready(function() {jQuery(\'#qemdate\').datepicker({dateFormat : \'dd M yy\'});});</script>
    </tr>
    <tr>
    <td width="20%"><label>' . __('End Date', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="border:1px solid #415063;"  id="qemenddate" name="event_end_date" value="' . $enddate . '" /> <em>' . __('Leave blank for one day events', 'quick-event-manager') . '.</em>';
    if ($eventenddate) {
        $output .= ' <em>' . __('Current end date', 'quick-event-manager') . ': ' . $localenddate . '</em>';
    }
    $output .= '</td>
    <script type="text/javascript">jQuery(document).ready(function() {jQuery(\'#qemenddate\').datepicker({dateFormat : \'dd M yy\'});});</script>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Short Description', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="width:100%;border:1px solid #415063;" name="event_desc" value="' . get_event_field("event_desc") . '" />
    </td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Time', 'quick-event-manager') . '</label></td>
    <td width="80%">' . $event['start_label'] . ' <input type="text" class="qem_input" style="border:1px solid #415063;"  name="event_start" value="' . get_event_field("event_start") . '" /> ' . $event['finish_label'] . ' <input type="text" style="width:40%;overflow:hidden;border:1px solid #415063;"   name="event_finish" value="' . get_event_field("event_finish") . '" /><br>
    <span class="description">Start times in the format 8.23 am/pm, 8.23, 8:23 and 08:23 will be used to order events by time and date. All other formats will display but won\'t contribute to the event ordering.</span> 
    </td>
    </tr>';
    if ($display['usetimezone']) {
        $tz = get_event_field("selected_timezone");
        ${$tz} = 'selected';
        $output .= '<tr>
		<td width="20%"><label>' . __('Timezone', 'quick-event-manager') . ': </label></td>
		<td width="80%">';
        if (get_event_field("event_timezone")) {
            $output .= '<b>Current timezone:</b> ' . get_event_field("event_timezone") . '.&nbsp;&nbsp;';
        }
        $output .= 'Select a new timezone or enter your own:<br>
        <select style="border:1px solid #415063;" name="event_timezone" id="event_timezone">
        <option value="">None</option>
        <option ' . $Eni . ' value="Eniwetok, Kwajalein">(GMT -12:00) Eniwetok, Kwajalein</option>       
        <option ' . $Mid . ' value="Midway Island, Samoa">(GMT -11:00) Midway Island, Samoa</option>       
        <option ' . $Hwa . ' value="Hawaii">(GMT -10:00) Hawaii</option>       
        <option ' . $Ala . ' value="Alaska">(GMT -9:00) Alaska</option>       
        <option ' . $Pac . ' value="Pacific Time (US &amp; Canada)">(GMT -8:00) Pacific Time (US &amp; Canada)</option>       
        <option ' . $Mou . ' value="Mountain Time (US &amp; Canada)">(GMT -7:00) Mountain Time (US &amp; Canada)</option>       
        <option ' . $Cen . ' value="Central Time (US &amp; Canada), Mexico City">(GMT -6:00) Central Time (US &amp; Canada), Mexico City</option>       
        <option ' . $Eas . ' value="Eastern Time (US &amp; Canada), Bogota, Lima">(GMT -5:00) Eastern Time (US &amp; Canada), Bogota, Lima</option>       
        <option ' . $Atl . ' value="Atlantic Time (Canada), Caracas, La Paz">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>       
        <option ' . $New . ' value="Newfoundland">(GMT -3:30) Newfoundland</option>       
        <option ' . $Bra . ' value="Brazil, Buenos Aires, Georgetown">(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>       
        <option ' . $Mia . ' value="Mid-Atlantic">(GMT -2:00) Mid-Atlantic</option>       
        <option ' . $Azo . ' value="Azores, Cape Verde Islands">(GMT -1:00 hour) Azores, Cape Verde Islands</option>       
        <option ' . $Wes . ' value="Western Europe Time, London, Lisbon, Casablanca">(GMT) Western Europe Time, London, Lisbon, Casablanca</option>       
        <option ' . $Bru . ' value="Brussels, Copenhagen, Madrid, Paris">(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris</option>       
        <option ' . $Kal . ' value="Kaliningrad, South Africa">(GMT +2:00) Kaliningrad, South Africa</option>       
        <option ' . $Bag . ' value="Baghdad, Riyadh, Moscow, St. Petersburg">(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>       
        <option ' . $Teh . ' value="Tehran">(GMT +3:30) Tehran</option>       
        <option ' . $Abu . ' value="Abu Dhabi, Muscat, Baku, Tbilisi">(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>       
        <option ' . $Kab . ' value="Kabul">(GMT +4:30) Kabul</option>       
        <option ' . $Eka . ' value="Ekaterinburg, Islamabad, Karachi, Tashkent">(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>       
        <option ' . $Bom . ' value="Bombay, Calcutta, Madras, New Delhi">(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option>       
        <option ' . $Kat . ' value="Kathmandu">(GMT +5:45) Kathmandu</option>       
        <option ' . $Alm . ' value="Almaty, Dhaka, Colombo">(GMT +6:00) Almaty, Dhaka, Colombo</option>       
        <option ' . $Ban . ' value="Bangkok, Hanoi, Jakarta">(GMT +7:00) Bangkok, Hanoi, Jakarta</option>       
        <option ' . $Bei . ' value="Beijing, Perth, Singapore, Hong Kong">(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>       
        <option ' . $Tok . ' value="Tokyo, Seoul, Osaka, Sapporo, Yakutsk">(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>       
        <option ' . $Ade . ' value="Adelaide, Darwin">(GMT +9:30) Adelaide, Darwin</option>       
        <option ' . $Aus . ' value="Eastern Australia, Guam, Vladivostok">(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>       
        <option ' . $Mag . ' value="Magadan, Solomon Islands, New Caledonia">(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>       
        <option ' . $Auk . ' value="Auckland, Wellington, Fiji, Kamchatka">(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option> 
        </select>
        <br><span class="description">The option to display timezones is set on the <a href="options-general.php?page=quick-event-manager/settings.php&tab=display">Event Display</a> page.</span>
    </td>
    </tr>';
    }
    $output .= '
    <tr>
    <td width="20%"><label>' . __('Venue', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="width:100%;border:1px solid #415063;"  name="event_location" value="' . get_event_field("event_location") . '" /></td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Address', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="width:100%;border:1px solid #415063;"  name="event_address" value="' . get_event_field("event_address") . '" /></td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Website', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="border:1px solid #415063;"  name="event_link" value="' . get_event_field("event_link") . '" /><label> ' . __('Display As', 'quick-event-manager') . ': </label><input type="text" style="width:40%;overflow:hidden;border:1px solid #415063;"  name="event_anchor" value="' . get_event_field("event_anchor") . '" /></td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Cost', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="width:100%;border:1px solid #415063;" name="event_cost" value="' . get_event_field("event_cost") . '" /></td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Organiser', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="width:100%;border:1px solid #415063;" name="event_organiser" value="' . get_event_field("event_organiser") . '" /></td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Organiser Contact Details', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="text" class="qem_input" style="width:100%;border:1px solid #415063;" name="event_telephone" value="' . get_event_field("event_telephone") . '" /></td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Registration Form', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="checkbox" style="" name="event_register" value="checked" ' . $useform . '> Add registration form to this event. <a href="options-general.php?page=quick-event-manager/settings.php&tab=register">Registration form settings</a><br>
    <span class="description">If you are using the <a href="options-general.php?page=quick-event-manager/settings.php&tab=auto">autoresponder</a> you can create a reply message for this event. See the \'Registration Confirmation Message\' at the bottom of this page.</span></td>
</tr>
<tr>
<td width="20%"><label>' . __('Redirect to a URL after registration', 'quick-event-manager') . ': </label></td>
<td width="80%"><input type="text" class="qem_input" style="border:1px solid #415063;" name="event_redirect" value="' . get_event_field("event_redirect") . '" /><br>
    <input type="checkbox" style="" name="event_redirect_id" value="checked" ' . get_event_field("event_redirect_id") . ' /> Add event ID to redirect URL<td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Event Counter', 'quick-event-manager') . ': </label></td>
    <td><input type="checkbox" style="" name="event_counter" value="checked" ' . get_event_field("event_counter") . '> Add an attendee counter to this form. Number of places available: <input type="text" class="qem_input" style="width:3em;border:1px solid #415063;" name="event_number" value="' . get_event_field("event_number") . '" /></td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Payment', 'quick-event-manager') . ': </label></td>
<td><input type="checkbox" name="event_paypal" value="checked" ' . $usepaypal . ' /> Link to paypal after registration. <a href="options-general.php?page=quick-event-manager/settings.php&tab=payment">Payment settings</a>.</td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Hide Event', 'quick-event-manager') . ': </label></td>
    <td width="80%"><input type="checkbox" style="" name="hide_event" value="checked" ' . get_event_field("hide_event") . '> Hide this event in the event list (only display on the calendar).</td>
    </tr>
    <tr>
    <td width="20%"><label>' . __('Event Image', 'quick-event-manager') . ': </label></td>
    <td><input id="event_image" type="text" class="qem_input" style="border:1px solid #415063;" name="event_image" value="' . get_event_field("event_image") . '" />&nbsp;
    <input id="upload_event_image" class="button" type="button" value="Upload Image" /></td>
    </tr>';
    if (get_event_field("event_image")) {
        $output .= '<tr>
    <td></td>
    <td><img class="qem-image" src=' . get_event_field("event_image") . '></td>
    </tr>';
    }
    $output .= '<tr>
    <td style="vertical-align:top"><label>' . __('Repeat Event', 'quick-event-manager') . ': </label></td>
    <td><span style="color:red;font-weight:bold;">Warning:</span> Only use once or you will get lots of duplicated events<br />
    <input style="margin:0; padding:0; border:none" type="radio" name="event_repeat" value="repeatweekly" /> ' . __('Weekly', 'quick-event-manager') . '<br />
	<input style="margin:0; padding:0; border:none" type="radio" name="event_repeat" value="repeatmonthly" /> ' . __('Monthly', 'quick-event-manager') . '<br>
    Number of repetitions: <input type="text" class="qem_input" style="width:3em;border:1px solid #415063;" name="repeatnumber" value="12" /> (maximum 52)</td>
    </tr>';
    $event = get_the_ID();
    $title = get_the_title();
    $whoscoming = get_option('qem_messages_' . $event);
    if ($whoscoming) {
        foreach ($whoscoming as $item) {
            $event_names .= $item['yourname'] . ', ';
        }
        $event_names = substr($event_names, 0, -2);
        $output .= '<tr>
        <td>Attendees (names and emails collected from the <a href="options-general.php?page=quick-event-manager/settings.php&tab=register">registration form</a>)</td>
        <td><input type="text" class="qem_input" style="width:100%;border:1px solid #415063;" name="event_names" value="' . $event_names . '" /></td>
        </tr>
        <tr>
        <td></td>
        <td><a href="admin.php?page=quick-event-manager/quick-event-messages.php&event=' . $event . '&title=' . $title . '">View Full Registration Details</a></td>
        <tr>';
    }
    $output .= '</table>';
    $output .= wp_nonce_field('qem_nonce', 'save_qem');
    echo $output;
}
Пример #4
0
function qem_coupon_codes()
{
    if (isset($_POST['Submit']) && check_admin_referer("save_qem")) {
        $options = array('code', 'coupontype', 'couponpercent', 'couponfixed');
        for ($i = 1; $i <= 10; $i++) {
            foreach ($options as $item) {
                $coupon[$item . $i] = stripslashes($_POST[$item . $i]);
            }
            if (!$coupon['coupontype' . $i]) {
                $coupon['coupontype' . $i] = 'percent' . $i;
            }
            if (!$coupon['couponpercent' . $i]) {
                $coupon['couponpercent' . $i] = '10';
            }
            if (!$coupon['couponfixed' . $i]) {
                $coupon['couponfixed' . $i] = '5';
            }
        }
        update_option('qem_coupon', $coupon);
        qem_admin_notice("The coupon settings have been updated");
    }
    if (isset($_POST['Reset']) && check_admin_referer("save_qem")) {
        delete_option('qem_coupon');
        qem_admin_notice("The coupon settings have been reset");
    }
    $payment = qem_get_stored_payment();
    $before = array('USD' => '&#x24;', 'CDN' => '&#x24;', 'EUR' => '&euro;', 'GBP' => '&pound;', 'JPY' => '&yen;', 'AUD' => '&#x24;', 'BRL' => 'R&#x24;', 'HKD' => '&#x24;', 'ILS' => '&#x20aa;', 'MXN' => '&#x24;', 'NZD' => '&#x24;', 'PHP' => '&#8369;', 'SGD' => '&#x24;', 'TWD' => 'NT&#x24;', 'TRY' => '&pound;');
    $after = array('CZK' => 'K&#269;', 'DKK' => 'Kr', 'HUF' => 'Ft', 'MYR' => 'RM', 'NOK' => 'kr', 'PLN' => 'z&#322', 'RUB' => '&#1056;&#1091;&#1073;', 'SEK' => 'kr', 'CHF' => 'CHF', 'THB' => '&#3647;');
    foreach ($before as $item => $key) {
        if ($item == $payment['currency']) {
            $b = $key;
        }
    }
    foreach ($after as $item => $key) {
        if ($item == $payment['currency']) {
            $a = $key;
        }
    }
    $coupon = qem_get_stored_coupon();
    $content = '<div class="qem-settings"><div class="qem-options">';
    $content .= '<h2>' . __('Coupons Codes', 'quick-event-manager') . '</h2>';
    $content .= '<form method="post" action="">
    <p<span<b>Note:</b>&nbsp;' . __('Leave fields blank if you don\'t want to use them', 'quick-event-manager') . '</span></p>
    <table width="100%">
    <tr>
    <td>' . __('Coupon Code', 'quick-event-manager') . '</td>
    <td>' . __('Percentage', 'quick-event-manager') . '</td>
    <td>' . __('Fixed Amount', 'quick-event-manager') . '</td>
    </tr>';
    for ($i = 1; $i <= $coupon['couponnumber']; $i++) {
        $percent = $coupon['coupontype' . $i] == 'percent' . $i ? 'checked' : '';
        $fixed = $coupon['coupontype' . $i] == 'fixed' . $i ? 'checked' : '';
        $content .= '<tr>
        <td><input type="text" name="code' . $i . '" value="' . $coupon['code' . $i] . '" /></td>
        <td><input type="radio" name="coupontype' . $i . '" value="percent' . $i . '" ' . $percent . ' /> <input type="text" style="width:4em;padding:2px" label="couponpercent' . $i . '" name="couponpercent' . $i . '" value="' . $coupon['couponpercent' . $i] . '" /> %</td>
        <td><input type="radio" name="coupontype' . $i . '" value="fixed' . $i . '" ' . $fixed . ' />&nbsp;' . $b . '&nbsp;<input type="text" style="width:4em;padding:2px" label="couponfixed' . $i . '" name="couponfixed' . $i . '" value="' . $coupon['couponfixed' . $i] . '" /> ' . $a . '</td>
        </tr>';
    }
    $content .= '</table>
    <p><input type="submit" name="Submit" class="button-primary" style="color: #FFF;" value="Save Changes" /> <input type="submit" name="Reset" class="button-primary" style="color: #FFF;" value="Reset" onclick="return window.confirm( \'Are you sure you want to reset the coupon codes?\' );"/></p>';
    $content .= wp_nonce_field("save_qem");
    $content .= '</form>
    </div>
    </div>';
    echo $content;
}
function qem_qpp_places()
{
    global $post;
    $payment = qem_get_stored_payment();
    if ($payment['qppcounter']) {
        $event = get_the_ID();
        $values = array('yourplaces' => 1);
        qem_place_number($event, $values);
    }
}