$regSettings = false;
$view = 'billing';
$importResults = false;
- $totalMembers = false;
+ $totalImports = false;
$numberProcessed = false;
// General settings are always stored in a record with ID=1.
break;
case 'importBillingData':
- $view = 'importAccounts';
+ $view = 'importBillingData';
if ( isset( $_REQUEST['option2'] ) ) {
$option2 = $_REQUEST['option2'];
}
switch ( $option2 ) {
case 'import':
require_once GLM_MEMBERS_BILLING_PLUGIN_PATH.'/models/admin/management/importBillingData.php';
+ // die('here');
break;
default:
break;
'settingsUpdateError' => $settingsUpdateError,
'option' => $option,
'importResults' => $importResults,
- 'totalMembers' => $totalMembers,
+ 'totalImports' => $totalImports,
'numberProcessed' => $numberProcessed,
'start' => ( isset( $start ) ? $start : false ),
);
);
}
}
-?>
// For billing support functions
require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
$BillingSupport = new GlmBillingSupport( $this->wpdb, $this->config );
-
// Connect to their live database.
$dbh = new PDO(
'pgsql: host=localhost dbname=uptravel user=postgres password=tweety',
$importResults = '';
// Get records.
-$sql = "
-SELECT *
- FROM members.billing
+$sqlWhere = "
WHERE invoice_id IN (
SELECT invoice_id
FROM members.billing
AND transaction_time >= '2017-01-01'
ORDER BY transaction_date,transaction_time)
AND billing_type IN (1,2,3)
- ORDER BY transaction_date,transaction_time";
-// LIMIT 20
-//OFFSET 0";
+";
+$mainSql = "
+SELECT *
+ FROM members.billing
+$sqlWhere
+ ORDER BY transaction_date,transaction_time
+ LIMIT 10
+OFFSET $start";
+
+$statsSql = "SELECT count(*)
+ FROM members.billing
+$sqlWhere";
+
+$stmt = $dbh->query( $mainSql );
+$billingRecords = $stmt->fetchAll();
+$statsStmt = $dbh->query( $statsSql );
+$totalImports = $statsStmt->fetchColumn();
+$numberProcessed = $start;
-//LIMIT 10
-//OFFSET $start";
-$stmt = $dbh->query( $sql );
-$billingRecords = $stmt->fetchAll();
+$importResults .= '<pre>$totalImports: ' . print_r( $totalImports, true ) . '</pre>';
+// return;
+// exit;
-$importResults .= '<pre>$billingRecords: ' . print_r( $billingRecords, true ) . '</pre>';
+// $importResults .= '<pre>$billingRecords: ' . print_r( $billingRecords, true ) . '</pre>';
if ( $start === 0 ) {
// Clear the invoices,line_items and transactions
$invoiceType = $BillingSupport->getInvoiceTypeById( $account['invoice_type'] );
// $importResults .= '<pre>$invoiceType: ' . print_r( $invoiceType, true ) . '</pre>';
if ( $invoiceType ) {
+ $numberProcessed++;
// Check the type (1 = invoice, 2 = payment, 3 = Adjustment, 4 = Comment)
switch ( $billingRecord['billing_type']) {
case "1": // Invoices
</span>
<span class="account-dashboard-link">
{if isset( $settings.invoice_pdf_enabled ) && $settings.invoice_pdf_enabled}
- <a href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=createPDFInvoice&id={$t.id}">Print</a> |
+ <a href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=createPDFInvoice&id={$t.id}" target="_blank">Print</a> |
{else}
- <a href="{$thisUrl}?page={$thisPage}&glm_action=invoices&option=view&id={$t.id}">View</a> |
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=invoices&option=view&id={$t.id}" target="_blank">View</a> |
{/if}
</span>
<span class="account-dashboard-link">
</table>
</form>
- <form action="{$thisUrl}?page={$thisPage}" method="post">
-
- <input type="hidden" name="glm_action" value="billing" />
- <input type="hidden" name="option" value="importBillingData" />
- <input type="hidden" name="option2" value="import" />
-
- <table class="glm-admin-table glm-settings-table">
-
- <tr>
- <td><input type="submit" value="Import Billing Data" /></td>
- </tr>
-
- </table>
- </form>
{/if}
Number processed: {$numberProcessed}
--- /dev/null
+{include file='admin/management/header.html'}
+
+{include file='admin/management/subHeader.html'}
+
+{if $importResults}
+ {$importResults}
+{else}
+ <form action="{$thisUrl}?page={$thisPage}" method="post">
+
+ <input type="hidden" name="glm_action" value="billing" />
+ <input type="hidden" name="option" value="importBillingData" />
+ <input type="hidden" name="option2" value="import" />
+
+ <table class="glm-admin-table glm-settings-table">
+
+ <tr>
+ <td><input type="submit" value="Import Billing Data" /></td>
+ </tr>
+
+ </table>
+ </form>
+{/if}
+
+Number processed: {$numberProcessed}
+
+{if $numberProcessed > 0}
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=billing&option=importBillingData&option2=import&start={$numberProcessed}">Next 10</a>
+{/if}
+
+{if $numberProcessed < $totalImports}
+
+ <script>
+ jQuery(document).ready(function($){
+
+ window.location.href = '{$thisUrl}?page={$thisPage}&glm_action=billing&option=importBillingData&option2=import&start={$numberProcessed}';
+
+ });
+
+ </script>
+{/if}
+
+{include file='admin/management/footer.html'}
class="glm-settings-tab nav-tab{if $option == ''} nav-tab-active{/if}">General Settings</a>
<a href="{$thisUrl}?page=glm-members-admin-menu-management&glm_action=billing&option=importAccounts"
class="glm-settings-tab nav-tab{if $option == 'importAccounts'} nav-tab-active{/if}">Import Accounts</a>
+ <a href="{$thisUrl}?page=glm-members-admin-menu-management&glm_action=billing&option=importBillingData"
+ class="glm-settings-tab nav-tab{if $option == 'importBillingData'} nav-tab-active{/if}">Import Billing Data</a>
</h2>