Page 1 of 1
IF Statement HELP
Posted: Thu Jan 14, 2010 5:48 am
by Jay87
Hi guys,
I want to create an IF statement that checks the helpdesk to see if a call is 'open' and 'high priority' and if this is true then to change the font of that call to RED (this will make all the high priority calls stand out on the helpdesk to get people's attention)...
I tried the following code:
Code: Select all
if ($item['priority']==High && $item['open'] style=red;)
This made the page crash but if i take the
style=red bit out the page runs fine but obviously im not telling it to do anything...
Any ideas?
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 5:56 am
by aravona
Code: Select all
if ($item['priority']==High && $item['open'])
{
style=red;
}
Try that instead.
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 6:05 am
by Jay87
aravona wrote:Code: Select all
if ($item['priority']==High && $item['open'])
{
style=red;
}
Try that instead.
Still just get a blank page when i tries that
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 6:09 am
by aravona
ok well then see if your code is being understood try:
Code: Select all
if ($item['priority']=="High" && $item['open'])
{
style=red;
}
try putting single or double quotes around the High.
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 6:15 am
by Jay87
aravona wrote:ok well then see if your code is being understood try:
Code: Select all
if ($item['priority']=="High" && $item['open'])
{
style=red;
}
try putting single or double quotes around the High.
Same result...
Do you want me to post the code for the whole page? (It's very long mind)!
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 6:26 am
by aravona
are you getting a blank page or an error? (and by blank page I mean fully blank)
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 6:28 am
by Jay87
aravona wrote:are you getting a blank page or an error? (and by blank page I mean fully blank)
Fully blank with no error...
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 6:31 am
by Jay87
Here's the code for the whole page:
Code: Select all
<?
if (!$_GET['strip']){include 'header.htm';} else {include 'functions.php';echo "<html><head><link href=\"css/style.css\" rel=\"stylesheet\" type=\"text/css\" /></head><body leftmargin=0 topmargin=0>";}
include 'dbcon.php';
//echo "C:" . $_SESSION['companyfilter'];
//Set Default Filters
if ($_SESSION['statfilter']==NULL){$_GET['statfilter']="My Calls";}
if ($_SESSION['timefilter']==NULL){$_GET['timefilter']="All";}
if ($_SESSION['durfilter']==NULL){$_GET['durfilter']="All";}
if ($_SESSION['queuefilter']==NULL){$_GET['queuefilter']="All";}
if ($_SESSION['chargefilter']==NULL){$_GET['chargefilter']="All";}
if ($_GET['page']!=NULL)
{
$_SESSION['page'] = $_GET['page'];
}
if ($_SESSION['page']==NULL){$_SESSION['page']=1;}
//Does the user want to change or reverse the sort field?
if ($_GET['sort']!=NULL)
{
if ($_GET['sort'] == $_SESSION['sort']){if ($_SESSION['sort_dir']=='DESC'){$_SESSION['sort_dir'] = 'ASC';} else {$_SESSION['sort_dir'] = 'DESC';}}
$_SESSION['sort'] = $_GET['sort'];
}
if ($_GET['statfilter']!=NULL)
{
if ($_GET['statfilter']!=$_SESSION['statfilter'])
{
$_SESSION['statfilter'] = $_GET['statfilter'];
$_SESSION['page']=1;
}
}
if ($_GET['timefilter']!=NULL)
{
$_SESSION['timefilter'] = $_GET['timefilter'];
}
if ($_GET['durfilter']!=NULL)
{
$_SESSION['durfilter'] = $_GET['durfilter'];
}
if ($_GET['queuefilter']!=NULL)
{
$_SESSION['queuefilter'] = $_GET['queuefilter'];
}
if ($_GET['chargefilter']!=NULL)
{
$_SESSION['chargefilter'] = $_GET['chargefilter'];
}
//Convert the sort info into a variable
switch ($_SESSION['sort']){
case NULL:
$sort = "logged DESC, priority DESC,(faultlog.id_prefix + faultlog.id)";
$_GET['sort'][1]='r';
break;
case 0:
$sort = "priority";
break;
case 1:
$sort = "(faultlog.id_prefix + faultlog.id)";
break;
case 2:
$sort = "description";
break;
case 3:
$sort = "logged";
break;
case 4:
$sort = "elapsed";
break;
case 5:
$sort = "engineer";
break;
case 6:
$sort = "company";
break;
case 7:
$sort = "status";
break;
}
$status_low=0;
//Apply any filters
switch ($_SESSION['statfilter'])
{
case 'All Calls':
$filter = "";
$status_low=0;
$status_up=100;
break;
case 'My Calls':
$filter = " AND (faultlog.engid='" . $_SESSION['guid'] . "' OR faultlog.engid='0')";
$status_up=14;
break;
case 'Unassigned Calls':
$filter = " AND faultlog.engid='0'";
$status_up=14;
break;
case 'Open Calls':
$filter = "";
$status_up=14;
break;
case 'Closed Calls':
$filter = "";
$status_low=15;
$status_up=15;
break;
case 'Invoiced Calls':
$filter = "";
$status_low=25;
$status_up=30;
break;
case 'Contract Calls':
$filter = " AND contract=1";
$status_up=100;
break;
}
switch ($_SESSION['timefilter'])
{
case 'All':
break;
case 'Today':
$filter .= " AND logged>DATEADD(d,-1,CURRENT_TIMESTAMP)";
break;
case 'Last Week':
$filter .= " AND logged>DATEADD(d,-7,CURRENT_TIMESTAMP)";
break;
case 'Last Month':
$filter .= " AND logged>DATEADD(m,-1,CURRENT_TIMESTAMP)";
break;
case 'This Year':
$filter .= " AND logged>DATEADD(yyyy,-1,CURRENT_TIMESTAMP)";
break;
}
switch ($_SESSION['durfilter'])
{
case 'All':
break;
case '2 Days':
$filter .= " AND DATEDIFF(s,notes.date,GETDATE())>172800";
break;
case '1 Week':
$filter .= " AND DATEDIFF(s,notes.date,GETDATE())>604800";
break;
}
switch ($_SESSION['chargefilter'])
{
case 'All':
break;
case 'Chargeable':
$filter .= " AND chargable=1";
break;
case 'Non Chargeable':
$filter .= " AND chargable=0";
break;
}
if ($_GET['companyfilter']){$filter .= " AND contact.company='" . $_GET['companyfilter'] . "'";}
if ($_GET['textfilter']){$filter .= " AND ((faultlog.id_prefix+faultlog.id) LIKE '%" . $_GET['textfilter'] . "%' OR faultlog.company LIKE '%" . $_GET['textfilter'] . "%' OR faultlog.description LIKE '%" . $_GET['textfilter'] . "%')";}
$query = mssql_query("SELECT id FROM queue WHERE description='" . $_SESSION['queuefilter'] . "'",$db);
if (mssql_num_rows($query)!=0){$filter .= "AND queueid=" . mssql_result($query,0,0);}
//Compile the database query
$query_string = "
DATEDIFF(s,date,GETDATE()) AS elapsed,
logged,CONVERT(char(10),logged,103) as logged_fmt, faultlog.enduser , faultlog.description, faultlog.id, faultlog.id_prefix, callstatus.name AS
status , contact.forename, calltype.name AS
type , contact.response,company = (case faultlog.company WHEN 'None' THEN faultlog.enduser ELSE faultlog.company END), DATEDIFF(s,logged,faultlog.closed) AS closed, (contact.forename + ' ' + contact.surname) as contact,(engineer.forename + ' ' + engineer.surname) as engineer, priority
FROM faultlog
INNER JOIN engineer ON engineer.id = faultlog.engid
INNER JOIN calltype ON calltype.id = faultlog.typeid
LEFT OUTER JOIN contact ON contact.id = faultlog.contid
INNER JOIN callstatus ON callstatus.id = faultlog.status
LEFT OUTER JOIN notes ON (notes.id = faultlog.id AND notes.id_prefix=faultlog.id_prefix)
WHERE (accountstatus!=2 OR accountstatus IS NULL) AND status<=$status_up AND status>=$status_low AND ((
(
SELECT COUNT( date )
FROM notes
WHERE notes.id = faultlog.id AND notes.id_prefix=faultlog.id_prefix
) =0
) OR (
date !=0 AND date = (
SELECT TOP 1 date
FROM notes
WHERE notes.id = faultlog.id AND notes.id_prefix=faultlog.id_prefix ORDER BY date DESC
))
)";
if ($_SESSION['conts'] && $_SESSION['level']<=3)
{
$query_string .= " AND (";
foreach ($_SESSION['conts'] as $c)
{
$query_string .= "contact.id=" . $c . " OR ";
}
$query_string = substr($query_string,0,strlen($query_string)-3) . ")";
}
$query_string .= $filter;
$query_string .= " ORDER BY " . $sort . " " . $_SESSION['sort_dir'];
$nopages = mssql_num_rows(mssql_query("SELECT " . $query_string));
$query = mssql_query("SELECT TOP (10+ " .($_SESSION['page']-1)*20 . ")" . $query_string,$db);
$_SESSION['curquery'] = $query_string;
//$nopages = mssql_num_rows($query);
if (!$_GET['strip']){
?>
<br>
<table width=100% cellspacing=1 cellpadding=0 class=smooth>
<tr><th class=smooth_title colspan=8><?echo "Last 10 Calls...";?></th><th class=smooth_title style='text-align:center;color:332233;cursor:pointer;' onclick="document.location='printlist.php';">Print</th></tr>
<? } else { echo "<table width=800 cellspacing=1 cellpadding=0 class=smooth>";}// Strip?>
<tr><th class=smooth width=20 onclick="document.location='calllist.php?sort=0&page=1';"> </th><th class=smooth onclick="document.location='calllist.php?sort=1&page=1';">Call ID</th><th class=smooth onclick="document.location='calllist.php?sort=2&page=1';">Description</th><th class=smooth onclick="document.location='calllist.php?sort=3&page=1';">Logged</th><th class=smooth onclick="document.location='calllist.php?sort=4&page=1';">Elapsed</th><th class=smooth>SLA</th><th class=smooth onclick="document.location='calllist.php?sort=5&page=1';">Engineer</th><th class=smooth onclick="document.location='calllist.php?sort=6&page=1';">Company</th><th class=smooth onclick="document.location='calllist.php?sort=7&page=1';">Status</th></tr>
<?
mssql_data_seek($query,($_SESSION['page']-1)*20);
$stripe='';
while ($item = mssql_fetch_array($query))
{
if ($item['closed']==NULL){$el = $item['elapsed'];} else {$el = $item['closed'];}
$days = floor($el / 86400);
$hours = floor(($el - ($days * 86400))/ 3600);
$mins = floor(($el - ($days * 86400) - ($hours * 3600)) / 60);
if ($_SESSION['level']==3)
{
echo "<tr onclick=\"document.location='viewcall.php?id=" . $item['id'] . "&pfx=" . $item['id_prefix']; if($HTTP_SERVER_VARS['QUERY_STRING']){ echo "&";} echo $HTTP_SERVER_VARS['QUERY_STRING'] . "';\"><td class=smooth" . $stripe . "><img src='/images/icons/pri" . $item['priority'] . ".gif'/></td><td align=center class=smooth" . $stripe .">" . $item['id_prefix'] . $item['id'] . "</td><td class=smooth" . $stripe .">" . substr($item['description'],0,50) . "</td><td class=smooth" . $stripe .">" . $item['logged_fmt'] . "</td><td class=smooth" . $stripe .">" . $days . "d " . $hours . "h " . $mins . "m </td><td class=smooth>" . $item['response'] . "</td><td class=smooth" . $stripe ." style=\"color:DD5555;\">" . $item['engineer'] . "</td><td class=smooth" . $stripe .">" . $item['contact'] . "</td><td class=smooth" . $stripe ." style=\"color:5555AA;\">" . $item['status'] . "</td></tr>";
} else {
echo "<tr onclick=\"document.location='viewcall.php?id=" . $item['id'] . "&pfx=" . $item['id_prefix']; if($HTTP_SERVER_VARS['QUERY_STRING']){ echo "&";} echo $HTTP_SERVER_VARS['QUERY_STRING'] . "';\"><td class=smooth" . $stripe . "><img src='/images/icons/pri" . $item['priority'] . ".gif'/></td><td align=center class=smooth" . $stripe .">" . $item['id_prefix'] . $item['id'] . "</td><td class=smooth" . $stripe .">" . substr($item['description'],0,50) . "</td><td class=smooth" . $stripe .">" . $item['logged_fmt'] . "</td><td class=smooth" . $stripe .">" . $days . "d " . $hours . "h " . $mins . "m </td><td class=smooth>" . $item['response'] . "</td><td class=smooth" . $stripe ." style=\"color:DD5555;\">" . $item['engineer'] . "</td><td class=smooth" . $stripe .">" . $item['company'] . "</td><td class=smooth" . $stripe ." style=\"color:5555AA;\">" . $item['status'] . "</td></tr>";
}
if ($stripe=='1'){$stripe='';} else {$stripe='1';}
}
?>
<style="font-size:3px;">
<?
//Summary Table
?>
<table width=100% height=66% cellspacing=1 cellpadding=0 class=smooth>
<tr><th colspan=8 style='text-align:center;background:red;font-size:30px;'><a href='index.php' style=color:white;><?echo"Priority"?></th><th colspan=8 style='text-align:center;background:orange;font-size:30px;'><a href='index.php' style=color:white;><?echo"Routine"?></th></tr>
<tr><th colspan=8 style='text-align:center;background:green;font-size:30px;'><a href='index.php' style=color:white;><?echo"Workshop"?></th><th colspan=8 style='text-align:center;background:blue;font-size:30px;'><a href='index.php' style=color:white;><?echo"Work Req"?></th></tr>
</table>
<meta http-equiv="refresh" content="120;url=calllist.php">
</table>
</td>
</tr>
</table>
<?
include 'footer.htm';
?>
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 6:35 am
by aravona
erm, if the whole page is blank, humour me a minute.
<?php instead of <? at the top?
(just to explain, I didnt put the 'php' at the top of a lot of work at uni and the server didnt like it, so may as well eliminate the obvious)
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 7:37 am
by Jay87
aravona wrote:erm, if the whole page is blank, humour me a minute.
<?php instead of <? at the top?
(just to explain, I didnt put the 'php' at the top of a lot of work at uni and the server didnt like it, so may as well eliminate the obvious)
Would have been funny if it was something so simple..!
Sadly for me i still get the blank screen

Re: IF Statement HELP
Posted: Thu Jan 14, 2010 7:40 am
by aravona
haha, sometimes it really is that simple.
Have you tried an echo test at the top? something like the usual ' echo "hello world!"; ' just to see if your code is being read at all? When I'm stuck I tend to echo a lot of things. Sorry I can't be of much more use I've been staring at CSS for the past 5 hours and am kinda stuck in that mode!
Re: IF Statement HELP
Posted: Thu Jan 14, 2010 7:50 am
by Jay87
aravona wrote:haha, sometimes it really is that simple.
Have you tried an echo test at the top? something like the usual ' echo "hello world!"; ' just to see if your code is being read at all? When I'm stuck I tend to echo a lot of things. Sorry I can't be of much more use I've been staring at CSS for the past 5 hours and am kinda stuck in that mode!
I am not sure if the code i posted is correct...! I am new to PHP so may have made a mistake...
It makes sense in my head but it probably needs altering and that would be my guess why i am getting a blank page!
Re: IF Statement HELP
Posted: Fri Jan 15, 2010 5:08 am
by Jay87
Right i have changed my approach and am trying to
Code: Select all
<?PHP
mssql_data_seek($query,($_SESSION['page']-1)*20);
$stripe='';
while ($item = mssql_fetch_array($query))
{
if ($item['closed']==NULL){$el = $item['elapsed'];} else {$el = $item['closed'];}
$days = floor($el / 86400);
$hours = floor(($el - ($days * 86400))/ 3600);
$mins = floor(($el - ($days * 86400) - ($hours * 3600)) / 60);
if ($_SESSION['level']==3)
{
echo "<tr onclick=\"document.location='viewcall.php?id=" . $item['id'] . "&pfx=" . $item['id_prefix']; if($HTTP_SERVER_VARS['QUERY_STRING']){ echo "&";} echo $HTTP_SERVER_VARS['QUERY_STRING'] . [b][color=#FF0000]if($item['priority']==High) . " style=\"color:DD5555;[/color]\[/b]"';\"><td class=smooth" . $stripe . "><img src='/images/icons/pri" . $item['priority'] . ".gif'/></td><td align=center class=smooth" . $stripe .">" . $item['id_prefix'] . $item['id'] . "</td><td class=smooth" . $stripe .">" . substr($item['description'],0,50) . "</td><td class=smooth" . $stripe .">" . $item['logged_fmt'] . "</td><td class=smooth" . $stripe .">" . $days . "d " . $hours . "h " . $mins . "m </td><td class=smooth>" . $item['response'] . "</td><td class=smooth" . $stripe ." style=\"color:DD5555;\">" . $item['engineer'] . "</td><td class=smooth" . $stripe .">" . $item['contact'] . "</td><td class=smooth" . $stripe ." style=\"color:5555AA;\">" . $item['status'] . "</td></tr>";
} else {
echo "<tr onclick=\"document.location='viewcall.php?id=" . $item['id'] . "&pfx=" . $item['id_prefix']; if($HTTP_SERVER_VARS['QUERY_STRING']){ echo "&";} echo $HTTP_SERVER_VARS['QUERY_STRING'] . [b][color=#FF0000]if($item['priority']==High) . " style=\"color:DD5555;\"[/color][/b]';\"><td class=smooth" . $stripe . "><img src='/images/icons/pri" . $item['priority'] . ".gif'/></td><td align=center class=smooth" . $stripe .">" . $item['id_prefix'] . $item['id'] . "</td><td class=smooth" . $stripe .">" . substr($item['description'],0,50) . "</td><td class=smooth" . $stripe .">" . $item['logged_fmt'] . "</td><td class=smooth" . $stripe .">" . $days . "d " . $hours . "h " . $mins . "m </td><td class=smooth>" . $item['response'] . "</td><td class=smooth" . $stripe ." style=\"color:DD5555;\">" . $item['engineer'] . "</td><td class=smooth" . $stripe .">" . $item['company'] . "</td><td class=smooth" . $stripe ." style=\"color:5555AA;\">" . $item['status'] . "</td></tr>";
}
if ($stripe=='1'){$stripe='';} else {$stripe='1';}
}
?>
The bit in red is the bit i added to try and get the log to go red if 'priority' is high but i still get a blank page when i try it...
Any ideas on where i am going wrong?