Moved templateselect function from templates.php to functions.php for use in other pages.

This commit is contained in:
2026-02-12 19:42:36 -05:00
parent a79f73a8ca
commit 0547e97479
2 changed files with 53 additions and 54 deletions

View File

@@ -931,4 +931,54 @@ function format_message($msgtype,$msgtxt) {
";
}
function templateselect($techid,$operation) {
// Displays a line enabling selection of a user or global template
// $techid is the id number of the current tech
// $operation is one of "add" "edit" "delete"
global $db;
echo "
<form method=\"post\" action=\"templates.php\">
";
// generate template selection line
echo "
<table border=\"0\" cellpadding=\"10\"><tr>
";
// list user templates
echo "
<td>
<select name=\"usertemplateid\" title=\"Select the user template you'd like to load and click the Load Template button. User template selection takes precedence.\">
";
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc");
printf("<option value=\"%s\" selected>%s</option>","0","Select user template");
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
}
echo "
</select>&nbsp;or&nbsp;
";
// list global templates
echo "
<select name=\"globaltemplateid\" title=\"Select the global template you'd like to load and click the Load Template button. User template selection takes precedence.\">
";
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"0\" order by templatename asc");
printf("<option value=\"%s\" selected>%s</option>","0","Select global template");
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
}
echo "
</select>&nbsp;&nbsp;
";
// show load button
echo "
<input type=\"hidden\" name=\"operation\" value=\"$operation\">
<input type=\"submit\" name=\"loadtemplate\" value=\"Load Template\">
</td>
<td>
<a href=\"templates.php\">Manage templates</a>
</td>
</tr></table>
<hr>
</form>
";
}
?>