Exemplo n.º 1
0
| EasyShop - an easy e107 web shop  | adapted by nlstart
| formerly known as
|	jbShop - by Jesse Burns aka jburns131 aka Jakle
|	Plugin Support Site: e107.webstartinternet.com
|
|	For the e107 website system visit http://e107.org
|
|	Released under the terms and conditions of the
|	GNU General Public License (http://gnu.org).
+------------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) {
    exit;
}
// Get language file (assume that the English language file is always present)
include_lan(e_PLUGIN . 'easyshop/languages/' . e_LANGUAGE . '.php');
require_once 'includes/ipn_functions.php';
// Put shop preferences into an array
$shoppref = shop_pref();
// Determine current year
$shop_year = intval(date("Y", time()));
if ($shoppref['enable_ipn'] == 2) {
    // Only display status when PayPal IPN is enabled
    $count = $sql->db_Count("easyshop_ipn_orders", "(*)", "WHERE YEAR(FROM_UNIXTIME(phptimestamp))= {$shop_year} AND payment_status=\"Completed\" ");
    if ($count == "" || $count == NULL) {
        $count = 0;
    }
    if ($count > 0) {
        $text .= "<div style='padding-bottom: 2px;'><img src='" . e_PLUGIN . "easyshop/images/logo_16.png' style='width: 16px; height: 16px; vertical-align: bottom' alt='' /> {$shop_year} " . EASYSHOP_STS_01 . ": <a href='" . e_BASE . e_PLUGIN_ABS . "easyshop/admin_monitor.php'>" . $count . "</a></div>";
    }
}
Exemplo n.º 2
0
function report($action = "all", $limit = 5, $from = NULL, $to = NULL, $phpsessionid = NULL, $txn_id = NULL, $payer_email = NULL)
{
    $shop_pref = shop_pref();
    $set_currency_behind = $shop_pref['set_currency_behind'];
    // Define actual currency and position of currency character once
    $sql_rep = new db();
    $sql_rep->db_Select(DB_TABLE_SHOP_CURRENCY, "*", "currency_active=2");
    if ($row = $sql_rep->db_Fetch()) {
        $unicode_character = $row['unicode_character'];
        $paypal_currency_code = $row['paypal_currency_code'];
    }
    // Determine currency before or after amount
    if ($set_currency_behind == 1) {
        // Print currency after amount
        $unicode_character_before = "";
        $unicode_character_after = "&nbsp;" . $unicode_character;
    } else {
        $unicode_character_before = "&nbsp;" . $unicode_character . "&nbsp;";
        $unicode_character_after = "";
        // Print currency before amount in all other cases
    }
    //!isset($action)      ? $action = "all" : $action = "";
    $action == "all" ? $action = "" : ($action = " payer_status = '" . $action . " '");
    isset($from) ? $from = " (phptimestamp >= '" . $from . "' " : ($from = "");
    isset($to) ? $to = " AND phptimestamp <= '" . $to . "') " : ($to = "");
    isset($phpsessionid) ? $phpsessionid = " phpsessionid = '" . $phpsessionid . "' " : ($phpsessionid = "");
    isset($txn_id) ? $txn_id = " txn_id = '" . $txn_id . "' " : ($txn_id = "");
    isset($payer_email) ? $payer_email = " payer_email = '" . $payer_email . " '" : ($payer_email = "");
    $completed = $processing = $shopping = $escheck = $totals = $rxemail = $dupltxn = $various = 0;
    $arg = "1 " . $action . $phpsessionid . $txn_id . $payer_email . $from . $to . " ORDER BY phptimestamp DESC";
    $count_ipn_rows = $sql_rep->db_Count("easyshop_ipn_orders");
    if ($count_ipn_rows > 0) {
        $sql_rep->db_Select("easyshop_ipn_orders", "*", $arg);
        while ($row = $sql_rep->db_Fetch()) {
            $row['items'] = unserialize($row['all_items']);
            if (preg_match("/^EScheck_totals_/", $row['payment_status'])) {
                $thiscase = "totals";
            } elseif (preg_match("/^EScheck_rxemail_/", $row['payment_status'])) {
                $thiscase = "rxemail";
            } elseif (preg_match("/^EScheck_dupltxn_/", $row['payment_status'])) {
                $thiscase = "dupltxn";
            } elseif (preg_match("/^EScheck_/", $row['payment_status'])) {
                $thiscase = "EScheck";
            } else {
                $thiscase = $row['payment_status'];
            }
            $text = "";
            isset($row['phpsessionid']) ? $trans_sessionid = $row['phpsessionid'] : ($trans_sessionid = $row['custom']);
            $text .= "<tr><td class='forumheader'>\r\n                <b>" . EASYSHOP_IPN_01 . "</b>: " . $row['first_name'] . " " . $row['last_name'] . " (" . $row['payer_status'] . ")<br />\r\n                <b>" . EASYSHOP_IPN_02 . "</b>: " . $row['address_name'] . "  (" . $row['address_status'] . ") <br />\r\n                         " . $row['address_street'] . "     <br />\r\n                         " . $row['address_zip'] . "        <br />\r\n                         " . $row['address_city'] . "       <br />\r\n                         " . $row['address_state'] . "      <br />\r\n                         " . $row['address_country'] . "    <br />\r\n                <b>" . EASYSHOP_IPN_03 . "</b>: <a href='mailto:" . $row['payer_email'] . "'>" . $row['payer_email'] . "</a><br />\r\n                <br />\r\n                <b>" . EASYSHOP_IPN_04 . "</b><br />\r\n                " . EASYSHOP_IPN_05 . " : " . $row['payment_status'] . "<br />\r\n                " . EASYSHOP_IPN_06 . " : " . $row['reason_code'] . "<br />\r\n                " . EASYSHOP_IPN_07 . " : " . $row['pending_reason'] . "<br />\r\n                " . EASYSHOP_IPN_08 . " : " . $row['txn_id'] . "<br />\r\n                " . EASYSHOP_IPN_09 . " : " . $trans_sessionid . "<br />\r\n                " . EASYSHOP_IPN_10 . " : " . $row['payment_date'] . "<br />\r\n                " . EASYSHOP_IPN_11 . " : " . date("M d Y H:i:s", $row['phptimestamp']) . "<br />\r\n                " . EASYSHOP_IPN_12 . " : " . $unicode_character_before . $row['mc_gross'] . $unicode_character_after . "<br /></td>\r\n                ";
            $text .= "<td class='forumheader2' style='vertical-align: top;'><table style='border:0;cellspacing:15;width:100%;'>\r\n               <tr><td class='forumheader2'><b> " . EASYSHOP_IPN_13 . " </b></td>\r\n                   <td class='forumheader2'><b> " . EASYSHOP_IPN_14 . " </b></td>\r\n                   <td class='forumheader2'><b> " . EASYSHOP_IPN_15 . " </b></td>\r\n                   <td class='forumheader2'><b> " . EASYSHOP_IPN_16 . " </b></td>\r\n                   <td class='forumheader2'><b> " . EASYSHOP_IPN_17 . " </b></td>\r\n                   <td class='forumheader2'><b> " . EASYSHOP_IPN_18 . " </b></td></tr>  ";
            $itemcount = 1;
            $item = $row['items'];
            //preg_match("/^ES_/",$row['payment_status']) ? $paypalfix = "_" : $paypalfix = ""; // Paypal is inconsistent in it's variable naming
            $paypalfix = "_";
            // Paypal Completed order changes; not necessary anymore to make this flexible
            $paypalfix == "" ? $notpaypalfix = "_" : ($notpaypalfix = "_");
            // mc_gross_n exists when other variables are item_number(n)
            while (isset($item["item_name" . $paypalfix . $itemcount]) || isset($item["item_number" . $paypalfix . $itemcount])) {
                $text .= "<tr><td>" . $itemcount . "</td>\r\n               <td>" . $item["item_name" . $paypalfix . $itemcount] . "</td>\r\n               <td>" . $item["item_number" . $paypalfix . $itemcount] . "</td>\r\n               <td>" . $unicode_character_before . ($item["mc_handling" . $paypalfix . $itemcount] + $item["mc_shipping" . $paypalfix . $itemcount]) . $unicode_character_after . "</td>\r\n               <td>" . $item["quantity" . $paypalfix . $itemcount] . "</td>\r\n               <td>" . $unicode_character_before . $item["amount" . $paypalfix . $itemcount] . $unicode_character_after . "</td></tr>";
                $itemcount++;
            }
            $text .= "</table></td><br />";
            switch ($thiscase) {
                case "Completed":
                    $completed++;
                    $report['Completed'][$completed]['report_array'] = $row;
                    $report['Completed']['report_count'] = $completed;
                    $full_text = "<table class='fborder' width='90%'>\r\n                     <tr><td>\r\n                     <div style='text-align:left;'> <b>" . EASYSHOP_IPN_19 . ": '" . $thiscase . "'  " . EASYSHOP_IPN_20 . ": " . $completed . " </b></div>\r\n                     " . $text . "</tr></table>";
                    $report['Completed'][$completed]['report_table'] = $full_text;
                    break;
                case "ES_processing":
                    $processing++;
                    $report['ES_processing'][$processing]['report_array'] = $row;
                    $report['ES_processing']['report_count'] = $processing;
                    $full_text = "<table border='1'  style='border: 1px thin;' cellspacing='5' width='100%'>\r\n                     <tr><td>\r\n                     <div style='text-align:left;'> <b>" . EASYSHOP_IPN_19 . ": '" . $thiscase . "'  " . EASYSHOP_IPN_20 . ": " . $processing . " </b></div>\r\n                     " . $text . "</tr></table>";
                    $report['ES_processing'][$processing]['report_table'] = $full_text;
                    break;
                case "ES_shopping":
                    $shopping++;
                    $report['ES_shopping'][$shopping]['report_array'] = $row;
                    $report['ES_shopping']['report_count'] = $shopping;
                    $full_text = "<table border='1'  style='border: 1px thin;' cellspacing='5' width='100%'>\r\n                     <tr><td>\r\n                     <div style='text-align:left;'> <b>" . EASYSHOP_IPN_19 . ": '" . $thiscase . "'  " . EASYSHOP_IPN_20 . ": " . $shopping . " </b></div>\r\n                     " . $text . "</tr></table>";
                    $report['ES_shopping'][$shopping]['report_table'] = $full_text;
                    break;
                case "EScheck":
                    $escheck++;
                    $report['EScheck'][$escheck]['report_array'] = $row;
                    $report['EScheck']['report_count'] = $escheck;
                    $full_text = "<table border='1'  style='border: 1px thin;' cellspacing='5' width='100%'>\r\n                     <tr><td>\r\n                     <div style='text-align:left;'> <b>" . EASYSHOP_IPN_19 . ": '" . $thiscase . "'  " . EASYSHOP_IPN_20 . ": " . $escheck . " </b></div>\r\n                     " . $text . "</tr></table>";
                    $report['EScheck'][$escheck]['report_table'] = $full_text;
                    break;
                case "totals":
                    $totals++;
                    $report['totals'][$totals]['report_array'] = $row;
                    $report['totals']['report_count'] = $totals;
                    $full_text = "<table border='1'  style='border: 1px thin;' cellspacing='5' width='100%'>\r\n                     <tr><td>\r\n                     <div style='text-align:left;'> <b>" . EASYSHOP_IPN_19 . ": '" . $thiscase . "'  " . EASYSHOP_IPN_20 . ": " . $totals . " </b></div>\r\n                     " . $text . "</tr></table>";
                    $report['totals'][$totals]['report_table'] = $full_text;
                    break;
                case "rxemail":
                    $rxemail++;
                    $report['rxemail'][$rxemail]['report_array'] = $row;
                    $report['rxemail']['report_count'] = $rxemail;
                    $full_text = "<table border='1'  style='border: 1px thin;' cellspacing='5' width='100%'>\r\n                     <tr><td>\r\n                     <div style='text-align:left;'> <b>" . EASYSHOP_IPN_19 . ": '" . $thiscase . "'  " . EASYSHOP_IPN_20 . ": " . $rxemail . " </b></div>\r\n                     " . $text . "</tr></table>";
                    $report['rxemail'][$rxemail]['report_table'] = $full_text;
                    break;
                case "dupltxn":
                    $dupltxn++;
                    $report['dupltxn'][$dupltxn]['report_array'] = $row;
                    $report['dupltxn']['report_count'] = $dupltxn;
                    $full_text = "<table border='1'  style='border: 1px thin;' cellspacing='5' width='100%'>\r\n                     <tr><td>\r\n                     <div style='text-align:left;'> <b>" . EASYSHOP_IPN_19 . ": '" . $thiscase . "'  " . EASYSHOP_IPN_20 . ": " . $dupltxn . " </b></div>\r\n                     " . $text . "</tr></table>";
                    $report['dupltxn'][$dupltxn]['report_table'] = $full_text;
                    break;
                default:
                    $various++;
                    $report['various'][$various]['report_array'] = $row;
                    $report['various']['report_count'] = $various;
                    $full_text = "<table border='1'  style='border: 1px thin;' cellspacing='5' width='100%'>\r\n                     <tr><td>\r\n                     <div style='text-align:left;'> <b>" . EASYSHOP_IPN_19 . ": '" . $thiscase . "'  " . EASYSHOP_IPN_20 . ": " . $various . " </b></div>\r\n                     " . $text . "</tr></table>";
                    $report['various'][$various]['report_table'] = $full_text;
                    break;
            }
            // End of switch cases
        }
        // End of while fetching rows for sql_report
    }
    // End of condition to start the above when count > 0
    return $report;
}