// /************** Check user security *****************************/ $security_level = validate_user(SECURITY_ID_IMPORT_BANK); /************** include page specific files *********************/ gen_pull_language($module); gen_pull_language('phreebooks'); gen_pull_language('phreebooks', 'admin'); gen_pull_language('contacts'); require_once DIR_FS_MODULES . 'phreebooks/classes/gen_ledger.php'; require_once DIR_FS_MODULES . 'phreedom/functions/phreedom.php'; require_once DIR_FS_WORKING . 'functions/import_bank.php'; /************** page specific initialization *************************/ $error = false; $bank_acct = isset($_GET['bank_acct']) ? $_GET['bank_acct'] : $_POST['bank_acct']; $page_list = array(); $page_list[$file] = array('title' => constant('MODULE_IMPORT_BANK_TITLE'), 'structure' => load_module_xml('import_bank/file')); /*************** hook for custom actions ***************************/ $custom_path = DIR_FS_MODULES . 'import_bank/custom/pages/main/extra_actions.php'; if (file_exists($custom_path)) { include $custom_path; } /*************** Act on the action request *************************/ switch ($_REQUEST['action']) { case 'import_csv': if (!validate_upload('file_name', 'text', 'csv')) { break; } $result = bank_import_csv($page_list[$subject]['structure'], 'file_name', $bank_acct); break; case 'sample_csv': $output = build_sample_csv($page_list[$subject]['structure'], 'bank_import');
$sql = "select c.id, beginning_balance, c.description, c.account_type\n\tfrom " . TABLE_CHART_OF_ACCOUNTS . " c inner join " . TABLE_CHART_OF_ACCOUNTS_HISTORY . " h on c.id = h.account_id\n\twhere h.period = 1 order by c.id"; $result = $db->Execute($sql); $glEntry->beg_bal = array(); while (!$result->EOF) { $glEntry->beg_bal[$result->fields['id']] = array('desc' => $result->fields['description'], 'type' => $result->fields['account_type'], 'type_desc' => $coa_types[$result->fields['account_type']]['text'], 'beg_bal' => $result->fields['beginning_balance']); $glEntry->affected_accounts[$result->fields['id']] = true; // build list of affected accounts to update chart history $result->MoveNext(); } $page_list = array(); $dir = scandir(DIR_FS_MODULES); foreach ($dir as $file) { if (is_dir(DIR_FS_MODULES . $file) && $file != '.' && $file != '..') { if (file_exists(DIR_FS_MODULES . $file . '/' . $file . '.xml')) { gen_pull_language($file, 'admin'); $page_list[$file] = array('title' => constant('MODULE_' . strtoupper($file) . '_TITLE'), 'structure' => load_module_xml($file)); } } } /*************** hook for custom actions ***************************/ $custom_path = DIR_FS_MODULES . 'phreedom/custom/pages/import_export/extra_actions.php'; if (file_exists($custom_path)) { include $custom_path; } /*************** Act on the action request *************************/ switch ($_REQUEST['action']) { case 'sample_xml': case 'sample_csv': $type = $_REQUEST['action'] == 'sample_csv' ? 'csv' : 'xml'; switch ($type) { case 'xml':