+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL Start: 06/29/2004 *
+ * =================== Last change: 06/29/2004 *
+ * *
+ * -------------------------------------------------------------------- *
+ * File : what-list_coupon.php *
+ * -------------------------------------------------------------------- *
+ * Short description : List all cashed coupons *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung : Alle eingeloesten Gutscheine auflisten *
+ * -------------------------------------------------------------------- *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team *
+ * For more information visit: http://www.mxchange.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+ die();
+} elseif (!isMember()) {
+ redirectToIndexMemberOnlyModule();
+}
+
+// Add description as navigation point
+addYouAreHereLink('member', __FILE__);
+
+// Continue only if the proper extension is active (admins can always continue)
+if ((!isExtensionActive('coupon')) && (!isAdmin())) {
+ displayMessage(generateExtensionInactiveNotInstalledMessage('coupon'));
+ return;
+} // END - if
+
+// Check if the user has cashed coupons
+$result = SQL_QUERY_ESC("SELECT
+ UNIX_TIMESTAMP(u.`cashed_on`) AS `cashed_on`,
+ UNIX_TIMESTAMP(d.`coupon_created`) AS `coupon_created`,
+ UNIX_TIMESTAMP(d.`coupon_expired`) AS `coupon_expired`,
+ d.`points`, d.`total_created`, d.`total_cashed`, d.`coupon_description`
+FROM
+ `{?_MYSQL_PREFIX?}_user_coupons` AS u
+INNER JOIN
+ `{?_MYSQL_PREFIX?}_coupon_data` AS d
+ON
+ u.`coupon_id`=d.`id`
+WHERE
+ u.`userid`=%s AND
+ u.`coupon_code` IS NULL AND
+ u.`cashed_on` IS NOT NULL
+ORDER BY
+ u.`cashed_on` DESC", array(getMemberId()), __FILE__, __LINE__);
+
+// Do we have entries?
+if (SQL_NUMROWS($result) > 0) {
+ // Init variable
+ $OUT = '';
+
+ // Load all rows
+ while ($content = SQL_FETCHARRAY($result)) {
+ // Translate all timestamps
+ $content['cashed_on'] = generateDateTime($content['cashed_on'] , '2');
+ $content['coupon_created'] = generateDateTime($content['coupon_created'], '2');
+ $content['coupon_expired'] = generateDateTime($content['coupon_expired'], '2');
+
+ // Add the row template
+ $OUT .= loadTemplate('member_list_coupon_row', true, $content);
+ } // END - while
+
+ // Load main template
+ loadTemplate('member_list_coupon', false, $OUT);
+} else {
+ // No cashed coupons found
+ displayMessage('{--MEMBER_COUPON_CASHED_404--}');
+}
+
+// Free result
+SQL_FREERESULT($result);
+
+// [EOF]
+?>