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(); }
function saveConfig() { foreach ($this->config_options as $name => $settings) { $si_config = new SI_Config(); $si_config->name = 'cc_processor-' . $GLOBALS['CONFIG']['cc_processor'] . '-' . $name; $si_config->value = $settings['value']; if ($si_config->update() === FALSE) { $this->error = "Error updating configuration parameter: {$si_config->name}\n"; return false; } } }
echo !SI_Config::canEdit('account_payment') ? 'DISABLED' : ''; ?> > <option value="0">Select account...</option> <?php echo SI_Account::getSelectTags($GLOBALS['CONFIG']['account_payment']); ?> </select> </td> </tr> <tr> <td class="dg_data_cell_1">Receivables Account</td> <td class="dg_data_cell_1">This account will be used for all receivables in the Quickbooks export</td> <td class="dg_data_cell_1"> <select name="params[account_rec]" <?php echo !SI_Config::canEdit('account_rec') ? 'DISABLED' : ''; ?> > <option value="0">Select account...</option> <?php echo SI_Account::getSelectTags($GLOBALS['CONFIG']['account_rec']); ?> </select> </td> </tr> <tr> <td colspan="3"><div align="right"><input type="submit" class="button" name="save" value="Save"></div></td> </tr> </table> </div> </div>
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 {
$task_status = new SI_TaskStatus(); $task_statuses = SI_TaskStatus::retrieveSet(); if($task_statuses === FALSE){ $error_msg .= "Error getting task statuses!\n"; debug_message($task_status->getLastError()); } $title = "Priority & Status Configuration"; if($_POST['save']){ if(is_array($_POST['params'])){ foreach($_POST['params'] as $param_name => $param_value){ if(!empty($param_name)){ $modified_config = new SI_Config(); $modified_config->name = $param_name; $modified_config->value = $param_value; if($modified_config->update() === FALSE){ $error_msg .= "Error updating configuration paramenter: $param_name\n"; debug_message($modified_config->getLastError()); break; } } } } if(empty($error_msg)){ header("Location: ".getCurrentURL()."\r\n"); exit(); } }
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(); }
function getAppConfig(){ $config = new SI_Config(); $config_items = $config->retrieveSet(); if($config_items === FALSE || !is_array($config_items)){ trigger_error("Could not retrieve configuration settings from database!", E_USER_ERROR); return FALSE; } $config_hash = array(); foreach($config_items as $item){ $config_hash[$item->name] = $item->value; } return $config_hash; }