$statement=$dbl->executeWithoutParams("SELECT ticket . * FROM ticket LEFT JOIN assigned ON ticket.TId = assigned.Ticket WHERE assigned.Ticket IS NULL");
$selectfrom="SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User";
if($how=="assigned"){
$assign="tu.TUserId = :id";
}elseif($how=="not_assigned"){
$assign="(tu.TUserId != :id OR a.Ticket IS NULL)";
}
}elseif($who=="support_group"){
$selectfrom="SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User LEFT JOIN `forwarded` f ON t.TId = f.Ticket";
//first: find the tickets assigned to the user with status = waiting on support
//second find all not assigned tickets that aren't forwarded yet.
//find all tickets assigned to someone else witht status waiting on support, with timestamp of last reply > 1 day
//find all non-assigned tickets forwarded to the support groups to which that user belongs
$query="SELECT * FROM `ticket` t LEFT JOIN `assigned` a ON t.TId = a.Ticket LEFT JOIN `ticket_user` tu ON tu.TUserId = a.User LEFT JOIN `forwarded` f ON t.TId = f.Ticket