got lognote multi flag search working
This commit is contained in:
@@ -129,15 +129,22 @@ if ($search) {
|
|||||||
$logfromtables[]="lognotes";
|
$logfromtables[]="lognotes";
|
||||||
$logconstraints[]="lognotes.lognote like \"%$srchtext%\"";
|
$logconstraints[]="lognotes.lognote like \"%$srchtext%\"";
|
||||||
}
|
}
|
||||||
// fixme
|
|
||||||
// flags
|
// flags
|
||||||
if (!empty($srchflags)) {
|
if (!empty($srchflags)) {
|
||||||
foreach ($srchflags as $flagtblnum) {
|
unset($flagconstraints);
|
||||||
$flagtblname="flag_{$flagtblnum}";
|
$flagcount=count($srchflags);
|
||||||
$logfromtables[]="lognotes";
|
$logfromtables[]="lognotes";
|
||||||
$logfromtables[]=$flagtblname;
|
$logfromtables[]="flagmap";
|
||||||
$logconstraints[]="lognotes.lognoteid={$flagtblname}.id and {$flagtblname}.target=\"lognotes\"";
|
$flagconstraints[]="flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in (";
|
||||||
|
foreach ($srchflags as $flagid) {
|
||||||
|
$flagconstraints[]="\"$flagid\"";
|
||||||
|
$flagconstraints[]=",";
|
||||||
}
|
}
|
||||||
|
// remove final comma
|
||||||
|
array_splice($flagconstraints, -1, 1);
|
||||||
|
$flagconstraints[]=") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount";
|
||||||
|
// make flagconstraints a single string so that the final implode doesn't split it
|
||||||
|
$logconstraints[]=join('', $flagconstraints);
|
||||||
}
|
}
|
||||||
// uid
|
// uid
|
||||||
if ($srchuid != "any" && $srchuid != "") {
|
if ($srchuid != "any" && $srchuid != "") {
|
||||||
@@ -192,9 +199,24 @@ if ($search) {
|
|||||||
$logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\"";
|
$logconstraints[]="lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\"";
|
||||||
}
|
}
|
||||||
// build the clauses and run the query
|
// build the clauses and run the query
|
||||||
|
echo "logfromtables: ";
|
||||||
|
foreach ($logfromtables as $lft) {
|
||||||
|
echo "$lft ";
|
||||||
|
}
|
||||||
|
echo "<br><br>";
|
||||||
|
|
||||||
|
echo "logconstraints: ";
|
||||||
|
foreach ($logconstraints as $lc) {
|
||||||
|
echo "$lc ";
|
||||||
|
}
|
||||||
|
echo "<br><br>";
|
||||||
|
|
||||||
$logfromclause=implode(",",array_unique($logfromtables));
|
$logfromclause=implode(",",array_unique($logfromtables));
|
||||||
|
echo "logfromclause: $logfromclause <br><br>";
|
||||||
$logwhereclause=implode(" and ",$logconstraints);
|
$logwhereclause=implode(" and ",$logconstraints);
|
||||||
|
echo "logwhereclause: $logwhereclause <br><br>";
|
||||||
$logrowqry=mysqli_query($db,"select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc");
|
$logrowqry=mysqli_query($db,"select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc");
|
||||||
|
echo "select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc";
|
||||||
}
|
}
|
||||||
if ($target[0]=="") $target=[];
|
if ($target[0]=="") $target=[];
|
||||||
if (in_array("maintform",$target)) {
|
if (in_array("maintform",$target)) {
|
||||||
@@ -239,13 +261,22 @@ if ($search) {
|
|||||||
$mffromtables[]="maintactions";
|
$mffromtables[]="maintactions";
|
||||||
$mfconstraints[]="maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)";
|
$mfconstraints[]="maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)";
|
||||||
}
|
}
|
||||||
// fixme
|
|
||||||
// flags
|
// flags
|
||||||
foreach ($srchflags as $flagtblnum) {
|
if (!empty($srchflags)) {
|
||||||
$flagtblname="flag_{$flagtblnum}";
|
unset($flagconstraints);
|
||||||
|
$flagcount=count($srchflags);
|
||||||
$mffromtables[]="maintforms";
|
$mffromtables[]="maintforms";
|
||||||
$mffromtables[]=$flagtblname;
|
$mffromtables[]="flagmap";
|
||||||
$mfconstraints[]="maintforms.maintformid={$flagtblname}.id and {$flagtblname}.target=\"maintforms\"";
|
$flagconstraints[]="flagmap.maintformid=maintforms.maintformid and flagmap.flagid in (";
|
||||||
|
foreach ($srchflags as $flagid) {
|
||||||
|
$flagconstraints[]="\"$flagid\"";
|
||||||
|
$flagconstraints[]=",";
|
||||||
|
}
|
||||||
|
// remove final comma
|
||||||
|
array_splice($flagconstraints, -1, 1);
|
||||||
|
$flagconstraints[]=") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount";
|
||||||
|
// make flagconstraints a single string so that the final implode doesn't split it
|
||||||
|
$logconstraints[]=join('', $flagconstraints);
|
||||||
}
|
}
|
||||||
// uid
|
// uid
|
||||||
if ($srchuid != "any" && $srchuid != "") {
|
if ($srchuid != "any" && $srchuid != "") {
|
||||||
@@ -476,7 +507,7 @@ if (!$print) {
|
|||||||
$flagsperline = 8;
|
$flagsperline = 8;
|
||||||
$flagcount = 1;
|
$flagcount = 1;
|
||||||
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
||||||
if ($srchflags[0] == "") $srchflags = [];
|
//if ($srchflags[0] == "") $srchflags = [];
|
||||||
if (in_array($flagcheckbox["flagid"], $srchflags)) {
|
if (in_array($flagcheckbox["flagid"], $srchflags)) {
|
||||||
printf(
|
printf(
|
||||||
"<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" checked title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
"<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" checked title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
|||||||
Reference in New Issue
Block a user