root_path = cou_getCORootPath( cnx );

__SQL_GET_STRING(name_role, "SELECT name FROM co_sec_role WHERE id=%d", cnx->id_role)

__SEND_MESG_DEBUG("we have name_role: %s", name_role)

if(id_report == 0 && strlen(report_name)>0)
{
@co_getPropByName(par_area, '"report"', report_name, '"id"');
if(err==0)
{
id_report = atoi(get_str);
}
}

fh = ap_pfopen(p, ap_pstrcat( p, root_path, "/forms/", "generic_f", "_head.html", NULL), "r");
if (!fh) cou_error( cnx, "Head file not found");
cou_logError( cnx, CO_LOG_DEBUG, "sending head" );
ap_rputs("<HEAD>\n", r);
ap_kill_timeout(r);

len = ap_send_fd( fh, r ); /* returns total of bytes sent */
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, r, "Head sent: %ld bytes", len);

ap_pfclose(p,fh);

cou_logError( cnx, CO_LOG_DEBUG, "sending script" );
ap_rputs("<SCRIPT>\n", r);

ap_rprintf( r, "var id_session = %d;\n", cou_assignNewSession( cnx ) );
ap_rprintf( r, "var par_id = %d;\n", par_id );
ap_rprintf( r, "var par_class=\'%s\';\n", par_class );
ap_rprintf( r, "var par_area = \'%s\';\n", par_area );
ap_rprintf( r, "var debug_level = %d;\n", cnx->debug_level );
ap_rprintf( r, "var id_report = %d;\n", id_report );
ap_rprintf( r, "var context_name = \'%s\';\n", context_name );
ap_rprintf( r, "var context1 = \'%s\';\n", context1 );
ap_rprintf( r, "var context2 = \'%s\';\n", context2 );
ap_rprintf( r, "var context3 = \'%s\';\n", context3 );

ap_rprintf( r, "var default_open_class_name = \'%s\';\n", default_open_class_name);
ap_rprintf( r, "var default_open_id_prop_name = \'%s\';\n", default_open_id_prop_name);

ap_rprintf( r, "var role = {id : %d , name: \'%s\'};\n", cnx->id_role, name_role );

if(filter_variables !=NULL)
{
int NElems = coa_GetElementCount(cnx, filter_variables);
int count = 0;
ap_rprintf( r, "var filter_variables = { ");
for(count=0; count<NElems; count +=2)
{
if(count>0){ ap_rprintf(r, ", "); };
ap_rprintf( r, " %s : '%s' ",
coa_GetStringElement(cnx, filter_variables, count),
coa_GetStringElement(cnx, filter_variables, count+1)
);
}
ap_rprintf( r, " }; \n");
}
else
{
ap_rprintf( r, "var filter_variables = new Object(); \n");
}
ap_rputs("</SCRIPT>\n", r);

ap_rputs("</HEAD>\n", r);
fh = ap_pfopen(p, ap_pstrcat( p, root_path, "/forms/", "generic_f", "_body.html", NULL), "r");
if (!fh) cou_error( cnx, "Body file not found");
cou_logError( cnx, CO_LOG_DEBUG, "sending body" );
ap_rputs("<BODY>\n", r);
len = ap_send_fd( fh, r ); /* returns total of bytes sent */

if (r->connection->aborted) ap_log_rerror(APLOG_MARK, APLOG_DEBUG, r, "connection aborted");
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, r, "bytes_send=%ld", r->bytes_sent);

ap_soft_timeout((char *) "finish request", r);

ap_log_rerror(APLOG_MARK, APLOG_DEBUG, r, "Body sent: %ld bytes", len);

ap_pfclose(p,fh);
ap_rputs("</BODY>\n", r);

ap_rflush(r);