if ($next_start_date != $result->fields['start_date']) { $fy_array = array('start_date' => $next_start_date); db_perform(TABLE_ACCOUNTING_PERIODS, $fy_array, 'update', 'period = ' . (int) $next_period); $messageStack->add(GL_ERROR_FISCAL_YEAR_SEQ, 'caution'); $fy++; } } gen_add_audit_log(GL_LOG_FY_UPDATE . TEXT_UPDATE); break; case 'new': validate_security($security_level, 2); $result = $db->Execute("select * from " . TABLE_ACCOUNTING_PERIODS . " where period = " . $highest_period); $next_fy = $result->fields['fiscal_year'] + 1; $next_period = $result->fields['period'] + 1; $next_start_date = date('Y-m-d', strtotime($result->fields['end_date']) + 60 * 60 * 24); $highest_period = validate_fiscal_year($next_fy, $next_period, $next_start_date); build_and_check_account_history_records(); // *************** roll account balances into next fiscal year ************************* $glEntry = new journal(); $result = $db->Execute("select id from " . TABLE_CHART_OF_ACCOUNTS); while (!$result->EOF) { $glEntry->affected_accounts[$result->fields['id']] = 1; $result->MoveNext(); } $glEntry->update_chart_history_periods(CURRENT_ACCOUNTING_PERIOD); // from current period through new fiscal year $fy = $next_fy; // set the pointer to open the fiscal year added gen_add_audit_log(GL_LOG_FY_UPDATE . TEXT_ADD); break; case "change":
} } // install reports now that categories are set up if ($_POST['phreeform_action'] != 'data') { // if=data reports have been copied, else load basic reports foreach ($copy_modules as $entry) { admin_add_reports($entry, DIR_FS_MY_FILES . $db_name . '/phreeform/'); } } } if (!$error && $_POST['phreebooks_action'] != 'data') { // install fiscal year if the phreebooks data is not copied $db->Execute("TRUNCATE TABLE " . TABLE_ACCOUNTING_PERIODS); require_once DIR_FS_MODULES . 'phreebooks/functions/phreebooks.php'; $dates = gen_get_dates(); validate_fiscal_year($dates['ThisYear'], '1', $dates['ThisYear'] . '-' . $dates['ThisMonth'] . '-01'); build_and_check_account_history_records(); gen_auto_update_period(false); } if (!$error) { // reset SESSION['company'] to new company and redirect to install->store_setup $db->Execute("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $co_name . "' \n\t where configuration_key = 'COMPANY_NAME'"); $messageStack->add(SETUP_CO_MGR_CREATE_SUCCESS, 'success'); gen_add_audit_log(SETUP_CO_MGR_LOG . TEXT_COPY, $db_name); $_SESSION['db_server'] = $db_server; $_SESSION['company'] = $db_name; $_SESSION['db_user'] = $db_user; $_SESSION['db_pw'] = $db_pw; gen_redirect(html_href_link(FILENAME_DEFAULT, $get_parmas, ENABLE_SSL_ADMIN ? 'SSL' : 'NONSSL')); } else { // restore db connection
require '../../includes/configure.php'; require '../../includes/database_tables.php'; if (!defined('DB_TYPE') || DB_TYPE == '') { echo 'Database Type Invalid. Did your configure.php file get written correctly?'; $zc_install->error = true; } $db->Connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE) or die("Unable to connect to database"); if (isset($_POST['submit'])) { $month = db_prepare_input($_POST['store_period_1']); $fiscal_year = db_prepare_input($_POST['store_fiscal_year']); $first_date = $fiscal_year . '-' . $month . '-01'; if ($zc_install->error == false) { require_once DIR_FS_MODULES . 'gen_ledger/functions/gen_ledger.php'; require_once DIR_FS_MODULES . 'general/functions/gen_functions.php'; require_once DIR_FS_MODULES . 'general/functions/general.php'; validate_fiscal_year($fiscal_year, '1', $first_date); build_and_check_account_history_records(); gen_auto_update_period(false); $db->Close(); header('location: index.php?main_page=coa_defaults&language=' . $language); exit; } } if (isset($_POST['skip'])) { $db->Close(); header('location: index.php?main_page=coa_defaults&language=' . $language); exit; } //if not submit, set some defaults $period_string = ''; foreach ($period_values as $value) {
$db->Execute("insert into " . TABLE_USERS_PROFILES . " set user_id = " . $user_id . ",\n\t\t\t\t menu_id = 'index', module_id = 'phreedom', dashboard_id = 'to_do', column_id = 1, row_id = 1, \n\t\t\t \t params = '" . serialize($params) . "'"); } } if (!$error) { // install fiscal year, default chart of accounts if (DEBUG) { $messageStack->debug("\n installing fiscal year."); } require_once '../modules/phreebooks/functions/phreebooks.php'; $db->Execute("TRUNCATE TABLE " . TABLE_ACCOUNTING_PERIODS); $current_year = date('Y'); $start_year = $fy_year; $start_period = 1; $runaway = 0; while ($start_year <= $current_year) { validate_fiscal_year($start_year, $start_period, $start_year . '-' . $fy_month . '-01'); $start_year++; $start_period = $start_period + 12; $runaway++; if ($runaway > 10) { break; } } if (DEBUG) { $messageStack->debug("\n loading chart of accounts"); } // load the retail chart as default if the chart of accounts table is empty $result = $db->Execute("select id from " . TABLE_JOURNAL_MAIN . " limit 1"); $entries_exist = $result->RecordCount() > 0 ? true : false; $result = $db->Execute("select id from " . TABLE_CHART_OF_ACCOUNTS . " limit 1"); $chart_exists = $result->RecordCount() > 0 ? true : false;