Location: PHPKode > projects > Helpdesk Over Web > how/calls/assignedcalls.php
<?php
// Assigned Calls Page

// Include Configuration File
require_once('../includes/config.inc');

// Set Page Title and Include HTML Header
$page_title = 'HOW - Assigned Calls';
include_once('../includes/header.html');
echo '<H1>Calls</H1>';

// Define Engineer using Session Login Name
$engineer = ($_SESSION['LoggedInUser']);

// Connect to Database
require_once ('../includes/mysql_connect.php');

// Define pagination variables.
if(!isset($_GET['page'])){ 
    $page = 1; 
} else { 
    $page = $_GET['page']; 
} 

// Define the number of results per page 
$max_results = 15; 

// Figure out the limit for the query based 
// on the current page number. 
$from = (($page * $max_results) - $max_results); 

// Query the database.
$query = "SELECT * FROM calls WHERE engineer='$engineer' AND CallStatus NOT LIKE 'Closed%' ORDER BY date desc, time desc, severity LIMIT $from, $max_results;";		
$result = mysql_query($query)
   or die("Invalid query: " . mysql_error());
$num_rows = mysql_num_rows($result);

// Figure out the total number of results in DB: 
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM calls WHERE engineer='$engineer' AND CallStatus NOT LIKE 'Closed%' ORDER BY date desc, time desc, severity;"),0); 

// Calculate total number of pages needed to display.
$total_pages = ceil($total_results / $max_results);

echo '<H3>Call Log - Assigned Open Calls</H3>';
if($num_rows == 0)
	{
	echo "<H4>Sorry - No Entries Found</H4>";
	echo ("<P><B><A HREF='javascript:history.back()'>Back to Previous Page</A></B></P>");
	}
else {
echo '<p>Click on a call identifier to view further details.</P>';
echo ("<TABLE WIDTH='700'><TR><TD><b>Call ID</b></TD><TD><b>Date</b></TD><TD><b>Time</b></TD><TD><b>User</b></TD><TD><b>Severity</b></TD><TD><b>Call Status</b></TD></TR>");
while($i = mysql_fetch_row($result)) { 
	echo ("<TR>");
	echo ("<TD><A HREF='editcall.php?callid=$i[0]'>$i[0]</A></TD>");
	echo ("<TD>$i[1]</TD>");
	echo ("<TD>$i[2]</TD>");
	echo ("<TD>$i[3]</TD>");
	echo ("<TD>$i[7]</TD>");	
	echo ("<TD>$i[9]</TD>");	
	}
echo ("</TABLE>");
// Build Previous Link 
echo "<P><b>Page</b>: ";if($page > 1){ 
    $prev = ($page - 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><</a>&nbsp;"; 
} 

for($i = 1; $i <= $total_pages; $i++){ 
    if(($page) == $i){ 
        echo "$i&nbsp;"; 
        } else { 
            echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a>&nbsp;"; 
    } 
} 

// Build Next Link 
if($page < $total_pages){ 
    $next = ($page + 1); 
    echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">></a>"; 
	echo "</P>";
}
}

echo ("<H5>[ <A HREF='calladmin.php'>Call Administration Menu</A> ]</H5>");
echo ("<H5>[ <A HREF='../index.php'>Main System Menu</A> ]</H5>");

// Include HTML footer.
include_once('../includes/footer.html');
?>
Return current item: Helpdesk Over Web