<?php

$orderItem = new MM_OrderItem($p->orderItemId);
if ($orderItem->isValid()) {
    $scheduledPaymentEvent = MM_ScheduledPaymentEvent::findNextScheduledEventByOrderItemId($orderItem->getId(), false);
    if ($scheduledPaymentEvent->isValid()) {
        $crntRebillDate = MM_Utils::dateToLocal($scheduledPaymentEvent->getScheduledDate(), "m/d/Y");
        ?>
<div id='mm-edit-subscription-div'>
<input type='hidden' id='order_item_id' value='<?php 
        echo $p->orderItemId;
        ?>
' />
<a href="#"></a>
<p>Next Rebill Date</p>
<p style="font-size:11px;">
	<input id="mm-next-rebill-date" type="text" style="width: 152px" value="<?php 
        echo $crntRebillDate;
        ?>
" /> 
	<a onClick="jQuery('#mm-next-rebill-date').focus();"><?php 
        echo MM_Utils::getCalendarIcon();
        ?>
</a>
</p>

</div>

<div class="mm-dialog-footer-container">
<div class="mm-dialog-button-container">
<a href="javascript:mmjs.saveSubscription();" class="mm-ui-button blue">Save</a>
<?php

$order = MM_Order::create($p->orderId);
if ($order->isValid()) {
    $orderItem = MM_OrderItem::create($p->orderItemId);
    if ($orderItem->isValid()) {
        ?>
<div id='mm-edit-transaction-div'>
<input type='hidden' id='order_id' value='<?php 
        echo $p->orderId;
        ?>
' />
<input type='hidden' id='order_item_id' value='<?php 
        echo $p->orderItemId;
        ?>
' />
<input type='hidden' id='transaction_id' value='<?php 
        echo $p->transactionId;
        ?>
' />
<div style="font-size:11px;">
<?php 
        if ($orderItem->isRecurring()) {
            echo MM_Utils::getInfoIcon();
            ?>
	<em>This transaction is associated with a subscription. Any changes made here will be applied to this transaction and
	future recurring payments.</em> 
<?php 
        }
        ?>
<table>
$field = new stdClass();
$field->fieldId = "mm_field_billing_state";
$field->fieldName = "billingstate";
$field->label = "State";
$fieldInfo[] = $field;
$field = new stdClass();
$field->fieldId = "mm_field_billing_zip";
$field->fieldName = "billingzipcode";
$field->label = "Zip Code";
$fieldInfo[] = $field;
$field = new stdClass();
$field->fieldId = "mm_field_billing_country";
$field->fieldName = "billingcountry";
$field->label = "Country";
$fieldInfo[] = $field;
$orderItem = new MM_OrderItem($p->orderItemId);
$order = new MM_Order($orderItem->getOrderId());
$billingAddress = $order->getBillingAddress();
$data = array();
$data["mm_field_billing_address"] = $billingAddress->getAddressLine1();
$data["mm_field_billing_city"] = $billingAddress->getCity();
$data["mm_field_billing_state"] = $billingAddress->getState();
$data["mm_field_billing_zip"] = $billingAddress->getPostalCode();
$data["mm_field_billing_country"] = $billingAddress->getCountry();
$form = new MM_CheckoutForm();
if (!isset($data["mm_field_billing_country"])) {
    $data["mm_field_billing_country"] = "";
}
$form->billingCountryList = MM_HtmlUtils::getCountryList($data["mm_field_billing_country"]);
$ccExpDateRendered = false;
echo $form->getJavascriptIncludes(false);
Esempio n. 4
0
 private function temporaryPendingOverdueSubscriptionPatch()
 {
     if (class_exists("MM_OrderItem") && $this->hasColumn(MM_TABLE_AUTHNET_ARB_SUBSCRIPTIONS, "id")) {
         global $wpdb;
         $pymtServicesTable = MM_TABLE_PAYMENT_SERVICES;
         $authNetToken = MM_PaymentService::$AUTHORIZENET_SERVICE_TOKEN;
         $authNetPaymentId = $wpdb->get_var("SELECT id from {$pymtServicesTable} where token='{$authNetToken}'");
         if (!is_null($authNetPaymentId)) {
             $ordersTable = MM_TABLE_ORDERS;
             $orderItemsTable = MM_TABLE_ORDER_ITEMS;
             $transactionsTable = MM_TABLE_TRANSACTION_LOG;
             $transTypePayment = MM_TransactionLog::$TRANSACTION_TYPE_PAYMENT;
             $transTypeRecurringPayment = MM_TransactionLog::$TRANSACTION_TYPE_RECURRING_PAYMENT;
             $authNetSubscriptionsTable = MM_TABLE_AUTHNET_ARB_SUBSCRIPTIONS;
             $orderItemStatusRecurring = MM_OrderItem::$STATUS_RECURRING;
             $orderItemTypeProduct = MM_OrderItem::$ORDER_ITEM_TYPE_PRODUCT;
             $sql = "SELECT oi.id as order_item_id, oi.order_id, oi.rebill_period, oi.rebill_frequency, o.user_id FROM {$orderItemsTable} oi INNER JOIN {$ordersTable} o ON (oi.order_id = o.id) LEFT JOIN {$authNetSubscriptionsTable} arbs ON " . "(oi.id = arbs.order_item_id) WHERE o.payment_id='{$authNetPaymentId}' AND oi.status='{$orderItemStatusRecurring}' AND " . "oi.item_type='{$orderItemTypeProduct}' AND oi.is_recurring=1 AND (arbs.x_subscription_id IS NULL)";
             $result = $wpdb->get_results($sql);
             foreach ($result as $row) {
                 // check if pending overdue item has already been inserted for this order item
                 $pendingOverdueSubscriptions = MM_TABLE_AUTHNET_PENDING_OVERDUE_SUBSCRIPTIONS;
                 $pendingOverdueSubscriptionId = $wpdb->get_var("SELECT id from {$pendingOverdueSubscriptions} where order_item_id='{$row->order_item_id}'");
                 if (is_null($pendingOverdueSubscriptionId)) {
                     // lookup the last transaction associated with the order item
                     $sql = "SELECT transaction_date FROM {$transactionsTable} WHERE order_item_id = {$row->order_item_id} AND ";
                     $sql .= "transaction_type IN ({$transTypePayment}, {$transTypeRecurringPayment}) ";
                     $sql .= "ORDER BY transaction_date DESC LIMIT 1;";
                     $lastTransaction = $wpdb->get_row($sql);
                     if ($lastTransaction) {
                         // set status of order item to pending overdue
                         $orderItem = new MM_OrderItem($row->order_item_id);
                         if ($orderItem->isValid()) {
                             $orderItem->setStatus(5);
                             // set to pending overdue status, not using constant as this script is being run in the installer
                             // and on first run the constant may not be defined
                             $orderItem->commitData();
                             // calculate overdue date based on last transaction date and length of subscription cycle
                             $overdueDate = date('Y-m-d', strtotime($lastTransaction->transaction_date . ' +' . $row->rebill_period . ' ' . $row->rebill_frequency));
                             $insertData = array("order_item_id" => $row->order_item_id, "overdue_date" => $overdueDate);
                             $wpdb->insert(MM_TABLE_AUTHNET_PENDING_OVERDUE_SUBSCRIPTIONS, $insertData);
                         }
                     }
                 }
             }
         }
     }
 }