コード例 #1
0
ファイル: common.php プロジェクト: nanoprime/sureinvoice
    if (file_exists(realpath(dirname(__FILE__) . '/../installer') . '/index.php')) {
        $url = WEB_ROOT . 'installer/';
        header("Location: " . $url . "\r\n");
        exit;
    } else {
        print "No configuration file found: " . $include_path . '/global_config.php' . "<BR>\n";
        exit;
    }
}
require_once 'DBConn.php';
require_once 'global_config.php';
$db_conn = new DBConn(DB_SERVER, DB_DATABASE, DB_USER, DB_PASSWORD, TRUE);
if ($db_conn->connect() == FALSE) {
    trigger_error("Could not connect to database!\n" . $db_conn->getLastError(), E_USER_ERROR);
}
$GLOBALS['CONFIG'] = SI_Config::getAppConfig();
require_once 'html.php';
require_once 'SI_User.php';
require_once 'SI_Config.php';
require_once 'SI_TimeImport.php';
require_once 'version.php';
require_once 'SureInvoice.php';
session_start();
ob_start();
// Error handling functions
function site_error_handler($errno, $errstr, $errfile, $errline)
{
    $today = date("D M j G:i:s T Y");
    if (isset($GLOBALS['CONFIG']['error_log']) && is_file($GLOBALS['CONFIG']['error_log']) && is_writeable($GLOBALS['CONFIG']['error_log'])) {
        $error_log_avail = TRUE;
    } else {
コード例 #2
0
ファイル: SI_Payment.php プロジェクト: nanoprime/sureinvoice
	function exportQB($clause = ''){
		$payments = $this->retrieveSet($clause);
		
		if($payments === FALSE){
			return FALSE;
		}
		
		$app_config = SI_Config::getAppConfig();
		$rec_account = new SI_Account();
		$rec_account->get($app_config['account_rec']);
		$payment_account = new SI_Account();
		$payment_account->get($app_config['account_payment']);
		
		$exporter = new QBExporter();
		foreach($payments as $payment){
			$company =& $payment->getCompany();
			if($company != FALSE){
				$payment_data = array();
				$payment_data['NAME'] = $company->name;
				$payment_data['TRNSID'] = $payment->id;
				$payment_data['ACCNT'] = $payment_account->name;
				$payment_data['DOCNUM'] = $payment->id;
				$payment_data['DATE'] = date("n/j/Y", $payment->timestamp);
				$payment_data['TRNSTYPE'] = 'PAYMENT';
				$payment_data['AMOUNT'] = $payment->amount;
				$payment_data['LINES'] = array();
				$payment_data['LINES'][] = array(
					'TRNSTYPE' => 'PAYMENT',
					'DATE' => $payment_data['DATE'],
					'DOCNUM' => $payment_data['DOCNUM'],
					'NAME' => $payment_data['NAME'],
					'AMOUNT' => ($payment->amount * -1),
					'ACCNT' => $rec_account->name
				);					

				if($exporter->addItem('Payment', $payment_data) === FALSE){
					$this->error = "SI_Payment::export(): Error adding payment {$payment->id}: ".$exporter->getLastError();
					return FALSE;
				}
			}
		}
		
		return $exporter->get_string();
	}
コード例 #3
0
ファイル: SI_Invoice.php プロジェクト: nanoprime/sureinvoice
	function exportQB($clause = ''){
		$invoices = $this->retrieveSet($clause);
		
		if($invoices === FALSE){
			return FALSE;
		}
		
		$app_config = SI_Config::getAppConfig();
		$rec_account = new SI_Account();
		$rec_account->get($app_config['account_rec']);
		
		$exporter = new QBExporter();
		foreach($invoices as $invoice){
			$company =& $invoice->getCompany();
			if(count($invoice->_lines) > 0 && $company != FALSE){
				$invoice_data = array();
				$invoice_data['NAME'] = $company->name;
				$invoice_data['TRNSID'] = $invoice->id;
				$invoice_data['DOCNUM'] = $invoice->id;
				$invoice_data['DATE'] = date("n/j/Y", $invoice->timestamp);
				$invoice_data['TRNSTYPE'] = 'INVOICE';
				$invoice_data['TAXABLE'] = ($invoice->getTaxAmount() > 0.00);
				$invoice_data['TAX_CHARGED'] = ($invoice->getTaxAmount() > 0.00);
				$invoice_data['ACCNT'] = $rec_account->name;
				$invoice_data['AMOUNT'] = $invoice->getTotal();
				$invoice_data['LINES'] = array();
				$invoice_data['TIMESTAMP'] = $invoice->updated_ts;
				foreach($invoice->_lines as $line){
					$item_code =& $line->getItemCode();
					$amount = $line->getTotal() * -1;
					$invoice_data['LINES'][] = array(
						'TRNSTYPE' => 'INVOICE',
						'DATE' => $invoice_data['DATE'],
						'QNTY' => (float)'-'.$line->quantity,
						'MEMO' => '"'.$line->description.'"',
						'AMOUNT' => $amount,
						'PRICE' => (float)$line->unit_price,
						'INVITEM' => $item_code->code,
						'ACCNT' => $item_code->getIncomeAccountName()
					);					
				}

				if($exporter->addItem('Invoice', $invoice_data) === FALSE){
					$this->error = "SI_Company::export(): Error adding customer {$customer->name}: ".$exporter->getLastError();
					return FALSE;
				}
			}
		}
		
		return $exporter->get_string();
	}