简体   繁体   English

将“全选”添加到过滤器

[英]Adding 'Select All' to a filter

I have successfully set up a filter for a calendar that displays the upcoming jobs for different users where you can choose the user you want to see the jobs for. 我已经成功地为日历设置了一个过滤器,以显示不同用户的即将到来的工作,您可以在其中选择要查看其工作的用户。 Now, I want to add a 'select all' to the filter so that it shows the jobs for everyone rather than just the specified user. 现在,我想向过滤器添加“全选”,以便它显示每个人的工作,而不仅仅是指定用户。
I have done my research and found a similar question but it doesn't quite apply to my situation (that question used an input form field whereas mine uses the database to create the filter and so that response won't work for me), before I get my question marked as a duplicate which I don't believe it is. 我已经进行了研究,发现了一个类似的问题,但是它不适用于我的情况(该问题使用了输入表单字段,而我的数据库使用了数据库来创建过滤器,因此响应对我不起作用)我将我的问题标记为重复,我不认为是重复。 Here is the page code: 这是页面代码:

if (isset($_REQUEST['id'])) {
     $workDetails = GetWork($_REQUEST['id']);
     $accountName = $_REQUEST['accountname'];
     $accountId = $_REQUEST['accountid'];
}
if(isset($_REQUEST['inassigneduser'])){
     $inassigneduser = $_REQUEST['inassigneduser'];
}else{
     $inassigneduser = $_SESSION['userid'];
}

echo "<h2 class='title'>Planned Works</h2><hr class='red'/>";
?>
<table style="margin-bottom:10px;">
<tr>
<td style='width:120px;'><span class='title'>Assigned To:&nbsp;&nbsp;</span> 
</td>
<td id="plannedworkusers" style='width:170px;text-align:left;'><?php echo 
GetUserCombo($inassigneduser, true, "inassigneduser","All");?></td><td 
style='text-align:left;'></td>
<td style='text-align:left;'><a href='#' class='button' 
name='filterassigneduser' >Filter</a></td>
</tr>
</table>
<?php
echo "<div id='calendar' style='float:left; width:100%; margin-left:10px;'> 
</div>";
$events = '';
$events = GetHolidaysForCal($inassigneduser);

And my functions.php file: 和我的functions.php文件:

function GetHolidaysForCal($inassigneduser)
{
     mysql_connect(DB_HOST, DB_USER, DB_PASS);
     mysql_select_db(DB_NAME) or die("Unable to select database");
     $eventArray = array();

     $sql = "SELECT w.*, c.name AS contactname, a.name AS accountname
        FROM works w, contact c, account a
        WHERE w.id = c.worksid
        AND w.accountid = a.id
        AND c.contacttype = 0
  AND w.assignedtouser = $inassigneduser
        AND (w.infracompletiondate != '0000-00-00'
                OR w.meteringcompletiondate != '0000-00-00'
                OR w.meterremovaldate != '0000-00-00'
                OR w.servicedisconnectiondate != '0000-00-00'
                OR w.gt1date != '0000-00-00'
                OR w.sitesurveydate != '0000-00-00'
                OR w.infrastructurestartdate != '0000-00-00'
      OR w.liveanddeadcheckdate != '0000-00-00')

        ORDER BY w.infracompletiondate ASC, w.meteringcompletiondate ASC ";
     $result = mysql_query($sql);
     $eventstr = "";
     $color = 'black';

I hope that will provide enough information, any help with how to add this 'select all' option would be greatly appreciated! 希望能提供足够的信息,对于如何添加“全选”选项的任何帮助将不胜感激!

After a lot of trial and error, I finally managed to figure it out on my own. 经过大量的试验和错误,我终于设法自己解决了。 Below is the code for my functions.php file which I edited. 以下是我编辑的functions.php文件的代码。

$sql = "SELECT w.*, c.name AS contactname, a.name AS accountname
        FROM works w, contact c, account a
        WHERE w.id = c.worksid
        AND w.accountid = a.id
        AND c.contacttype = 0";

 //Added code
  if ($inassigneduser != "all") {
    $sql .= " AND w.assignedtouser = " . $inassigneduser;
  }

        $sql .= " AND (w.infracompletiondate != '0000-00-00'
                OR w.meteringcompletiondate != '0000-00-00'
                OR w.meterremovaldate != '0000-00-00'
                OR w.servicedisconnectiondate != '0000-00-00'
                OR w.gt1date != '0000-00-00'
                OR w.sitesurveydate != '0000-00-00'
                OR w.infrastructurestartdate != '0000-00-00'
      OR w.liveanddeadcheckdate != '0000-00-00')

        ORDER BY w.infracompletiondate ASC, w.meteringcompletiondate ASC ";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM