Add tcl (apache rivet) web interface realisation
This commit is contained in:
parent
97a8bbacb7
commit
25a0c92f08
106
www.tcl/index.rvt
Normal file
106
www.tcl/index.rvt
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
<?
|
||||||
|
######################################################
|
||||||
|
# web
|
||||||
|
# Distributed under GNU Public License
|
||||||
|
# Author: Sergey Kalinin banzaj28@yandex.ru
|
||||||
|
# Copyright (c) "Sergey Kalinin", 2017, http://nuk-svk.ru
|
||||||
|
######################################################
|
||||||
|
|
||||||
|
package require mysqltcl
|
||||||
|
|
||||||
|
|
||||||
|
proc main {} {
|
||||||
|
if { [::rivet::var exists query_type] } {
|
||||||
|
set query_type [::rivet::var get query_type]
|
||||||
|
if {$query_type == "internal"} {
|
||||||
|
set output "[header] [body] [getInternalNumbers] [footer]"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
set output "[header] [body] [footer]"
|
||||||
|
}
|
||||||
|
return $output
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
proc header {} {
|
||||||
|
set txtHeader "<html><head><meta charset=\"utf-8\"><link rel=\"shortcut icon\" href=\"favicon.png\" >\n
|
||||||
|
<link rel=\"icon\" type=\"image/png\" href=\"favicon.png\" >\n
|
||||||
|
<link href=\"css/layout.css\" rel=\"stylesheet\" type=\"text/css\" />\n
|
||||||
|
<title>Телефоны</title>\n
|
||||||
|
<link href=\"css/menu.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body>\n"
|
||||||
|
return $txtHeader
|
||||||
|
}
|
||||||
|
|
||||||
|
proc footer {} {
|
||||||
|
set txtFooter "</body></html>\n"
|
||||||
|
return $txtFooter
|
||||||
|
}
|
||||||
|
|
||||||
|
proc body {} {
|
||||||
|
set txtBody "<table><tr><td><h2 align=left>ТЕЛЕФОНЫ</h2></td></tr>\n
|
||||||
|
<tr><td>[menu]</td></tr></table>\n"
|
||||||
|
return $txtBody
|
||||||
|
}
|
||||||
|
proc menu {} {
|
||||||
|
set txtMenu "<div class=\"container\"><ul id=\"nav\"></li>
|
||||||
|
<li><a class=\"hsubs\" href=\"#\">Справочник</a><ul class=\"subs\">
|
||||||
|
<li><a href=\"?query_type=external\">Городские телефоны</a></li>
|
||||||
|
<li><a href=\"?query_type=internal\">Внутренние</a></li></li>
|
||||||
|
<li><a href=\"?query_type=ldap\">Внутренние (AD)</a></li></ul></li>
|
||||||
|
<li><a class=\"hsubs\" href=\"\">Отчёты</a><ul class=\"subs\">
|
||||||
|
<li><a href=\"?query_type=report&report_type=int\">Список звонков по номеру</a></li>
|
||||||
|
<li><a href=\"?query_type=report&report_type=dep\">Звонки по отделам</a></li>\n</ul></div>"
|
||||||
|
return $txtMenu
|
||||||
|
}
|
||||||
|
|
||||||
|
proc connectDB {} {
|
||||||
|
return [mysql::connect -host localhost -user root -db ats -encoding binary]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Список внутренних номеров из СУБД
|
||||||
|
proc getInternalNumbers {} {
|
||||||
|
set conn [connectDB]
|
||||||
|
set order "int_number"
|
||||||
|
set result "<h4 align=left>Список внутренних телефонов</h4>"
|
||||||
|
set qr "SELECT * FROM int_number ORDER by $order"
|
||||||
|
set query [mysql::query $conn $qr]
|
||||||
|
|
||||||
|
set listHeader "<table class=\"table_dark\"><tr><th>№ п/п</th>\n
|
||||||
|
<th><a href=index.py?query_type=internal&order=int_number>Телефон</a></th>\n
|
||||||
|
<th><a href=index.py?query_type=internal&order=fio>ФИО</a></th>\n
|
||||||
|
<th>Описание<th>Эл.почта</th></tr>\n"
|
||||||
|
set result "$result $listHeader"
|
||||||
|
set rowData ""
|
||||||
|
while {[set row [mysql::fetch $query]]!=""} {
|
||||||
|
set rowData "<tr><td>[lindex $row 0]</td>
|
||||||
|
<td>[lindex $row 1]</td>
|
||||||
|
<td>[lindex $row 2]</td>
|
||||||
|
<td>[lindex $row 4]</td>
|
||||||
|
<td><a href=\"mailto:[lindex $row 3]\">[lindex $row 3]</a></td></tr>\n"
|
||||||
|
}
|
||||||
|
mysql::endquery $query
|
||||||
|
#set result "$result [encoding convertto utf-8 $rowData]"
|
||||||
|
set result "$result $rowData"
|
||||||
|
|
||||||
|
return "$result </table>\n"
|
||||||
|
|
||||||
|
}
|
||||||
|
# Список пользователей (ФИО, телефон, почта, отдел) из LDAP (AD)
|
||||||
|
proc getLDAPusers {} {
|
||||||
|
}
|
||||||
|
proc getCOline {} {
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ReportForm {} {
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ReportData {environ} {
|
||||||
|
}
|
||||||
|
|
||||||
|
#puts [header]
|
||||||
|
#puts [body]
|
||||||
|
#puts [footer]
|
||||||
|
puts [main]
|
||||||
|
?>
|
||||||
|
|
67
www.tcl/vars.rvt
Normal file
67
www.tcl/vars.rvt
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?
|
||||||
|
######################################################
|
||||||
|
# web
|
||||||
|
# Distributed under GNU Public License
|
||||||
|
# Author: Sergey Kalinin banzaj28@yandex.ru
|
||||||
|
# Copyright (c) "Sergey Kalinin", 2017, http://nuk-svk.ru
|
||||||
|
######################################################
|
||||||
|
|
||||||
|
|
||||||
|
set errlist {}
|
||||||
|
if { [::rivet::var exists title] } {
|
||||||
|
set title [::rivet::var get title]
|
||||||
|
} else {
|
||||||
|
set errlist "You need to enter a title"
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [::rivet::var exists salary] } {
|
||||||
|
set salary [::rivet::var get salary]
|
||||||
|
if { ! [string is digit $salary] } {
|
||||||
|
lappend errlist "Salary must be a number"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lappend errlist "You need to enter a salary"
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [::rivet::var exists boss] } {
|
||||||
|
set boss [::rivet::var get boss]
|
||||||
|
} else {
|
||||||
|
set boss "Mr. Burns"
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [::rivet::var exists skills] } {
|
||||||
|
set skills [::rivet::var list skills]
|
||||||
|
} else {
|
||||||
|
lappend errlist "You need to enter some skills"
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [llength $errlist] != 0 } {
|
||||||
|
foreach err $errlist {
|
||||||
|
puts "<b> $err </b>"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
puts "Thanks for the information!"
|
||||||
|
?>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><b>Title:</b></td>
|
||||||
|
<td><?= $title ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Boss:</b></td>
|
||||||
|
<td><?= $boss ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Salary:</b></td>
|
||||||
|
<td><?= $salary ?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Skills:</b></td>
|
||||||
|
<td><?= $skills ?></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user