Forum OpenACS Development: "asset-customer.tcl"

Collapse
Posted by Divya R on
Hi,

I am unable to run this program successfully...Can anybody figure out what is the bug??
I am unable to understand the same after having tried for over 10-15 times....yet trying..but all in vain 😟

The output is as under and the code is followed by it: -
extra characters after close-brace
    while executing
"if {$admin_p"
    (file "/web/nspapp/www/nspapp/reports/d_assets-customer1.tcl" line 7)
    invoked from within
"source [ad_conn file]"
    (procedure "rp_handle_tcl_request" line 2)
    invoked from within
"rp_handle_tcl_request"
    invoked from within
"catch $handler error"
    invoked from within
"rp_abstract_url_server"

CODE: -
set title "View Assets and Associated Customers"
set html ""
set db [ns_db gethandle]
set user_id [ad_maybe_redirect_for_registration]
set admin_p [ad_administrator_p $user_id]

if {$admin_p}{
  set selection [ns_db select $db "select delivery_details_id,hw_assets_associated,rack_num,ip_num_associated,so_number,sstf_ref,primary_cust_contact,services_delivered from delivery_details order by hw_assets_associated"]
} else {
set selection [ns_db select $db "select delivery_details_id,hw_assets_associated,rack_num,ip_num_associated,so_number,sstf_ref,primary_cust_contact,services_delivered from delivery_details order by hw_assets_associated where delivery_details_id=$delivery_cetails_id"]
}

append html "

  <table cellpadding=5 cellspacing=4 border=1 width=100%>
        <tr bgcolor=#ddccff><th colspan=9><font face=verdana font size=1>View Assets and Associated Customers Details</font></th></tr>
        <tr bgcolor=#ccddee>
        <th width=5><font face=verdana font size=1>No</font></th>
        <th width=150><font face=verdana font size=1>Asset</font></th>
        <th width=150><font face=verdana font size=1>Rack #</font></th>
        <th width=150><font face=verdana font size=1>IP #</font></th>
        <th width=150><font face=verdana font size=1>SO #</font></th>
        <th width=150><font face=verdana font size=1>SSTF Ref</font></th>
        <th width=150><font face=verdana font size=1>Customer details</font></th>
        <th width=150><font face=verdana font size=1>Service delivered</font></th>
        <th width=200><font face=verdana font size=1>Options</font></th></tr>
  </tr>
"
set count 0
while {[ns_db getrow $db $selection]} {
  set_variables_after_query
    incr count

append html "
<tr bgcolor=#ccddee>
                <td><font face=verdana font size=1>$count</font></td>
        <td><font face=verdana font size=1>$hw_assets_associated</font></td>
        <td><font face=verdana font size=1>$rack_num</font></td>
        <td><font face=verdana font size=1>$ip_num_allocated</font></td>
                <td><font face=verdana font size=1>$so_number</font></td>
                <td><font face=verdana font size=1>$sstf_ref</font></td>
        <td>
            Name : $primary_cust_contact_name <br>
            Email: $primary_cust_contact_email <br>
            Phone Office: $primary_cust_contact_phone_work<br>
            Phone Res: $primary_cust_contact_phone_home
        </td>
                <td><font face=verdana font size=1>$services_delivered</font></td>
                <td><a href=delivery-details?delivery_details_id=$delivery_details_id><font face=verdana font size=1>View</font></a></td>
        </tr>"
}

append  html "
[ad_space 1]|[ad_space 1]<a href=hardware-asset-delete?creation_date=$creation_date>Delete Hardware Asset</a> "

append html "</td></tr>"

if {$count==0} {
append html "<tr><th colspan=8 align=center>No Hardware Asset in the database</th></tr>"

}

append html "</table>"

append page_content "
[nsp_header $title]
<br>
<br>
[ad_scope_context_bar_ws_or_index [list "/nspapp/" "Nsp App"][list "/nspapp/reports/d_index.tcl/" "View Reports"]$title]
<hr><p>
  $html
<p>
<p>
[ad_footer]
"
doc_return 200 text/html $page_content
"d_assets-customer1.tcl" 80L, 3207C

Thanks in advance,
Divya

Collapse
Posted by Torben Brosten on
Hi,

I don't  know  about the SQL  etc, but try changing:

if {$admin_p}{

to

if {$admin_p} {

I believe there should be a space between the close and open brackets.

cheers,
Torben