/** * View the current order summary * * @param boolean $final Indicates that this order is final. * @param string $tpl "print" for a printable template * @return string HTML for order view */ public function View($final = false, $tpl = '') { global $_PP_CONF, $_USER, $LANG_PP, $LANG_ADMIN, $_TABLES, $_CONF, $_SYSTEM; USES_paypal_class_product(); // canView should be handled by the caller if (!$this->canView()) { return ''; } $T = new Template(PAYPAL_PI_PATH . '/templates'); if ($tpl == 'print') { $tpltype = '.print'; } else { $tpltype = $_SYSTEM['framework'] == 'uikit' ? '.uikit' : ''; } $T->set_file('order', "order{$tpltype}.thtml"); $isAdmin = SEC_hasRights('paypal.admin') ? true : false; foreach ($this->_addr_fields as $fldname) { $T->set_var($fldname, $this->{$fldname}); } $T->set_block('order', 'ItemRow', 'iRow'); // Get the workflows so we sho the relevant info. if (!isset($_PP_CONF['workflows']) || !is_array($_PP_CONF['workflows'])) { USES_paypal_class_workflow(); ppWorkflow::Load(); } foreach ($_PP_CONF['workflows'] as $key => $value) { $T->set_var('have_' . $value, 'true'); } $this->no_shipping = 1; // no shipping unless physical item ordered $subtotal = 0; foreach ($this->items as $key => $item) { $P = new Product($item['product_id']); $item_options = ''; $opt = json_decode($item['options_text'], true); if ($opt) { foreach ($opt as $opt_str) { $item_options .= " -- {$opt_str}<br />\n"; } } $item_total = $item['price'] * $item['quantity']; $subtotal += $item_total; $T->set_var(array('item_id' => htmlspecialchars($item['product_id']), 'item_descrip' => htmlspecialchars($item['description']), 'item_price' => COM_numberFormat($item['price'], 2), 'item_quantity' => (int) $item['quantity'], 'item_total' => COM_numberFormat($item_total, 2), 'item_options' => $item_options, 'is_admin' => $isAdmin ? 'true' : '', 'is_file' => $P->file != '' ? 'true' : '')); $T->parse('iRow', 'ItemRow', true); if ($item['data']['prod_type'] == PP_PROD_PHYSICAL) { $this->no_shipping = 0; } } $dt = new Date($this->order_date, $_CONF['timezone']); $total = $subtotal + $this->shipping + $this->handling + $this->tax; $T->set_var(array('pi_url' => PAYPAL_URL, 'is_admin' => $isAdmin ? 'true' : '', 'pi_admin_url' => PAYPAL_ADMIN_URL, 'total' => sprintf('%6.2f', $total), 'not_final' => $final ? '' : 'true', 'order_date' => $dt->format($_PP_CONF['datetime_fmt'], true), 'order_date_tip' => $dt->format($_PP_CONF['datetime_fmt'], false), 'order_number' => $this->order_id, 'shipping' => COM_numberFormat($this->shipping, 2), 'handling' => COM_numberFormat($this->handling, 2), 'tax' => COM_numberFormat($this->tax, 2), 'subtotal' => COM_numberFormat($subtotal, 2), 'have_billto' => 'true', 'have_shipto' => 'true', 'order_instr' => htmlspecialchars($this->instructions), 'shop_name' => $_PP_CONF['shop_name'], 'shop_addr' => $_PP_CONF['shop_addr'])); if ($isAdmin) { USES_paypal_class_orderstatus(); $T->set_var(array('purch_name' => COM_getDisplayName($this->uid), 'purch_uid' => $this->uid, 'stat_update' => ppOrderStatus::Selection($this->order_id, 1, $this->status), 'status' => $this->status)); $sql = "SELECT * FROM {$_TABLES['paypal.order_log']} WHERE order_id = '" . DB_escapeString($this->order_id) . "'"; $res = DB_query($sql); $T->set_block('order', 'LogMessages', 'Log'); while ($L = DB_fetchArray($res, false)) { $dt->setTimestamp(strtotime($L['ts'])); $T->set_var(array('log_username' => $L['username'], 'log_msg' => $L['message'], 'log_ts' => $dt->format($_PP_CONF['datetime_fmt'], true), 'log_ts_tip' => $dt->format($_PP_CONF['datetime_fmt'], false))); $T->parse('Log', 'LogMessages', true); } } $status = $this->status; if ($this->pmt_method != '') { //if ($status & PP_STATUS_PAID) { if (USES_paypal_gateway($this->pmt_method)) { $gw = new $this->pmt_method(); $pmt_method = $gw->Description(); } else { $pmt_method = $this->pmt_method; } $T->set_var(array('pmt_method' => $pmt_method, 'pmt_txn_id' => $this->pmt_txn_id)); } $T->parse('output', 'order'); $form = $T->finish($T->get_var('output')); return $form; }
/** * Get an individual field for the history screen. * * @param string $fieldname Name of field (from the array, not the db) * @param mixed $fieldvalue Value of the field * @param array $A Array of all fields from the database * @param array $icon_arr System icon array (not used) * @param object $EntryList This entry list object * @return string HTML for field display in the table */ function PAYPAL_getPurchaseHistoryField($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_PP_CONF, $LANG_PP; $retval = ''; switch ($fieldname) { case 'name': list($item_id, $item_opts) = explode('|', $A['product_id']); //if (is_numeric($A['product_id'])) { if (is_numeric($item_id)) { // One of our catalog items, so link to it $retval = COM_createLink($fieldvalue, PAYPAL_URL . '/index.php?detail=x&id=' . $item_id); } else { // Probably came from a plugin, just show the product name $retval = htmlspecialchars($A['product_id'], ENT_QUOTES, COM_getEncodingt()); } break; case 'username': $retval = COM_createLink($fieldvalue, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid']); break; case 'quantity': $retval = '<div class="alignright">' . $fieldvalue . "</div>"; break; case 'txn_id': $base_url = $A['isAdmin'] ? PAYPAL_ADMIN_URL : PAYPAL_URL; // Admins get a link to the transaction log, regular users just // get the ID to check against their Paypal account. if ($A['isAdmin'] == 1) { $retval = COM_createLink($fieldvalue, $base_url . '/index.php?ipnlog=x&op=single&txn_id=' . $fieldvalue); } else { $retval = $fieldvalue; } break; case 'prod_type': // Return the plain-language product type description //$retval = $LANG_PP['prod_types'][$fieldvalue]; $retval = $LANG_PP['prod_types'][$A['prod_type']]; //if ($fieldvalue == PP_PROD_DOWNLOAD && $A['exptime'] > time() ) { if ($A['file'] != '' && $A['exptime'] > time()) { $retval = COM_createLink($retval, PAYPAL_URL . "/download.php?id={$A['product_id']}"); } break; case 'short_description': // If this is a plugin item, there should be a description recorded // in the purchase file. If not, just take it from the product // table. if (!empty($A['description'])) { $retval = $A['description']; } else { $retval = $fieldvalue; } break; case 'status': if ($A['isAdmin'] && is_array($LANG_PP['orderstatus'])) { $retval = ppOrderStatus::Selection($A['order_id'], 0, $fieldvalue); } elseif (isset($LANG_PP['orderstatus'][$fieldvalue])) { $retval = $LANG_PP['orderstatus'][$fieldvalue]; } else { $retval = 'Unknown'; } break; case 'order_id': $base_url = $A['isAdmin'] ? PAYPAL_ADMIN_URL : PAYPAL_URL; $retval = COM_createLink($fieldvalue, $base_url . '/index.php?order=' . $fieldvalue); break; default: $retval = htmlspecialchars($fieldvalue, ENT_QUOTES, COM_getEncodingt()); break; } return $retval; }
break; case 'gwmove': PAYPAL_loadGateways(); // just need the PaymentGw class PaymentGw::moveRow($_GET['id'], $actionval); $view = 'gwadmin'; break; case 'wfmove': switch ($_GET['type']) { case 'workflow': USES_paypal_class_workflow(); ppWorkflow::moveRow($_GET['id'], $actionval); break; case 'orderstatus': USES_paypal_class_orderstatus(); ppOrderStatus::moveRow($_GET['id'], $actionval); break; } $view = 'wfadmin'; break; default: $view = $action; break; } //PAYPAL_debug('Admin view: ' . $action); switch ($view) { case 'history': $content .= PAYPAL_history(true); break; case 'orderhist': if (isset($_POST['upd_orders']) && is_array($_POST['upd_orders'])) {
/** * Get an individual field for the history screen. * * @param string $fieldname Name of field (from the array, not the db) * @param mixed $fieldvalue Value of the field * @param array $A Array of all fields from the database * @param array $icon_arr System icon array (not used) * @param object $EntryList This entry list object * @return string HTML for field display in the table */ function PAYPAL_getPurchaseHistoryField($fieldname, $fieldvalue, $A, $icon_arr) { global $_CONF, $_PP_CONF, $LANG_PP, $_USER; static $dt = NULL; if ($dt === NULL) { $dt = new Date('now', $_USER['tzid']); } $retval = ''; switch ($fieldname) { case 'order_date': $dt->setTimestamp(strtotime($fieldvalue)); $retval = '<span title="' . $dt->format($_PP_CONF['datetime_fmt'], false) . '">' . $dt->format($_PP_CONF['datetime_fmt'], true) . '</span>'; break; case 'name': list($item_id, $item_opts) = PAYPAL_explode_opts($A['product_id']); if (is_numeric($item_id)) { // One of our catalog items, so link to it $retval = COM_createLink($fieldvalue, PAYPAL_URL . '/index.php?detail=x&id=' . $item_id); } else { // Probably came from a plugin, just show the product name $retval = htmlspecialchars($A['product_id'], ENT_QUOTES, COM_getEncodingt()); } break; case 'username': if ($A['isAdmin']) { $retval = COM_createLink($fieldvalue, PAYPAL_ADMIN_URL . '/index.php?orderhist=x&uid=' . $A['uid']); } else { $retval = COM_createLink($fieldvalue, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid']); } break; case 'quantity': $retval = '<div class="alignright">' . $fieldvalue . "</div>"; break; case 'txn_id': $base_url = $A['isAdmin'] ? PAYPAL_ADMIN_URL : PAYPAL_URL; // Admins get a link to the transaction log, regular users just // get the ID to check against their Paypal account. if ($A['isAdmin'] == 1) { $retval = COM_createLink($fieldvalue, $base_url . '/index.php?ipnlog=x&op=single&txn_id=' . $fieldvalue); } else { $retval = $fieldvalue; } break; case 'prod_type': // Return the plain-language product type description //$retval = $LANG_PP['prod_types'][$fieldvalue]; $retval = $LANG_PP['prod_types'][$A['prod_type']]; //if ($fieldvalue == PP_PROD_DOWNLOAD && $A['exptime'] > time() ) { if ($A['file'] != '' && $A['exptime'] > time()) { $retval = COM_createLink($retval, PAYPAL_URL . "/download.php?id={$A['product_id']}"); } break; case 'short_description': // If this is a plugin item, there should be a description recorded // in the purchase file. If not, just take it from the product // table. if (!empty($A['description'])) { $retval = $A['description']; } else { $retval = $fieldvalue; } break; case 'status': if ($A['isAdmin'] && is_array($LANG_PP['orderstatus'])) { $retval = ppOrderStatus::Selection($A['order_id'], 0, $fieldvalue); } elseif (isset($LANG_PP['orderstatus'][$fieldvalue])) { $retval = $LANG_PP['orderstatus'][$fieldvalue]; } else { $retval = 'Unknown'; } break; case 'order_id': $base_url = $A['isAdmin'] ? PAYPAL_ADMIN_URL : PAYPAL_URL; $retval = COM_createLink($fieldvalue, $base_url . '/index.php?order=' . $fieldvalue, array('data-uk-tooltip' => '', 'title' => 'View', 'class' => 'gl_mootip')); $retval .= ' <a href="' . PAYPAL_URL . '/index.php?printorder=' . $fieldvalue . '" target="_blank" class="uk-icon-mini uk-icon-print gl_mootip" title="Print" data-uk-tooltip>'; if (!$_PP_CONF['_is_uikit']) { $retval .= '(print)'; } $retval .= '</a>'; break; default: $retval = htmlspecialchars($fieldvalue, ENT_QUOTES, COM_getEncodingt()); break; } return $retval; }
<info>' . "\n"; echo "<newval>{$newval}</newval>\n"; echo "<id>{$_REQUEST['id']}</id>\n"; echo "<type>{$_REQUEST['type']}</type>\n"; echo "<component>{$_REQUEST['component']}</component>\n"; echo "<imgurl>{$img_url}</imgurl>\n"; echo "<baseurl>" . PAYPAL_ADMIN_URL . "</baseurl>\n"; echo "</info>\n"; break; case 'orderstatus': USES_paypal_class_orderstatus(); $field = $_GET['type']; switch ($field) { case 'enabled': case 'notify_buyer': $newval = ppOrderStatus::Toggle($_REQUEST['id'], $field, $_REQUEST['oldval']); break; default: exit; } $img_url = PAYPAL_URL . '/images/'; $img_url .= $newval == 1 ? 'on.png' : 'off.png'; header('Content-Type: text/xml'); header("Cache-Control: no-cache, must-revalidate"); //A date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); echo '<?xml version="1.0" encoding="ISO-8859-1"?> <info>' . "\n"; echo "<newval>{$newval}</newval>\n"; echo "<id>{$_REQUEST['id']}</id>\n"; echo "<type>{$_REQUEST['type']}</type>\n";
/** * View the current order summary * * @param boolean $final Indicates that this order is final. * @return string HTML for order view */ public function View($final = false) { global $_PP_CONF, $_USER, $LANG_PP, $LANG_ADMIN, $_TABLES; $T = new Template(PAYPAL_PI_PATH . '/templates'); $T->set_file(array('order' => 'order.thtml')); $isAdmin = SEC_hasRights('paypal.admin') ? true : false; foreach ($this->_addr_fields as $fldname) { $T->set_var($fldname, $this->{$fldname}); } $T->set_block('order', 'ItemRow', 'iRow'); // Get the workflows so we sho the relevant info. if (!isset($_PP_CONF['workflows']) || !is_array($_PP_CONF['workflows'])) { USES_paypal_class_workflow(); ppWorkflow::Load(); } foreach ($_PP_CONF['workflows'] as $key => $value) { $T->set_var('have_' . $value, 'true'); } $this->no_shipping = 1; // no shipping unless physical item ordered $subtotal = 0; foreach ($this->items as $key => $item) { $item_total = $item['price'] * $item['quantity']; $subtotal += $item_total; $T->set_var(array('item_id' => $item['product_id'], 'item_descrip' => $item['description'], 'item_price' => COM_numberFormat($item['price'], 2), 'item_quantity' => (int) $item['quantity'], 'item_total' => COM_numberFormat($item_total, 2))); $T->parse('iRow', 'ItemRow', true); if ($item['data']['prod_type'] == PP_PROD_PHYSICAL) { $this->no_shipping = 0; } } $total = $subtotal + $this->shipping + $this->handling + $this->tax; $T->set_var(array('pi_url' => PAYPAL_URL, 'is_admin' => $isAdmin ? 'true' : '', 'pi_admin_url' => PAYPAL_ADMIN_URL, 'total' => sprintf('%6.2f', $total), 'not_final' => $final ? '' : 'true', 'order_date' => $this->order_date, 'order_number' => $this->order_id, 'shipping' => COM_numberFormat($this->shipping, 2), 'handling' => COM_numberFormat($this->handling, 2), 'tax' => COM_numberFormat($this->tax, 2), 'subtotal' => COM_numberFormat($subtotal, 2), 'have_billto' => 'true', 'have_shipto' => 'true')); if ($isAdmin) { USES_paypal_class_orderstatus(); $T->set_var(array('purch_name' => COM_getDisplayName($this->uid), 'purch_uid' => $this->uid, 'stat_update' => ppOrderStatus::Selection($this->order_id, 1, $this->status))); $sql = "SELECT * FROM {$_TABLES['paypal.order_log']} WHERE order_id = '" . DB_escapeString($this->order_id) . "'"; $res = DB_query($sql, 1); $T->set_block('order', 'LogMessages', 'Log'); while ($L = DB_fetchArray($res, false)) { $T->set_var(array('log_username' => $L['username'], 'log_msg' => $L['message'], 'log_ts' => $L['ts'])); $T->parse('Log', 'LogMessages', true); } } $status = $this->status; if ($this->pmt_method != '') { //if ($status & PP_STATUS_PAID) { if (USES_paypal_gateway($this->pmt_method)) { $gw = new $this->pmt_method(); $pmt_method = $gw->Description(); } else { $pmt_method = $this->pmt_method; } $T->set_var(array('pmt_method' => $pmt_method, 'pmt_txn_id' => $this->pmt_txn_id)); } $T->parse('output', 'order'); $form = $T->finish($T->get_var('output')); return $form; }