Advertisement
Guest User

superlinux - saving an Sqlite view to an HTML file using Tcl

a guest
Nov 22nd, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.32 KB | None | 0 0
  1. proc save_current_date_total_income_report { } {
  2.   set filetype  { { {Report as HTML File} {.html} } }
  3.   set filename [tk_getSaveFile -filetypes $filetype]
  4.   set fp [ open $filename "w"]
  5.  
  6.   set report_query { select * from current_date_customer_vs_income }
  7.   puts $fp "<table border=1>\n"
  8.  
  9.   set html_table_headers [ list "<tr>" ]
  10.   set headers [list "customer id" "customer first name" "customer father name" "customer last name" "customer mother name" "customer phone number" "customer address" "customer email address" "total payment" ]
  11.     foreach column $headers {
  12.       lappend html_table_row "<th>$column</th>"
  13.     }
  14.     lappend html_table_row "</tr>"
  15.     puts $fp "$html_table_row\n"
  16.  
  17.   dbcmd eval $report_query {
  18.    
  19.     set html_table_row [ list "<tr>" ]
  20.     set row [list $customer_id $customer_first_name $customer_father_name $customer_last_name $customer_mother_name $customer_phone_number $customer_address $customer_email_address $total_payment]
  21.     foreach column $row {
  22.       lappend html_table_row "<td>$column</td>"
  23.     }
  24.     lappend html_table_row "</tr>"
  25.     puts $fp "$html_table_row\n"
  26.   }
  27.   set total_income [dbcmd eval {select * from current_date_total_income } ]
  28.   puts $fp "<tr><th>Total Income</th></td>"
  29.   puts $fp "<tr><td>$total_income</td></td>"
  30.   puts $fp "</table>\n"
  31.  close $fp
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement