This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/export/classes/quicken.php

67 lines
1.7 KiB
PHP
Raw Normal View History

2010-11-29 22:41:08 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Quicken exporting capabilities.
*
* @package OSB
* @subpackage Export
* @category Classes/Quicken
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Quicken extends OSBExport {
protected $defaults = array();
protected function keys() {
return array_merge(array_keys($this->defaults),parent::keys());
}
protected function vals() {
return array_merge(array_values($this->defaults),parent::vals());
}
public function addInvoice(Quicken_Invoice $item) {
array_push($this->_items,$item);
}
public function export() {
$export = '';
foreach ($this->_items as $inv) {
# Invoices
$export .= "!TRNS\t";
$export .= implode("\t",$inv->keys())."\n";
$export .= "TRNS\t";
$export .= implode("\t",$inv->vals())."\n";
# Invoice Items
$spl = 0;
foreach ($inv->_items as $invitem) {
if (! $spl) {
$export .= "!SPL\tSPLID\t";
$export .= implode("\t",$invitem->keys())."\n";
}
$export .= sprintf("SPL\t%s\t%s",$spl++,implode("\t",$invitem->vals()))."\n";
}
$export .= "ENDTRNS\n";
# Payments
foreach ($inv->_payments as $payitem) {
$export .= "!TRNS\t";
$export .= implode("\t",$payitem->keys())."\n";
$export .= "TRNS\t";
$export .= implode("\t",$payitem->vals())."\n";
$export .= sprintf("!SPL\t%s\t%s\t%s\t%s\t%s\t",'SPLID','TRANSTYPE','CLEAR','ACCNT','AMOUNT')."\n";
$export .= sprintf("SPL\t%s\t%s\t%s\t%s\t%s\t",0,'PAYMENT','N','Accounts Receivable',$payitem->AMOUNT)."\n";
$export .= "ENDTRNS\n";
}
}
return $export;
}
}