$invoices[$row['invoice']]['ids'][] = $ta->id; $checks[$row['check']]['user_id'] = $row['user_id']; $checks[$row['check']]['ids'][] = $ta->cost_trans_id; if ($ta->end_ts > $checks[$row['check']]['timestamp']) { $checks[$row['check']]['timestamp'] = $ta->end_ts; } $checks[$row['check']]['amount'] += $ta->cost; } $task_activity_result->free(); debug('Added task activities to sureinvoice!'); } $si_db = new DBConn(DB_SERVER, DB_DATABASE, DB_USER, DB_PASSWORD); assert_die($si_db->connect(TRUE), "Could not connect to sureinvoice database!\n" . $si_db->getLastError()); debug('Connected to sureinvoice database ' . DB_DATABASE); $dt_db = new DBConn($phpdt_server, $phpdt_database, $phpdt_username, $phpdt_password); assert_die($dt_db->connect(TRUE), "Could not connect to phpdt database!\n" . $dt_db->getLastError()); debug('Connected to phpdt database ' . $phpdt_database); // Migrate companies $companies = array(); $company_rates = array(); $company_sql = "\nSELECT `id`, `name`, `address1`, `address2`, `city`, `state`,\n`zip`, `phone`, `fax`, `hourly_rate`, `created_ts`, `updated_ts`\nFROM `companies`\n"; $company_result = $dt_db->query($company_sql, TRUE); assert_die($company_result, "Could not get company list!\n" . $dt_db->getLastError()); debug('Got ' . $company_result->numRows() . ' company rows from phpdt.'); while ($row = $company_result->fetchArray(MYSQL_ASSOC)) { $company_insert_sql = "\nINSERT INTO companies (id, name, address1, address2, city,\nstate, zip, phone, fax, hourly_rate,created_ts, updated_ts)\nVALUES(" . $row['id'] . ", '" . $si_db->escapeString($row['name']) . "', '" . $row['address1'] . "', \n'" . $row['address2'] . "', '" . $row['city'] . "', '" . $row['state'] . "', \n'" . $row['zip'] . "', '" . $row['phone'] . "', '" . $row['fax'] . "', \n" . $row['hourly_rate'] . ", " . $row['created_ts'] . ", " . $row['updated_ts'] . ")\n\t"; assert_die($si_db->query($company_insert_sql, TRUE), "Error adding company!\n" . $si_db->getLastError(), FALSE); debug('Added ' . $row['name'] . ' to sureinvoice'); $company_rates[$row['id']] = $row['hourly_rate']; $companies[$row['id']] = $row; }
$include_path = realpath(dirname(__FILE__)); if (!file_exists($include_path . '/global_config.php') || filesize($include_path . '/global_config.php') < 10) { 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'])) {