<?php
$page_security = 'SA_SETUPCOMPANY';
$path_to_root = "../../..";
include($path_to_root . "/includes/session.inc");

page(_($help_context = "External Setup"));
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/admin/db/company_db.inc");
include_once($path_to_root . "/modules/external/includes/ui/utils_ui.inc");

//-------------------------------------------------------------------------------------------------
// initialize stuff just in case
$init = 0;
if (get_company_pref('documents_footer_text') === null) {
    set_company_pref('documents_footer_text', 'system.external', 'varchar', 100, '');
    $init++;
}



//if ($init)
//    refresh_sys_prefs();

function can_process() {
    $errors = 0;
    return ($errors == 0);
}

//-------------------------------------------------------------------------------------------------

if (isset($_POST['submit']) && can_process()) {
    update_company_prefs(get_post(array('documents_footer_text')));

    display_notification(_("Settings have been saved."));
}

if(!isset($_POST['documents_footer_text'])){
    $prefs = get_company_prefs();
    $_POST['documents_footer_text'] = $prefs['documents_footer_text'];
}
//-------------------------------------------------------------------------------------------------

start_form();

div_start('details');
start_table(TABLESTYLE2);

$Ajax->activate('_page_body');
textarea_cells(_("Documents Footer Text"), "documents_footer_text", null, 50, 5, 5000);
end_table(1);
div_end();

echo '<center>';
submit('submit', _("Update"), true, '', 'default');
echo '</center>';
end_form(2);
echo "<hr>";

//-------------------------------------------------------------------------------------------------

end_page();
?>
