Moved templateselect function from templates.php to functions.php for use in other pages.
This commit is contained in:
@@ -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> or
|
||||||
|
";
|
||||||
|
// 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>
|
||||||
|
";
|
||||||
|
// 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>
|
||||||
|
";
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ $flags=$_POST['flags'] ?? [];
|
|||||||
$refstring=$_REQUEST['refstring'] ?? NULL;
|
$refstring=$_REQUEST['refstring'] ?? NULL;
|
||||||
$submit=$_REQUEST['submit'] ?? NULL;
|
$submit=$_REQUEST['submit'] ?? NULL;
|
||||||
$operation=$_REQUEST['operation'] ?? NULL;
|
$operation=$_REQUEST['operation'] ?? NULL;
|
||||||
//$add=$_REQUEST['add'] ?? NULL;
|
|
||||||
//$edit=$_REQUEST['edit'] ?? NULL;
|
|
||||||
//$delete=$_REQUEST['delete'] ?? NULL;
|
|
||||||
$templateid=$_REQUEST['templateid'] ?? NULL;
|
$templateid=$_REQUEST['templateid'] ?? NULL;
|
||||||
$templatename=$_REQUEST['templatename'] ?? NULL;
|
$templatename=$_REQUEST['templatename'] ?? NULL;
|
||||||
$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL;
|
$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL;
|
||||||
@@ -59,7 +56,7 @@ if ($isadmin) {
|
|||||||
$authorized=FALSE;
|
$authorized=FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
var_dump($_REQUEST);
|
// var_dump($_REQUEST);
|
||||||
|
|
||||||
function templatetable($db,$techid,$user) {
|
function templatetable($db,$techid,$user) {
|
||||||
// Show template table
|
// Show template table
|
||||||
@@ -154,53 +151,6 @@ function templatetable($db,$techid,$user) {
|
|||||||
echo "<br>";
|
echo "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
function templateselect($db,$techid,$operation) {
|
|
||||||
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> or
|
|
||||||
";
|
|
||||||
// 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>
|
|
||||||
";
|
|
||||||
// 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>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
|
|
||||||
// ******** begin database manipulation ********
|
// ******** begin database manipulation ********
|
||||||
|
|
||||||
if ($usertemplateid) {
|
if ($usertemplateid) {
|
||||||
@@ -422,10 +372,9 @@ if ($operation=="delete") {
|
|||||||
echo "
|
echo "
|
||||||
<br><b>$optext template</b><br><hr>
|
<br><b>$optext template</b><br><hr>
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|
||||||
// show the template selection line
|
// show the template selection line
|
||||||
templateselect($db,$techid,$operation);
|
templateselect($techid,$operation);
|
||||||
|
|
||||||
// start template entry section
|
// start template entry section
|
||||||
echo "
|
echo "
|
||||||
|
|||||||
Reference in New Issue
Block a user