18 $serviceShowInfo =
true;
19 $serviceLoadMenu =
true;
20 $serviceShowMenu =
true;
21 $serviceAllowReadonly =
true;
24 require_once(
'hcuService.i');
30 PermCheckFeatureScreen($dbh, $HB_ENV, $MC, FEATURE_DOWNLOAD_HISTORY);
34 $string= array(
"filter" => FILTER_SANITIZE_STRING);
35 $dms_ok = array(
"action"=>$string,
'downfmt' => $string,
36 'start' => $string,
'end' => $string,
37 'selacct' => $string );
39 HCU_ImportVars($HB_ENV,
"HCUPOST", $dms_ok);
49 if (HCU_array_key_exists(
"action", $HB_ENV[
'HCUPOST'])) {
50 if ( $HB_ENV[
"HCUPOST"][
"action"] ==
"download" ||
51 $HB_ENV[
"HCUPOST"][
"action"] ==
"download_txns" ) {
65 $start = (empty($HB_ENV[
"HCUPOST"][
"start"]) ?
"" : $HB_ENV[
"HCUPOST"][
"start"]);
66 $end = (empty($HB_ENV[
"HCUPOST"][
"end"]) ? mdydate() : $HB_ENV[
"HCUPOST"][
"end"]);
67 $sqlend = sqldate($end);
70 $aryErrors[] = $MC->msg(
'Please provide a Start Date', HCU_DISPLAY_AS_RAW);
72 if (!sqldate($start)) {
73 $aryErrors[] =
"[$start] " . $MC->msg(
'is not a valid date', HCU_DISPLAY_AS_RAW);
75 $sqlstart = sqldate($start);
78 $aryErrors[] = $MC->msg(
'Please provide an End Date', HCU_DISPLAY_AS_RAW);
81 $aryErrors[] =
"[$end] " . $MC->msg(
'is not a valid date', HCU_DISPLAY_AS_RAW);
84 if ( !count( $aryErrors ) ) {
86 $sql =
"select trim(fid), trim(rt), trim(orgname) from cuadmin where cu='{$HB_ENV['Cu']}'";
87 $sth = db_query($sql, $dbh);
88 list ($Cfid, $Crt, $Corgname) = db_fetch_array($sth, 0);
89 $datalist[
'cuinfo'][
'fid'] = $Cfid;
90 $datalist[
'cuinfo'][
'rt'] = $Crt;
91 $datalist[
'cuinfo'][
'orgname'] = $Corgname;
93 $datalist[
"cuinfo"][
"sqlstart"] = $sqlstart;
94 $datalist[
"cuinfo"][
"sqlend"] = $sqlend;
96 $aryBalances = Get_Balances($dbh, $HB_ENV);
98 if ($aryBalances[
'status'][
'code'] !=
'000') {
99 for ( $i = 0; $i < count( $aryBalances[
"status"][
"errors"] ); $i++ ) {
100 $aryErrors[] = $aryBalances[
"status"][
"errors"][$i];
106 $selAccts = explode(
";", $HB_ENV[
'HCUPOST'][
'selacct'] );
107 for ( $i = 0; $i < count( $selAccts ); $i++ ) {
109 $selAcct = hcu_decrypturl($selAccts[$i], $HB_ENV[
'historyHash']);
110 $selAcctParts = explode(
"|", $selAcct);
111 switch ($selAcctParts[0]) {
123 $accountId = $aryBalances[$tbl][$selAcct];
124 $datalist[
'balances'][$tbl][$selAcct] = $accountId;
127 $aryTxns = Get_History($dbh, $HB_ENV, $selAcct, $sqlstart, $sqlend);
129 if ($aryTxns[
'status'][
'code'] !=
'000') {
130 for ( $i = 0; $i < count( $aryTxns[
"status"][
"errors"] ); $i++ ) {
131 $aryErrors[] = $aryTxns[
"status"][
"errors"][$i];
134 if ($aryTxns[
'status'][
'code'] ==
'000') {
135 $datalist[
'txns'][$selAcct] = array_key_exists($selAcct, $aryTxns) ?
143 if ( !count( $aryErrors ) ) {
144 # so now we have datalist holding balances and transactions as requested - pass it off to the appropriate download routine 146 if ( $HB_ENV[
"HCUPOST"][
"action"] ==
"download_txns" ) {
148 $expires = mktime(date(
"H"), date(
"i"), date(
"s"), date(
"m") + 3, date(
"d"), date(
"Y"));
150 setcookie(
"webconnect",
"time=$now&user={$HB_ENV['cu']}:{$HB_ENV['Cn']}&laststart=$start&lastend=$end&fmt={$HB_ENV["HCUPOST
"]['downfmt']}", $expires,
"/",
".homecu.net", 1);
154 switch ($HB_ENV[
"HCUPOST"][
"downfmt"]) {
156 $outString = CSVDown($HB_ENV, $MC, $datalist);
157 header(
"Content-length: " . strlen($outString));
158 header(
"Content-type: application/octetstream");
159 header(
"Content-disposition: inline; filename=\"{$HB_ENV['Cu']}_txns.csv\"");
163 $outString = QIFDown($HB_ENV, $datalist);
164 header(
"Content-length: " . strlen($outString));
165 header(
"Content-type: application/octetstream");
166 header(
"Content-disposition: inline; filename=\"{$HB_ENV['Cu']}_txns.qif\"");
170 $outString = OFXDown2($HB_ENV, $datalist); # OFX 211 format, with conditional
for QFX even though Intuit says it is unsupported
171 if ($HB_ENV[
'HCUPOST'][
'downfmt'] ==
'qfx') {
172 header(
"Content-type: application/vnd.intu.QFX");
173 header(
"Content-disposition: inline; filename=\"{$HB_ENV['Cu']}_txns.qfx\"");
175 header(
"Content-Type: application/x-ofx");
176 header(
"Content-disposition: inline; filename=\"{$HB_ENV['Cu']}_txns.ofx\"");
178 $outCount = strlen( $outString );
179 header(
"Content-length: $outCount");
185 $outString = OFXDown1($HB_ENV, $datalist, $HB_ENV[
"HCUPOST"][
"downfmt"]); # OFX 100 format
186 if ($HB_ENV[
'HCUPOST'][
'downfmt'] ==
'qfx') {
187 header(
"Content-type: application/vnd.intu.QFX");
188 header(
"Content-disposition: inline; filename=\"{$HB_ENV['Cu']}_txns.qfx\"");
190 header(
"Content-Type: application/x-ofx");
191 header(
"Content-disposition: inline; filename=\"{$HB_ENV['Cu']}_txns.ofx\"");
193 $outCount = strlen( $outString );
194 header(
"Content-length: $outCount");
198 $outString = QknDown($HB_ENV, $datalist);
199 header(
"Content-type: application/vnd.intu.QFX");
200 header(
"Content-disposition: inline; filename=\"{$HB_ENV['Cu']}_txns.qfx\"");
201 $outCount = strlen( $outString );
202 header(
"Content-length: $outCount");
206 $outString = QknDown($HB_ENV, $datalist);
207 header(
"Content-type: application/vnd.intu.QBO");
208 header(
"Content-disposition: inline; filename=\"{$HB_ENV['Cu']}_txns.qbo\"");
209 $outCount = strlen( $outString );
210 header(
"Content-length: $outCount");
214 # error, unexpected format 215 $aryErrors[] =
"Unexpected format: {$HB_ENV["HCUPOST
"]["downfmt
"]}";
219 if ( count( $aryErrors ) ) {
220 throw new Exception(HCU_JsonEncode($aryErrors));
230 require_once(
'hcuPreContent.i');
232 $Flang = (trim($Flang) ==
"" ?
"en_US" : trim($Flang));
234 if ( $HB_ENV[
'offline'] !=
"N" ) {
235 $thisPageErrors = $HB_ENV[
"offlinemsg"];
236 throw new Exception( HCU_JsonEncode($thisPageErrors) );
240 $noticesAry = Get_NoticeInfo($dbh, $HB_ENV, $MC,
"D",
"TxnDownloadHelp",
true);
242 $hasNoticeDNL =
false;
243 $hasNoticePopupDNL =
false;
245 $noticeLinkDisplayDNL =
"";
246 $noticeURLNoticeOnlyDNL =
"";
248 if ( $noticesAry[
"status"][
"code"] ==
"000" && HCU_array_key_exists(
'0', $noticesAry[
'notice'])) {
249 if ($noticesAry[
"notice"][0][
"notice_id"] ) {
250 $hasNoticeDNL =
true;
251 $noticeLinkDisplayDNL = $noticesAry[
"notice"][0][
"notice_linkdisplay"];
253 $noticeOption = $noticesAry[
'notice'][0];
255 $noticeOptions = Array (
256 'docsid' => $noticeOption[
'notice_id'],
257 'docstype' => $noticeOption[
'notice_type'],
260 'expireTime' => mktime() + 86400
263 $encryptedDocDetails= HCU_PayloadEncode($HB_ENV[
'Cu'], $noticeOptions);
265 $noticeOptions[
'noticeOnly'] = 1;
267 $encryptedDocDetailsNoticeOnly= HCU_PayloadEncode($HB_ENV[
'Cu'], $noticeOptions);
271 $noticeURLDNL = $HB_ENV[
'homebankingpath'] .
'/hcuViewNotice.prg?cu=' . $HB_ENV[
'cu'] .
'&x=' . urlencode($encryptedDocDetails);
274 $noticeURLNoticeOnlyDNL = $HB_ENV[
'homebankingpath'] .
'/hcuViewNotice.prg?cu=' . $HB_ENV[
'cu'] .
'&x=' . urlencode($encryptedDocDetailsNoticeOnly);
277 $hasNoticePopupDNL = $noticeOption[
"notice_popup"] ? true :
false;
284 $acctTypes = Array(
"dp",
"ln",
"cc");
285 $acctListAry = Array();
286 $GetBalancesAry = Get_Balances($dbh, $HB_ENV);
288 if ( $GetBalancesAry[
'status'][
'code'] ==
'000' ) {
289 foreach ( $acctTypes as $acctType ) {
290 if ( HCU_array_key_exists($acctType, $GetBalancesAry ) ){
293 if ( is_array( $GetBalancesAry[$acctType] ) ===
true ) {
295 foreach ( $GetBalancesAry[$acctType] as $acctID => $acctRow ) {
298 $acctText = $acctRow[
'displaydesc'];
299 $acctValue = hcu_encrypturl($acctID, $HB_ENV[
'historyHash']);
302 if ( $acctType ==
"ln" ) {
304 if (HCU_array_key_exists(
"hisinfo", $GetBalancesAry[
"ln"][$acctID])) {
305 if ( strlen(trim($GetBalancesAry[
"ln"][$acctID][
"hisinfo"])) == 0 ) {
306 $acctListAry[] = Array(
"acctValue" => $acctValue,
"acctText" => $acctText,
"type" => $acctType );
309 }
else if ( $acctType ==
"cc" ) {
311 if (HCU_array_key_exists(
"hisinfo", $GetBalancesAry[
"cc"][$acctID])) {
312 if ( strtolower(trim($GetBalancesAry[
"cc"][$acctID][
"hisinfo"])) ==
"homecu" ) {
313 $acctListAry[] = Array(
"acctValue" => $acctValue,
"acctText" => $acctText,
"type" => $acctType );
317 $acctListAry[] = Array(
"acctValue" => $acctValue,
"acctText" => $acctText,
"type" => $acctType );
326 $Fset = $HB_ENV[
"Fset"];
327 $formatListAry = array();
328 if (($Fset & GetFlagsetValue(
"CU_MNYDOWN")) == GetFlagsetValue(
"CU_MNYDOWN") ) {
329 $formatListAry[] = array(
"text" => $MC->msg(
'Money Active Statement', HCU_DISPLAY_AS_RAW),
"value" =>
"mny",
"type" =>
"dp|ln|cc" );
331 if (($Fset & GetFlagsetValue(
"CU_QKNDOWN")) == GetFlagsetValue(
"CU_QKNDOWN") ) {
332 $formatListAry[] = array(
"text" => $MC->msg(
'Quicken WebConnect', HCU_DISPLAY_AS_RAW),
"value" =>
"qkn",
"type" =>
"dp" );
335 if (($HB_ENV[
"Fset3"] & GetFlagsetValue(
"CU3_QBDOWN")) !== 0 ) {
336 $formatListAry[] = array(
"text" => $MC->msg(
'QuickBooks WebConnect', HCU_DISPLAY_AS_RAW),
"value" =>
"qb",
"type" =>
"dp" );
338 if (($Fset & GetFlagsetValue(
"CU_QIFDOWN")) == GetFlagsetValue(
"CU_QIFDOWN") ) {
339 $formatListAry[] = array(
"text" => $MC->msg(
'QIF File', HCU_DISPLAY_AS_RAW),
"value" =>
"qif",
"type" =>
"dp|ln|cc" );
343 $formatListAry[] = array(
"text" => $MC->msg(
'CSV File', HCU_DISPLAY_AS_RAW),
"value" =>
"csv",
"type" =>
"dp|ln|cc" );
345 $lastend = date(
"m/d/Y", time() - 30 * 24 * 3600 );
346 $lastendParts = explode(
"/", $lastend );
347 $end = date(
"m/d/Y" );
348 $endParts = explode(
"/", $end );
351 var acctListAry = <?php echo HCU_JsonEncode( $acctListAry ); ?>;
352 var formatListAry = <?php echo HCU_JsonEncode( $formatListAry ); ?>;
354 $(document).ready(
function() {
356 homecuTooltip.reset();
357 $(
".detailsTip").each(
function() {
358 homecuTooltip.custom.content = $(
this).attr(
"title");
359 $(
this).kendoTooltip(homecuTooltip.custom);
362 $(
"#helpButton").click(
function() {
363 ShowNotice(
"<?php echo $noticeURLNoticeOnlyDNL; ?>",
"<?php echo $MC->msg( "Download
", HCU_DISPLAY_AS_JS ); ?>" );
367 $.homecuValidator.setup({
368 formValidate:
'formDownload' 372 var date =
new Date();
373 var endDate = date.setFullYear(<?php echo $endParts[2]; ?>,<?php echo ($endParts[0] - 1); ?>,<?php echo $endParts[1]; ?>);
374 var startDate = date.setFullYear(<?php echo $lastendParts[2]; ?>,<?php echo ($lastendParts[0] - 1); ?>,<?php echo $lastendParts[1]; ?>);
376 $(
'#histStartDate').kendoDatePicker({format:
"MM/dd/yyyy"});
377 $(
'#histEndDate').kendoDatePicker({format:
"MM/dd/yyyy"});
378 $(
'#histStartDate').data(
'kendoDatePicker').value(kendo.toString(
new Date(startDate),
'MM/dd/yyyy'));
379 $(
'#histEndDate').data(
'kendoDatePicker').value(kendo.toString(
new Date(endDate),
'MM/dd/yyyy'));
382 $(
"#acctList").kendoMultiSelect({
383 dataTextField:
"acctText",
384 dataValueField:
"acctValue",
385 dataSource: thisAcctChoiceAry,
387 placeholder:
"<?php echo $MC->msg('Select account', HCU_DISPLAY_AS_JS) ?>",
388 template:
"#= acctText #", <?php
389 tagTemplate:
"#= acctText #" 393 $(
"#formatList").kendoDropDownList({
394 dataTextField:
"text",
395 dataValueField:
"value",
396 dataSource: formatListAry,
397 value: formatListAry[0],
398 change: UpdateAccountChoices
401 $(
"#btnDownload").on(
"click",
function() {
402 if ($.homecuValidator.validate()) {
403 var multiselect = $(
"#acctList").data(
"kendoMultiSelect");
404 var selectTest = multiselect.value();
405 var selectAccts =
"";
407 for (i=0; i < selectTest.length; i++) {
408 if ( selectAccts.length > 0 ) {
411 selectAccts += selectTest[i];
414 document.formDownload.selacct.value = selectAccts;
415 document.formDownload.submit();
418 var thisAcctChoiceAry;
421 function UpdateAccountChoices() {
423 var formatChoice = $(
"#formatList").data(
"kendoDropDownList").value( );
425 var typesSupported =
"";
426 for ( var i = 0; i < formatListAry.length; i++ ) {
427 if ( formatListAry[i].value === formatChoice ) {
428 typesSupported = formatListAry[i].type;
434 thisAcctChoiceAry = [];
435 for ( var i = 0; i < acctListAry.length; i++ ) {
436 test = typesSupported.indexOf( acctListAry[i].type );
438 thisAcctChoiceAry.push( acctListAry[i] );
442 var acctList = $(
"#acctList").data(
"kendoMultiSelect");
443 acctList.setDataSource( thisAcctChoiceAry );
446 if ( formatChoice ===
"qif" ) {
447 acctList.options.maxSelectedItems = 1;
449 acctList.options.maxSelectedItems = acctListAry.length;
457 function updateOutputChoices( ) {
458 var acctList = $(
"#acctList").data(
'kendoMultiSelect');
459 var choices = acctList.value();
463 for ( var i = 0; i < acctListAry.length; i++ ) {
464 var oneChoice = acctListAry[i].acctValue;
465 for ( var c = 0; c < choices.length; c++ ) {
466 if ( choices[c] === oneChoice ) {
467 var thisType = acctListAry[i].type;
468 var test = typeList.indexOf( thisType );
470 typeList.push( thisType );
478 var thisAcctFormatListAry = [];
479 for ( var i = 0; i < formatListAry.length; i++ ) {
480 var thisType = formatListAry[i].type;
481 for ( var t = 0; t < typeList.length; t++ ) {
482 var oneType = typeList[t];
483 var test = thisType.indexOf( oneType );
487 for ( var f = 0; f < thisAcctFormatListAry.length; f++ ) {
488 if ( thisAcctFormatListAry[f] === formatListAry[i] ) {
494 thisAcctFormatListAry.push( formatListAry[i] );
500 $(
"#formatList").data(
"kendoDropDownList").setDataSource( thisAcctFormatListAry );
504 UpdateAccountChoices();
507 <?php
if ( array_key_exists(
"downfmt", $HB_ENV[
'HCUPOST']) && strlen( $HB_ENV[
"HCUPOST"][
"downfmt"] ) > 0 ) { ?>
508 $(
"#formatList").data(
"kendoDropDownList").value(
"<?php echo $HB_ENV["HCUPOST
"]["downfmt
"]; ?>" )
512 <?php
if ( $hasNoticeDNL && $hasNoticePopupDNL ) { ?>
513 ShowNotice(
'<?php echo $noticeURLDNL; ?>');
518 <!-- HTML STYLING -->
519 <style type=
"text/css">
527 .hcu-info-margin, .hcu-error-margin {
531 .hcu-info-padding, .hcu-error-padding {
540 .hcu-container-margin {
549 <!-- HTML CONTENT -->
550 <div
class=
"container-fluid hcuDownload">
551 <div
class=
"well well-sm">
555 <h3><?php echo $MC->msg(
'Download', HCU_DISPLAY_AS_HTML); ?></h3>
558 <!-- FORM CONTENT -->
559 <form
id=
"formDownload" name=
"formDownload" method=
"post">
561 <input type=
"hidden" name=
"action" value=
"download_txns">
565 <div
class=
"col-xs-12 col-md-6 hcu-container-margin">
567 <span><?php echo $MC->msg(
'Transaction Date Range', HCU_DISPLAY_AS_HTML); ?>: </span>
568 <span
class=
"fa fa-question-circle-o detailsTip" title=
"<?php echo $MC->msg('Enter dates', HCU_DISPLAY_AS_HTML) ?>"></span>
571 <input type=
"text" name=
'start' id=
'histStartDate' class=
"hcu-full-width" 573 data-homecuCustomMatch-msg=
" 574 <?php echo $MC->msg('Transaction Date Range', HCU_DISPLAY_AS_HTML); ?>: 575 <?php echo $MC->msg('is not a valid date', HCU_DISPLAY_AS_HTML) ?>" 577 <?php echo $MC->msg('Transaction Date Range', HCU_DISPLAY_AS_HTML); ?>: 578 <?php echo $MC->msg('is not a valid date', HCU_DISPLAY_AS_HTML) ?>" 582 <div
class=
"col-xs-12 col-md-6 hcu-container-margin">
584 <span><?php echo $MC->msg(
'To', HCU_DISPLAY_AS_HTML) ?>:</span>
587 <input type=
"text" name=
'end' id=
'histEndDate' class=
"hcu-full-width" 589 data-homecuCustomMatch-msg=
" 590 <?php echo $MC->msg('To', HCU_DISPLAY_AS_HTML); ?>: 591 <?php echo $MC->msg('is not a valid date', HCU_DISPLAY_AS_HTML) ?>" 593 <?php echo $MC->msg('To', HCU_DISPLAY_AS_HTML); ?>: 594 <?php echo $MC->msg('is not a valid date', HCU_DISPLAY_AS_HTML) ?>" 601 <div
class=
"col-xs-12 col-md-6 hcu-container-margin">
602 <label
for=
"account">
603 <span><?php echo $MC->msg(
'Format', HCU_DISPLAY_AS_HTML); ?>: </span>
604 <span
class=
"fa fa-question-circle-o detailsTip" title=
"<?php echo $MC->msg('Select a download format', HCU_DISPLAY_AS_HTML) ?>"></span>
607 <input
id=
'formatList' name=
"downfmt" class=
"hcu-full-width"/>
610 <div
class=
"col-xs-12 hcu-container-margin">
611 <label
for=
"account">
612 <span><?php echo $MC->msg(
'Account', HCU_DISPLAY_AS_HTML); ?>: </span>
613 <span
class=
"fa fa-question-circle-o detailsTip" title=
"<?php echo $MC->msg('Transactions will be downloaded', HCU_DISPLAY_AS_HTML) ?>"></span>
616 <input type=
"hidden" name=
"selacct" value=
"" />
617 <select
id=
'acctList' name=
"acctList" multiple=
"multiple" class=
"hcu-full-width" 618 data-required-msg=
"<?php echo $MC->msg('Please select an account', HCU_DISPLAY_AS_HTML) ?>" 624 <div
class=
"col-xs-12 col-md-6 hcu-container-margin">
625 <button
id=
"btnDownload" name=
'btnDownload' type=
"button" class=
"k-button k-primary">
626 <span
class=
"fa fa-download"> </span>
627 <span><?php print $MC->msg(
'Download', HCU_DISPLAY_AS_HTML); ?></span>
631 <div
class=
"col-xs-12 col-md-12">
632 <a href=
"#" id=
"helpButton" class=
"hcu-full-width">
633 <span><?php echo $noticeLinkDisplayDNL ?></span>
641 }
catch (Exception $ex) {
643 $thisPageErrors = HCU_JsonDecode($ex->getMessage());
646 $serviceErrorCode =
'917';
647 $serviceErrorMsgs = $thisPageErrors;
649 require_once(
'hcuErrorPage.i');
654 require_once(
'hcuPostContent.i');
659 # OFX / Quicken download 661 function OFXDown2($HB_ENV,$datalist) {
671 $sqlStart = $datalist[
"cuinfo"][
"sqlstart"];
672 $sqlEnd = $datalist[
"cuinfo"][
"sqlend"];
676 <?xml version=
"1.0" encoding=
"US-ASCII"?>
677 <?OFX OFXHEADER=
"200" VERSION=
"211" SECURITY=
"NONE" OLDFILEUID=
"NONE" NEWFILEUID=
"NONE"?>
683 <SEVERITY>INFO</SEVERITY>
685 <DTSERVER>{$now}</DTSERVER>
686 <LANGUAGE>ENG</LANGUAGE>
687 <DTACCTUP>19900101000000</DTACCTUP>
689 <ORG>{$datalist[
'cuinfo'][
'orgname']}</ORG>
690 <FID>{$datalist[
'cuinfo'][
'fid']}</FID>
695 if ($HB_ENV[
'HCUPOST'][
'downfmt'] ==
'qfx') {
696 $ofxString .=
"\n<INTU.BID>{$datalist['cuinfo']['fid']}\n<INTU.USERID>{$HB_ENV['Cn']}";
699 $ofxString .=
"</SONRS>\n</SIGNONMSGSRSV1>\n";
701 if (HCU_array_key_exists(
"dp", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'dp'])) {
702 $ofxString .=
"<BANKMSGSRSV1>\n";
704 foreach ($datalist[
'balances'][
'dp'] as $balkey => $balinfo) {
706 # for each $balances[dp] Get_History & print 707 $cert = $balinfo[
'certnumber'];
708 $type = $balinfo[
'accounttype'];
709 $desc = $balinfo[
'description'];
710 $desc = hcu_displayHtml( $desc, ENT_NOQUOTES );
711 $displaydesc = $balinfo[
'displaydesc'];
712 $displaydesc = hcu_displayHtml( $displaydesc, ENT_NOQUOTES );
713 $type = (
"$cert" ==
"0" ? $type :
"${type}_${cert}");
714 $type = hcu_displayHtml( trim($type), ENT_NOQUOTES );
716 switch ($balinfo[
'deposittype']) {
718 $acttype =
"CHECKING";
723 case "I": # IRA accounts
724 $acttype =
"RETIREMENT";
729 $acttype =
"SAVINGS";
732 # opening tags for account info 734 $ofxString .=
"<STMTTRNRS>\n";
735 $ofxString .=
"<TRNUID>0</TRNUID>\n";
736 $ofxString .=
"<STATUS>\n";
737 $ofxString .=
"<CODE>0</CODE>\n";
738 $ofxString .=
"<SEVERITY>INFO</SEVERITY>\n";
739 $ofxString .=
"</STATUS>\n";
740 $ofxString .=
"<STMTRS>\n";
741 $ofxString .=
"<CURDEF>USD</CURDEF>\n";
742 $ofxString .=
"<BANKACCTFROM>\n";
743 $ofxString .=
"<BANKID>{$datalist['cuinfo']['rt']}</BANKID>\n";
744 $ofxString .=
"<ACCTID>$type</ACCTID>\n";
745 $ofxString .=
"<ACCTTYPE>$acttype</ACCTTYPE>\n";
746 $ofxString .=
"<DESCRIPTION>$desc</DESCRIPTION>\n";
747 if (
"$displaydesc" >
'') {
748 $ofxString .=
"<DISPLAYDESC>$displaydesc</DISPLAYDESC>\n";
750 $ofxString .=
"</BANKACCTFROM>\n";
752 $ofxString .=
"<BANKTRANLIST>\n";
753 $ofxString .=
"<DTSTART>{$sqlStart}000000</DTSTART>\n";
754 $ofxString .=
"<DTEND>$now</DTEND>\n";
756 if (
sizeof($datalist[
'txns'][$balkey])) {
757 foreach ($datalist[
'txns'][$balkey] as $tnum => $detl) {
758 $tranamount = $detl[
'amount'];
759 $tranamount = str_replace(
",",
"", str_replace(
"$",
"", $tranamount));
760 $tranamount = sprintf(
"%.2f", $tranamount);
761 $trbal = $detl[
'balance'];
762 $trbal = str_replace(
",",
"", str_replace(
"$",
"", $trbal));
763 $trbal = sprintf(
"%.2f", $trbal);
764 $check = HCU_array_key_exists(
"checkno", $detl) ? $detl[
'checkno'] : 0;
765 $trandesc = $detl[
'description'];
766 if ($trandesc <
" " && $check != 0) {
769 $trandesc = (preg_replace(
"/<BR>/",
" ", $trandesc));
770 $trandesc = (preg_replace(
"/ /",
" ", $trandesc));
771 $longdesc = htmlentities($trandesc,ENT_NOQUOTES,
'UTF-8',FALSE);
772 $shortdesc = substr(htmlentities($trandesc,ENT_NOQUOTES,
'UTF-8',FALSE), 0, 31);
773 $shortdesc = preg_replace(
'/&[^;]*$/',
'', $shortdesc);
774 $shortdesc = (trim($shortdesc) ==
'' ?
'.' : $shortdesc);
776 $ofxString .=
"<STMTTRN>\n";
777 if ($tranamount < 0) {
778 if ($balinfo[
'deposittype'] ==
'Y' && $check != 0) {
779 $ofxString .=
"<TRNTYPE>CHECK</TRNTYPE>\n";
781 $ofxString .=
"<TRNTYPE>DEBIT</TRNTYPE>\n";
784 $ofxString .=
"<TRNTYPE>CREDIT</TRNTYPE>\n";
787 $date = str_replace(
"-",
"", $detl[
"date"]);
788 $ofxString .=
"<DTPOSTED>$date</DTPOSTED>\n";
789 # DTUSER not needed for 211? 790 $ofxString .=
"<DTUSER>$date</DTUSER>\n";
791 $ofxString .=
"<TRNAMT>$tranamount</TRNAMT>\n";
792 $ofxString .=
"<FITID>" . $detl[
'traceno'] .
"</FITID>\n";
793 if ($balinfo[
'deposittype'] ==
'Y' && $check != 0) {
794 $ofxString .=
"<CHECKNUM>$check</CHECKNUM>\n";
796 $ofxString .=
"<NAME>$shortdesc</NAME>\n";
797 if (strlen( trim( $longdesc ) ) > 32) {
798 $ofxString .=
"<MEMO>$longdesc</MEMO>\n";
800 $ofxString .=
"</STMTTRN>\n";
804 # closing tags for transaction list 805 $ofxString .=
"</BANKTRANLIST>\n";
806 $ofxString .=
"<LEDGERBAL>\n";
807 $ofxString .=
"<BALAMT>" . $balinfo[
"currentbal"] .
"</BALAMT>\n";
808 $ofxString .=
"<DTASOF>$now</DTASOF>\n";
809 $ofxString .=
"</LEDGERBAL>\n";
810 if (($HB_ENV[
'Fset'] & GetFlagsetValue(
"CU_SHOWAVAILABLE")) == GetFlagsetValue(
"CU_SHOWAVAILABLE")) {
811 $ofxString .=
"<AVAILBAL>\n<BALAMT>" . $balinfo[
"availablebal"] .
"</BALAMT>\n <DTASOF>$now</DTASOF>\n</AVAILBAL>\n";
814 # closing tags for account info 815 $ofxString .=
"</STMTRS>\n</STMTTRNRS>\n";
816 } # end of
foreach(balances[
'dp']
818 $ofxString .=
"</BANKMSGSRSV1>\n";
821 if (HCU_array_key_exists(
"cc", $datalist[
'balances']) && count($datalist[
'balances'][
'cc'])) {
822 $ofxString .=
"<CREDITCARDMSGSRSV1>\n";
824 foreach ($datalist[
'balances'][
'cc'] as $balkey => $balinfo) {
825 $ofxString .=
"<CCSTMTTRNRS>\n";
827 $stmntbal = $balinfo[
'payoff'];
828 $paymentamount = $balinfo[
'paymentamount'];
829 $nextduedate = $balinfo[
'nextduedate'];
830 $interestrate = $balinfo[
'interestrate'];
831 $creditlimit = $balinfo[
'creditlimit'];
833 $desc = $balinfo[
'description'];
834 $desc = hcu_displayHtml( $desc, ENT_NOQUOTES );
835 $displaydesc = $balinfo[
'displaydesc'];
836 $displaydesc = hcu_displayHtml( $displaydesc, ENT_NOQUOTES );
837 $loan = $balinfo[
'loan'];
838 $balance = $balinfo[
'currentbal'];
839 $available = $creditlimit - $balance;
840 $available = ($available < 0 ?
"" : $available);
843 $ofxString .=
"<CCSTMTRS>\n";
844 $ofxString .=
"<CURDEF>USD</CURDEF>\n";
845 $ofxString .=
"<CCACCTFROM>\n";
846 $ofxString .=
"<ACCTID>$loan</ACCTID>\n";
847 $ofxString .=
"<DESCRIPTION>$desc</DESCRIPTION>\n";
848 if (
"$displaydesc" >
'') {
849 $ofxString .=
"<DISPLAYDESC>$displaydesc</DISPLAYDESC>\n";
851 $ofxString .=
"</CCACCTFROM>\n";
852 $ofxString .=
"<BANKTRANLIST>\n";
853 $ofxString .=
"<DTSTART>{$sqlStart}000000</DTSTART>\n";
854 $ofxString .=
"<DTEND>$now</DTEND>\n";
856 $cur_avail = (($HB_ENV[
'Fset2'] & GetFlagsetValue(
"CU2_CALL_CCAVAIL")) == GetFlagsetValue(
"CU2_CALL_CCAVAIL") ?
857 "Call" : $available);
860 if (
sizeof($datalist[
'txns'][$balkey])) {
861 foreach ($datalist[
'txns'][$balkey] as $tnum => $detl) {
863 $hisbal = $detl[
'balance'];
864 $principle = $detl[
'principal'];
865 $interest = $detl[
'interest'];
867 if ($principle < 0) {
873 $totalpay = $detl[
'totalpay'];
874 $trdesc = $detl[
'description'];
876 $date = str_replace(
"-",
"", $detl[
"date"]);
877 $traceno = $detl[
'traceno'];
878 $longdesc = htmlentities($trdesc,ENT_NOQUOTES,
'UTF-8',FALSE);
879 $shortdesc = substr(htmlentities($trdesc,ENT_NOQUOTES,
'UTF-8',FALSE), 0, 31);
880 $shortdesc = preg_replace(
'/&[^;]*$/',
'', $shortdesc);
881 $shortdesc = (trim($shortdesc) ==
'' ?
'.' : $shortdesc);
883 # transaction data row 884 $ofxString .=
"<STMTTRN>\n";
885 $ofxString .=
"<TRNTYPE>$trntype</TRNTYPE>\n";
886 $ofxString .=
"<DTPOSTED>$date</DTPOSTED>\n";
887 $ofxString .=
"<TRNAMT>$totalpay</TRNAMT>\n";
888 $ofxString .=
"<FITID>$traceno</FITID>\n";
889 if (($HB_ENV[
'Fset'] & GetFlagsetValue(
"CU_SHOWLNTXNDESC")) == GetFlagsetValue(
"CU_SHOWLNTXNDESC")) {
890 $ofxString .=
"<NAME>$shortdesc</NAME>\n";
891 if ( strlen( trim( $longdesc ) ) > 32 ) {
892 $ofxString .=
"<MEMO>$longdesc</MEMO>\n";
895 $ofxString .=
"</STMTTRN>\n";
898 $ofxString .=
"</BANKTRANLIST>\n";
899 $ofxString .=
"<LEDGERBAL>\n";
900 $ofxString .=
"<BALAMT>$balance</BALAMT>\n";
901 $ofxString .=
"<DTASOF>$now</DTASOF>\n";
902 $ofxString .=
"</LEDGERBAL>\n";
903 if ($cur_avail > 0) {
904 $ofxString .=
"<AVAILBAL>\n";
905 $ofxString .=
"<BALAMT>$cur_avail</BALAMT>\n";
906 $ofxString .=
"<DTASOF>$now</DTASOF>\n";
907 $ofxString .=
"</AVAILBAL>\n";
910 $ofxString .=
"</CCSTMTRS>\n";
911 $ofxString .=
"</CCSTMTTRNRS>\n";
913 $ofxString .=
"</CREDITCARDMSGSRSV1>\n";
916 if (HCU_array_key_exists(
"ln", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'ln'])) {
918 $ofxString .=
"<LOANMSGSRSV1>\n";
920 foreach ($datalist[
'balances'][
'ln'] as $balkey => $balinfo) {
922 $ofxString .=
"<LOANSTMTTRNRS>\n";
924 $balance = $balinfo[
'currentbal'];
925 $loan = $balinfo[
'loan'];
926 $desc = $balinfo[
'description'];
927 $desc = hcu_displayHtml( $desc, ENT_NOQUOTES );
928 $displaydesc = $balinfo[
'displaydesc'];
929 $displaydesc = hcu_displayHtml( $displaydesc, ENT_NOQUOTES );
930 $payoff = $balinfo[
'payoff'];
931 $paymentamount = $balinfo[
'paymentamount'];
932 $nextduedate = $balinfo[
'nextduedate'];
933 $interestrate = $balinfo[
'interestrate'];
934 $creditlimit = $balinfo[
'creditlimit'];
937 $ofxString .=
"<LOANSTMTRS>\n";
938 $ofxString .=
"<CURDEF>USD</CURDEF>\n";
939 $ofxString .=
"<LOANACCTFROM>\n";
940 $ofxString .=
"<LOANACCTID>$loan</LOANACCTID>\n";
941 $ofxString .=
"<LOANACCTTYPE>CONSUMER</LOANACCTTYPE>\n";
942 $ofxString .=
"<DESCRIPTION>$desc</DESCRIPTION>\n";
943 if (
"$displaydesc" >
'') {
944 $ofxString .=
"<DISPLAYDESC>$displaydesc</DISPLAYDESC>\n";
946 $ofxString .=
"</LOANACCTFROM>\n";
947 $ofxString .=
"<LOANTRANLIST>\n";
948 $ofxString .=
"<DTSTART>{$sqlStart}000000</DTSTART>\n";
949 $ofxString .=
"<DTEND>$now</DTEND>\n";
951 if (
sizeof($datalist[
'txns'][$balkey])) {
952 foreach ($datalist[
'txns'][$balkey] as $tnum => $detl) {
954 $hisbal = $detl[
'balance'];
955 $principle = $detl[
'principal'];
956 $interest = $detl[
'interest'];
957 $totalpay = $detl[
'totalpay'];
958 $traceno = $detl[
'traceno'];
959 $trdesc = $detl[
'description'];
961 if ($principle < 0) {
962 $trntype =
"PAYMENT";
964 $trntype =
"ADVANCE";
967 $longdesc = htmlentities($trdesc,ENT_NOQUOTES,
'UTF-8',FALSE);
968 $shortdesc = substr(htmlentities($trdesc,ENT_NOQUOTES,
'UTF-8',FALSE), 0, 31);
969 $shortdesc = preg_replace(
'/&[^;]*$/',
'', $shortdesc);
970 $shortdesc = (trim($shortdesc) ==
'' ?
'.' : $shortdesc);
972 # transaction data row 974 $date = str_replace(
"-",
"", $detl[
"date"]);
975 $ofxString .=
"<LOANSTMTTRN>\n";
976 $ofxString .=
"<LOANTRNTYPE>$trntype</LOANTRNTYPE>\n";
977 $ofxString .=
"<DTPOSTED>$date</DTPOSTED>\n";
978 if (($HB_ENV[
'Fset'] & GetFlagsetValue(
"CU_SHOWLNTXNSPLIT")) == GetFlagsetValue(
"CU_SHOWLNTXNSPLIT")) {
979 $ofxString .=
"<TRNAMT>$totalpay</TRNAMT>\n";
980 $ofxString .=
"<LOANTRNAMT>\n";
981 $ofxString .=
"<PRINAMT>$principle</PRINAMT>\n";
982 $ofxString .=
"<INTAMT>$interest</INTAMT>\n";
983 $ofxString .=
"</LOANTRNAMT>\n";
985 $ofxString .=
"<TRNAMT>$principle</TRNAMT>\n";
987 $ofxString .=
"<FITID>$traceno</FITID>\n";
988 if (($HB_ENV[
'Fset'] & GetFlagsetValue(
"CU_SHOWLNTXNDESC")) == GetFlagsetValue(
"CU_SHOWLNTXNDESC")) {
989 $ofxString .=
"<NAME>$shortdesc</NAME>\n";
990 if ( strlen( trim( $longdesc ) ) > 32 ) {
991 $ofxString .=
"<MEMO>$longdesc</MEMO>\n";
994 $ofxString .=
"</LOANSTMTTRN>\n";
997 $ofxString .=
"</LOANTRANLIST>\n";
998 $ofxString .=
"<PRINBAL>\n";
999 $ofxString .=
"<BALAMT>$balance</BALAMT>\n";
1000 $ofxString .=
"<DTASOF>$now</DTASOF>\n";
1001 $ofxString .=
"</PRINBAL>\n";
1003 $ofxString .=
"</LOANSTMTRS>\n";
1004 $ofxString .=
"</LOANSTMTTRNRS>\n";
1006 $ofxString .=
"</LOANMSGSRSV1>\n";
1010 $ofxString .=
"</OFX>\n";
1015 function QknDown($HB_ENV,$datalist) {
1024 $sqlStart = $datalist[
"cuinfo"][
"sqlstart"];
1025 $sqlEnd = $datalist[
"cuinfo"][
"sqlend"];
1028 $ofxString .= <<<EOF
1048 <DTACCTUP>19900101000000
1050 <ORG>{$datalist[
'cuinfo'][
'orgname']}
1051 <FID>{$datalist[
'cuinfo'][
'fid']}
1053 <INTU.BID>{$datalist[
'cuinfo'][
'fid']}
1054 <INTU.USERID>{$HB_ENV[
'Cn']}
1060 if (HCU_array_key_exists(
"dp", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'dp'])) {
1061 $ofxString .=
"<BANKMSGSRSV1>\n";
1064 $userAccts = Get_UserAccounts( $HB_ENV[
'dbh'], $HB_ENV[
"cu"], $HB_ENV[
"Uid"] );
1065 $useMemAcctFlag = (($HB_ENV[
'flagset2'] & GetFlagsetValue(
"CU2_OFX_MEMACCTID")) == GetFlagsetValue(
"CU2_OFX_MEMACCTID"));
1066 $useMemAcctID = (count($userAccts[
'data']) > 1);
1067 $useMemAcct = ($useMemAcctID || $useMemAcctFlag);
1069 foreach ($datalist[
'balances'][
'dp'] as $balkey => $balinfo) {
1071 # for each $balances[dp] Get_History & print 1072 $acct = $balinfo[
'accountnumber'];
1073 $cert = $balinfo[
'certnumber'];
1074 $type = $balinfo[
'accounttype'];
1075 $desc = $balinfo[
'description'];
1076 $desc = hcu_displayHtml( $desc, ENT_NOQUOTES );
1077 $displaydesc = $balinfo[
'displaydesc'];
1078 $displaydesc = hcu_displayHtml( $displaydesc, ENT_NOQUOTES );
1079 $type = (
"$cert" ==
"0" ? $type :
"${type}_${cert}");
1080 $type = ($useMemAcct ?
"$acct/$type" : $type);
1081 $type = hcu_displayHtml( trim($type), ENT_NOQUOTES );
1083 switch ($balinfo[
'deposittype']) {
1085 $acttype =
"CHECKING";
1087 case "I": # IRA accounts
1088 $acttype =
"RETIREMENT";
1093 $acttype =
"SAVINGS";
1096 # opening tags for account info 1098 $ofxString .=
"<STMTTRNRS>\n";
1099 $ofxString .=
"<TRNUID>0\n";
1100 $ofxString .=
"<STATUS>\n";
1101 $ofxString .=
"<CODE>0\n";
1102 $ofxString .=
"<SEVERITY>INFO\n";
1103 $ofxString .=
"</STATUS>\n";
1104 $ofxString .=
"<STMTRS>\n";
1105 $ofxString .=
"<CURDEF>USD\n";
1106 $ofxString .=
"<BANKACCTFROM>\n";
1107 $ofxString .=
"<BANKID>{$datalist['cuinfo']['rt']}\n";
1108 $ofxString .=
"<ACCTID>$type\n";
1109 $ofxString .=
"<ACCTTYPE>$acttype\n";
1110 $ofxString .=
"</BANKACCTFROM>\n";
1112 $ofxString .=
"<BANKTRANLIST>\n";
1113 $ofxString .=
"<DTSTART>{$sqlStart}000000\n";
1114 $ofxString .=
"<DTEND>$now\n";
1116 if (
sizeof($datalist[
'txns'][$balkey])) {
1117 foreach ($datalist[
"txns"][$balkey] as $tnum => $detl) {
1119 $tranamount = $detl[
'amount'];
1120 $tranamount = str_replace(
",",
"", str_replace(
"$",
"", $tranamount));
1121 $tranamount = sprintf(
"%.2f", $tranamount);
1122 $trbal = $detl[
'balance'];
1123 $trbal = str_replace(
",",
"", str_replace(
"$",
"", $trbal));
1124 $trbal = sprintf(
"%.2f", $trbal);
1125 $check = HCU_array_key_exists(
"checkno", $detl) ? $detl[
'checkno'] : 0;
1126 $trandesc = $detl[
'description'];
1127 if ($trandesc <
" " && $check != 0) {
1130 $trandesc = (preg_replace(
"/<BR>/",
" ", $trandesc));
1131 $trandesc = (preg_replace(
"/ /",
" ", $trandesc));
1132 $longdesc = htmlentities($trandesc,ENT_NOQUOTES,
'UTF-8',FALSE);
1133 $shortdesc = substr(htmlentities($trandesc,ENT_NOQUOTES,
'UTF-8',FALSE), 0, 31);
1134 $shortdesc = preg_replace(
'/&[^;]*$/',
'', $shortdesc);
1135 $shortdesc = (trim($shortdesc) ==
'' ?
'.' : $shortdesc);
1137 $ofxString .=
"<STMTTRN>\n";
1138 if ($tranamount < 0) {
1139 if ($balinfo[
'deposittype'] ==
'Y' && $check != 0) {
1140 $ofxString .=
"<TRNTYPE>CHECK\n";
1142 $ofxString .=
"<TRNTYPE>DEBIT\n";
1145 $ofxString .=
"<TRNTYPE>CREDIT\n";
1147 $date = str_replace(
"-",
"", $detl[
"date"]);
1148 $ofxString .=
"<DTPOSTED>$date\n";
1149 # DTUSER not needed for 211? 1150 $ofxString .=
"<DTUSER>$date\n";
1151 $ofxString .=
"<TRNAMT>$tranamount\n";
1152 $ofxString .=
"<FITID>{$detl['traceno']}\n";
1153 if ($balinfo[
'deposittype'] ==
'Y' && $check != 0) {
1154 $ofxString .=
"<CHECKNUM>$check\n";
1156 $ofxString .=
"<NAME>$shortdesc\n";
1157 if (strlen($longdesc) > 32) {
1158 $ofxString .=
"<MEMO>$longdesc\n";
1160 $ofxString .=
"</STMTTRN>\n";
1163 # closing tags for transaction list 1165 $ofxString .=
"</BANKTRANLIST>\n";
1166 $ofxString .=
"<LEDGERBAL>\n";
1167 $ofxString .=
"<BALAMT>{$balinfo['currentbal']}\n";
1168 $ofxString .=
"<DTASOF>$now\n";
1169 $ofxString .=
"</LEDGERBAL>\n";
1171 # closing tags for account info 1172 $ofxString .=
"</STMTRS>\n</STMTTRNRS>\n";
1173 } # end of
foreach(balances[
'dp']
1175 $ofxString .=
"</BANKMSGSRSV1>\n";
1178 $ofxString .=
"</OFX>\n";
1185 function OFXDown1($HB_ENV, $datalist, $format) {
1187 $sqlStart = $datalist[
"cuinfo"][
"sqlstart"];
1188 $sqlEnd = $datalist[
"cuinfo"][
"sqlend"];
1190 if ( $format ==
"mny" ) {
1191 $ofxString .= <<<EOF
1203 $ofxString .= <<<EOF
1216 $ofxString .= <<< EOF
1227 <DTACCTUP>19900101000000
1229 <ORG>{$datalist[
'cuinfo'][
'orgname']}
1230 <FID>{$datalist[
'cuinfo'][
'fid']}
1234 if ($HB_ENV[
'HCUPOST'][
'downfmt'] ==
'qfx') {
1235 $ofxString .=
"\n<INTU.BID>{$datalist['cuinfo']['fid']}\n<INTU.USERID>{$HB_ENV['Cn']}";
1238 $ofxString .=
"\n </SONRS>\n </SIGNONMSGSRSV1>\n";
1240 $ofxString .=
" <BANKMSGSRSV1>\n";
1242 if (HCU_array_key_exists(
"dp", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
"dp"])) {
1243 foreach ($datalist[
'balances'][
"dp"] as $balkey => $acctdetls) {
1244 $tbl = substr($balkey, 0, 1);
1249 $desc =
"{$acctdetls['description']} - {$acctdetls['accounttype']} {$acctdetls['certnumber']}";
1250 $desc = hcu_displayHtml( $desc, ENT_NOQUOTES );
1251 $type = ($acctdetls[
'certnumber'] ==
"0" ? $acctdetls[
'accounttype'] :
"{$acctdetls['accounttype']}_{$acctdetls['certnumber']}");
1252 if (($HB_ENV[
'Fset2'] & GetFlagsetValue(
"CU2_OFX_MEMACCTID")) == GetFlagsetValue(
"CU2_OFX_MEMACCTID")) {
1253 $acctid =
"{$HB_ENV['Cn']}-{$type}";
1257 $acctid = hcu_displayHtml( $acctid, ENT_NOQUOTES );
1258 $trbal = $acctdetls[
"availablebal"];
1260 switch ($acctdetls[
'deposittype']) {
1262 $accttype =
"CHECKING";
1264 case "C": # Certificates
1265 $accttype =
"INVESTMENT";
1267 case "I": # IRA accounts
1268 $accttype =
"RETIREMENT";
1272 $accttype =
"SAVINGS";
1284 # error - unknown table type 1288 $ofxString .= <<< EOF
1298 <BANKID>{$datalist[
'cuinfo'][
'rt']}
1305 $ofxString .= <<< EOF
1307 <DTSTART>{$sqlStart}120000
1314 if (
sizeof($datalist[
'txns'][$balkey])) {
1315 foreach ($datalist[
'txns'][$balkey] as $txn => $drow) {
1316 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1317 $tranDesc = trim( $drow[
"description"] );
1318 $tranDesc = ($tranDesc ==
'' ?
'.' : $tranDesc);
1319 if ($tranDesc <
" " && $check != 0) {
1322 $tranDesc = (preg_replace(
"/<BR>/",
" ", $tranDesc));
1323 $tranDesc = (preg_replace(
"/ /",
"", $tranDesc));
1325 $tranAmount = sprintf(
"%.2f", $drow[
"amount"]);
1327 $trace = trim( $drow[
"traceno"] );
1330 $txnDate = str_replace(
"-" ,
"", $drow[
"date"] );
1331 $ofxString .=
" <STMTTRN>\n";
1332 if ($tranAmount < 0) {
1333 if ($accttype ==
'Y' and $check != 0) {
1334 $ofxString .=
" <TRNTYPE>CHECK\n";
1335 $ofxString .=
" <CHECKNUM>$check\n";
1337 $ofxString .=
" <TRNTYPE>DEBIT\n";
1340 $ofxString .=
" <TRNTYPE>CREDIT\n";
1342 $ofxString .=
" <DTPOSTED>{$txnDate}120000\n";
1343 $ofxString .=
" <DTUSER>{$txnDate}120000\n";
1344 $ofxString .=
" <TRNAMT>$tranAmount\n";
1345 $ofxString .=
" <FITID>$trace\n";
1347 $longDesc = htmlentities(html_entity_decode($tranDesc, ENT_NOQUOTES), ENT_NOQUOTES);
1348 $shortDesc = substr(htmlentities(html_entity_decode($tranDesc, ENT_NOQUOTES), ENT_NOQUOTES), 0, 31);
1349 $shortDesc = preg_replace(
'/&[^;]*$/',
'', $shortDesc);
1350 $shortDesc = (trim($shortDesc) ==
'' ?
'.' : $shortDesc);
1351 $ofxString .=
" <NAME>$shortDesc\n";
1353 if (strlen($longDesc) > 32) {
1354 $ofxString .=
" <MEMO>$longDesc\n";
1356 $ofxString .=
" </STMTTRN>\n";
1365 $olbal=sprintf(
"%.2f",$trbal);
1366 $ofxString .= <<< EOF
1387 function CSVDown($HB_ENV, $MC, $datalist) {
1389 $multipleAccounts =
false;
1390 if ( count( $datalist[
"txns"] ) > 1 ) {
1391 $ostring .=
"\"Account\",\"Date\",\"Check\",\"Description\",\"Amount\"\r\n";
1392 $multipleAccounts =
true;
1395 if (HCU_array_key_exists(
"dp", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'dp'])) {
1396 foreach ($datalist[
'balances'][
'dp'] as $acctid => $acctdetls) {
1397 if ( !$multipleAccounts ) {
1398 $ostring .=
"\"{$MC->msg('Account', HCU_DISPLAY_AS_RAW)}\",\"{$MC->msg('Date', HCU_DISPLAY_AS_RAW)}\",";
1399 if ($acctdetls[
'deposittype'] ==
'Y') {
1400 $ostring .=
"\"{$MC->msg('Check', HCU_DISPLAY_AS_RAW)}\",";
1402 $ostring .=
"\"{$MC->msg('Description', HCU_DISPLAY_AS_RAW)}\",\"{$MC->msg('Amount', HCU_DISPLAY_AS_RAW)}\",\"{$MC->msg('Balance', HCU_DISPLAY_AS_RAW)}\"\r\n";
1405 if (
sizeof($datalist[
'txns'][$acctid])) {
1406 $baldesc = trim( $acctdetls[
'description'] );
1407 if ( strlen( trim( $acctdetls[
'accounttype'] . $acctdetls[
'certnumber'] ) ) > 0 ) {
1408 $baldesc .=
" - {$acctdetls['accounttype']} {$acctdetls['certnumber']}";
1412 if (strlen($acctdetls[
'displayname']) > 0) {
1413 $baldesc = $acctdetls[
'displayname'];
1416 foreach ($datalist[
'txns'][$acctid] as $key => $drow) {
1417 $drow[
'description'] = (str_replace(
"<BR>",
" ", $drow[
'description']));
1418 $drow[
'description'] = (str_replace(
" ",
" ", $drow[
'description']));
1419 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1420 if ( $multipleAccounts ) {
1422 $tranamount = str_replace(
",",
"", str_replace(
"$",
"", $drow[
'amount'] ) );
1423 $tranamount = sprintf(
"%.2f", $tranamount );
1424 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1425 $ostring .=
"\"$baldesc\",\"{$drow['date']}\",\"$check\",\"{$drow['description']}\",\"$tranamount\"\r\n";
1428 $ostring .=
"\"$baldesc\",\"{$drow['date']}\",";
1429 if ($acctdetls[
'deposittype'] ==
'Y') {
1430 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1431 $ostring .=
"\"$check\",";
1433 $ostring .=
"\"{$drow['description']}\",\"{$drow['amount']}\",\"{$drow['balance']}\"\r\n";
1439 if (HCU_array_key_exists(
"ln", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'ln'])) {
1441 if ( !$multipleAccounts ) {
1442 $ostring .=
"\"{$MC->msg('Account', HCU_DISPLAY_AS_RAW)}\",\"{$MC->msg('Date', HCU_DISPLAY_AS_RAW)}\"";
1446 foreach ($datalist[
'balances'][
'ln'] as $acctid => $acctdetls) {
1447 $baldesc = trim( $acctdetls[
'description'] );
1448 if ( strlen( trim( $acctdetls[
'loan'] ) ) > 0 ) {
1449 $baldesc .=
" - {$acctdetls['loan']}";
1453 if (strlen($acctdetls[
'displayname']) > 0) {
1454 $baldesc = $acctdetls[
'displayname'];
1457 if (
sizeof( $datalist[
"txns"][$acctid] ) ) {
1458 if ( !$multipleAccounts ) {
1460 $txnIds = array_keys($datalist[
'txns'][$acctid]);
1461 $fldlist = array_keys($datalist[
'txns'][$acctid][$txnIds[0]]);
1463 if (in_array(
"description", $fldlist)) {
1464 $ostring .=
",\"{$MC->msg('Description', HCU_DISPLAY_AS_RAW)}\"";
1466 if (in_array(
"escrow", $fldlist)) {
1467 $ostring .=
",\"{$MC->msg('Escrow', HCU_DISPLAY_AS_RAW)}\"";
1469 if (in_array(
"fee", $fldlist)) {
1470 $ostring .=
",\"{$MC->msg('Fees', HCU_DISPLAY_AS_RAW)}\"";
1472 if (in_array(
"principal", $fldlist)) {
1473 $ostring .=
",\"{$MC->msg('Principal', HCU_DISPLAY_AS_RAW)}\"";
1474 $ostring .=
",\"{$MC->msg('Interest', HCU_DISPLAY_AS_RAW)}\"";
1475 $ostring .=
",\"{$MC->msg('Amount', HCU_DISPLAY_AS_RAW)}\"";
1477 $ostring .=
",\"{$MC->msg('Payment', HCU_DISPLAY_AS_RAW)}\"";
1479 if (in_array(
"balance", $fldlist)) {
1480 $ostring .=
",\"{$MC->msg('Balance', HCU_DISPLAY_AS_RAW)}\"";
1485 if (
sizeof($datalist[
'txns'][$acctid])) {
1486 foreach ($datalist[
'txns'][$acctid] as $key => $drow) {
1487 $drow[
'description'] = (str_replace(
"<BR>",
" ", $drow[
'description']));
1488 $drow[
'description'] = (str_replace(
" ",
" ", $drow[
'description']));
1489 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1490 if ( $multipleAccounts ) {
1491 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1492 $ostring .=
"\"$baldesc\",\"{$drow['date']}\",\"$check\",\"{$drow['description']}\",\"{$drow['totalpay']}\"\r\n";
1494 $ostring .=
"\"$baldesc\",\"{$drow['date']}\"";
1495 if (in_array(
"description", $fldlist)) {
1496 $ostring .=
",\"{$drow['description']}\"";
1498 if (in_array(
"escrow", $fldlist)) {
1499 $ostring .=
",\"{$drow['escrow']}\"";
1501 if (in_array(
"fee", $fldlist)) {
1502 $ostring .=
",\"{$drow['fee']}\"";
1504 if (in_array(
"principal", $fldlist)) {
1505 $ostring .=
",\"{$drow['principal']}\"";
1506 $ostring .=
",\"{$drow['interest']}\"";
1508 $ostring .=
",\"{$drow['totalpay']}\"";
1509 if (in_array(
"balance", $fldlist)) {
1510 $ostring .=
",\"{$drow['balance']}\"";
1521 if (HCU_array_key_exists(
"cc", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'cc'])) {
1523 if ( !$multipleAccounts ) {
1524 $ostring .=
"\"{$MC->msg('Account', HCU_DISPLAY_AS_RAW)}\",\"{$MC->msg('Date', HCU_DISPLAY_AS_RAW)}\"";
1527 foreach ($datalist[
'balances'][
'cc'] as $acctid => $acctdetls) {
1528 $baldesc = trim( $acctdetls[
'description'] );
1529 if ( strlen( trim( $acctdetls[
'accounttype'] . $acctdetls[
'certnumber'] ) ) > 0 ) {
1530 $baldesc .=
" - {$acctdetls['accounttype']} {$acctdetls['certnumber']}";
1534 if (strlen($acctdetls[
'displayname']) > 0) {
1535 $baldesc = $acctdetls[
'displayname'];
1538 if (
sizeof( $datalist[
"txns"][$acctid] ) ) {
1539 if ( !$multipleAccounts ) {
1541 $txnIds = array_keys($datalist[
'txns'][$acctid]);
1542 $fldlist = array_keys($datalist[
'txns'][$acctid][$txnIds[0]]);
1543 if (in_array(
"description", $fldlist)) {
1544 $ostring .=
",\"{$MC->msg('Description', HCU_DISPLAY_AS_RAW)}\"";
1546 if (in_array(
"fee", $fldlist)) {
1547 $ostring .=
",\"{$MC->msg('Fees', HCU_DISPLAY_AS_RAW)}\"";
1549 if (in_array(
"principal", $fldlist)) {
1550 $ostring .=
",\"{$MC->msg('Principal', HCU_DISPLAY_AS_RAW)}\"";
1551 $ostring .=
",\"{$MC->msg('Interest', HCU_DISPLAY_AS_RAW)}\"";
1553 $ostring .=
",\"{$MC->msg('Amount', HCU_DISPLAY_AS_RAW)}\"";
1554 if (in_array(
"balance", $fldlist)) {
1555 $ostring .=
",\"{$MC->msg('Balance', HCU_DISPLAY_AS_RAW)}\"";
1561 if (
sizeof($datalist[
'txns'][$acctid])) {
1562 foreach ($datalist[
'txns'][$acctid] as $key => $drow) {
1563 $drow[
'description'] = (str_replace(
"<BR>",
" ", $drow[
'description']));
1564 $drow[
'description'] = (str_replace(
" ",
" ", $drow[
'description']));
1565 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1567 if ( $multipleAccounts ) {
1568 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1569 $ostring .=
"\"$baldesc\",\"{$drow['date']}\",\"$check\",\"{$drow['description']}\",\"{$drow['totalpay']}\"\r\n";
1571 $ostring .=
"\"$baldesc\",\"{$drow['date']}\"";
1572 if (in_array(
"description", $fldlist)) {
1573 $ostring .=
",\"{$drow['description']}\"";
1575 if (in_array(
"fee", $fldlist)) {
1576 $ostring .=
",\"{$drow['fee']}\"";
1578 if (in_array(
"principal", $fldlist)) {
1579 $ostring .=
",\"{$drow['principal']}\"";
1580 $ostring .=
",\"{$drow['interest']}\"";
1582 $ostring .=
",\"{$drow['totalpay']}\"";
1583 if (in_array(
"balance", $fldlist)) {
1584 $ostring .=
",\"{$drow['balance']}\"";
1598 function QIFDown($HB_ENV, $datalist) {
1599 # only one account at a time for QIF 1602 if (HCU_array_key_exists(
"dp", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'dp'])) {
1604 foreach ($datalist[
'balances'][
'dp'] as $acctid => $acctdetls) {
1605 $baldesc =
"{$acctdetls['description']} - {$acctdetls['accounttype']} {$acctdetls['certnumber']}";
1608 if (strlen($acctdetls[
'displayname']) > 0) {
1609 $baldesc = $acctdetls[
'displayname'];
1612 $ostring .=
"!Account\r\nTBank\r\nN$baldesc\r\n^\r\n";
1613 $ostring .=
"!Type:Bank\r\n";
1614 if (
sizeof($datalist[
'txns'][$acctid])) {
1615 foreach ($datalist[
'txns'][$acctid] as $key => $drow) {
1617 $drow[
'description'] = (str_replace(
"<BR>",
" ", $drow[
'description']));
1618 $drow[
'description'] = (str_replace(
" ",
" ", $drow[
'description']));
1619 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1620 $date = $drow[
'date'];
1621 $date = (substr($date, 5, 2) .
"/" . substr($date, 8, 2) .
"/" . substr($date, 0, 4));
1622 $check = HCU_array_key_exists(
"checkno", $drow) ? $drow[
'checkno'] : 0;
1623 $ostring .=
"D$date\r\nN$check\r\nP{$drow['description']}\r\nCC\r\nT{$drow['amount']}\r\n^\r\n";
1628 if (HCU_array_key_exists(
"ln", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'ln'])) {
1630 foreach ($datalist[
'balances'][
'ln'] as $acctid => $acctdetls) {
1631 $baldesc =
"{$acctdetls['description']} - {$acctdetls['loan']}";
1634 if (strlen($acctdetls[
'displayname']) > 0) {
1635 $baldesc = $acctdetls[
'displayname'];
1638 $ostring .=
"!Account\r\nTOth L\r\nN$baldesc\r\n^\r\n";
1639 $ostring .=
"!Type:Oth L\r\n";
1641 if (
sizeof($datalist[
'txns'][$acctid])) {
1642 foreach ($datalist[
'txns'][$acctid] as $key => $drow) {
1643 $date = $drow[
'date'];
1644 $date = (substr($date, 5, 2) .
"/" . substr($date, 8, 2) .
"/" . substr($date, 0, 4));
1645 $ostring .=
"D$date\r\n";
1646 if (trim($drow[
'description']) !=
'') {
1647 $drow[
'description'] = (str_replace(
"<BR>",
" ", $drow[
'description']));
1648 $drow[
'description'] = (str_replace(
" ",
" ", $drow[
'description']));
1649 $ostring .=
"P{$drow['description']}\r\n";
1651 $ostring .=
"CC\r\n";
1652 if (HCU_array_key_exists(
"fee", $drow) && trim($drow[
'fee']) !=
'') {
1653 $ostring .=
"EFees\r\n\${$drow['fee']}\r\n";
1655 if (HCU_array_key_exists(
"principal", $drow) && trim($drow[
'principal']) !=
'') {
1656 $ostring .=
"EPrincipal\r\n\${$drow['principal']}\r\n";
1658 if (HCU_array_key_exists(
"interest", $drow) && trim($drow[
'interest']) !=
'') {
1659 $ostring .=
"EInterest\r\n\${$drow['interest']}\r\n";
1661 $ostring .=
"T{$drow['totalpay']}\r\n";
1662 $ostring .=
"^\r\n";
1667 if (HCU_array_key_exists(
"cc", $datalist[
'balances']) &&
sizeof($datalist[
'balances'][
'cc'])) {
1669 foreach ($datalist[
'balances'][
'cc'] as $acctid => $acctdetls) {
1670 $baldesc =
"{$acctdetls['description']} - {$acctdetls['loan']}";
1673 if (strlen($acctdetls[
'displayname']) > 0) {
1674 $baldesc = $acctdetls[
'displayname'];
1677 $ostring .=
"!Account\r\nTCCard\r\nN$baldesc\r\n^\r\n";
1678 $ostring .=
"!Type:Oth L\r\n";
1680 if (
sizeof($datalist[
'txns'][$acctid])) {
1681 foreach ($datalist[
'txns'][$acctid] as $key => $drow) {
1682 $date = $drow[
'date'];
1683 $date = (substr($date, 5, 2) .
"/" . substr($date, 8, 2) .
"/" . substr($date, 0, 4));
1684 $ostring .=
"D$date\r\n";
1685 if (trim($drow[
'description']) !=
'') {
1686 $drow[
'description'] = (str_replace(
"<BR>",
" ", $drow[
'description']));
1687 $drow[
'description'] = (str_replace(
" ",
" ", $drow[
'description']));
1688 $ostring .=
"P{$drow['description']}\r\n";
1690 $ostring .=
"CC\r\n";
1691 if (trim($drow[
'fee']) !=
'') {
1692 $ostring .=
"EFees\r\n\${$drow['fee']}\r\n";
1694 if (trim($drow[
'principal']) !=
'') {
1695 $ostring .=
"EPrincipal\r\n\${$drow['principal']}\r\n";
1697 if (trim($drow[
'interest']) !=
'') {
1698 $ostring .=
"EInterest\r\n\${$drow['interest']}\r\n";
1700 $ostring .=
"T{$drow['totalpay']}\r\n";
1701 $ostring .=
"^\r\n";
1710 function sqldate($date) {
1712 if (strtolower($date) ==
"now" || strtolower($date) ==
"today") {
1713 $date = date(
"m/d/Y");
1715 # only allow 0-9 and dash(-) 1716 if (preg_match(
"/[^0-9\-\/ ]/", $date)) {
1719 list ($mm, $dd, $yy) = preg_split(
'#[-/]#', $date);
1720 $mm = sprintf(
'%02d', intval($mm));
1721 $dd = sprintf(
'%02d', intval($dd));
1722 if (strlen($yy) > 0 && strlen($yy) < 4) {
1723 $yy = ($yy < 70 ? 2000 + $yy : 1900 + $yy);
1725 $yy = sprintf(
'%04d', intval($yy));
1726 if (checkdate($mm, $dd, $yy)) {
1727 return "${yy}${mm}${dd}";
1733 function ofxdate() {
1734 list ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $idist) = localtime();
1735 $year = ($year < 1900 ? $year + 1900 : $year);
1737 return sprintf(
"%04d%02d%02d%02d%02d%02d", $year, $mon, $mday, $hour, $min, $sec);
1740 function mdydate() {
1741 list ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $idist) = localtime();
1742 $year = ($year < 1900 ? $year + 1900 : $year);
1744 return sprintf(
"%02d/%02d/%04d", $mon, $mday, $year);