<?php require_once('Connections/t77_connect.php'); ?>
<?php
mysql_select_db($database_t77_connect, $t77_connect);
$query_Typen = "SELECT * FROM t77_bill_types";
$Typen = mysql_query($query_Typen, $t77_connect) or die(mysql_error());
$row_Typen = mysql_fetch_assoc($Typen);
$totalRows_Typen = mysql_num_rows($Typen);
if(!isset($_GET['typeID'])) {
$type = "3";
} else {
$type = $_GET['typeID'];
}
$datax = array("","Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","October","November","December");
mysql_select_db($database_t77_connect, $t77_connect);
$query_settings = "SELECT * FROM t77_bill_settings";
$settings = mysql_query($query_settings, $t77_connect) or die(mysql_error());
$row_settings = mysql_fetch_assoc($settings);
$totalRows_settings = mysql_num_rows($settings);
mysql_select_db($database_t77_connect, $t77_connect);
$query_getyear = "SELECT DISTINCT YEAR(t77_bill_bills.bill_date) as jaar FROM t77_bill_bills";
$getyear = mysql_query($query_getyear, $t77_connect) or die(mysql_error());
$row_getyear = mysql_fetch_assoc($getyear);
$totalRows_getyear = mysql_num_rows($getyear);
$ubertotal = 0;
?>
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" class="lineleft">
<tr>
<td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="31" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"><img src="images/tabletopstart.gif" width="20" height="31" /></td>
<td><table width="100%" height="30" border="0" cellpadding="5" cellspacing="0">
<tr>
<td><p><strong>Report</strong></p>
</td>
<td><table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="20">
<tr>
<td><form name="type" id="type" method="get" action="<? echo $_SERVER['PHP_SELF']; ?>">
<select name="typeID" onChange="javascript:document.type.submit(this.form)">
<?php
do {
?>
<option value="<?php echo $row_Typen['bill_type']?>"<?php if (!(strcmp($row_Typen['bill_type'], $type))) {echo "SELECTED";} ?>><?php echo $row_Typen['type_description']?></option>
<?php
} while ($row_Typen = mysql_fetch_assoc($Typen));
$rows = mysql_num_rows($Typen);
if($rows > 0) {
mysql_data_seek($Typen, 0);
$row_Typen = mysql_fetch_assoc($Typen);
}
?>
</select>
<select name="year" onChange="javascript:document.type.submit(this.form)">
<?php
do {
?>
<option value="<?php echo $row_getyear['jaar']?>"<?php if (!(strcmp($row_getyear['jaar'], "$year"))) {echo "SELECTED";} ?>><?php echo $row_getyear['jaar']?></option>
<?php
} while ($row_getyear = mysql_fetch_assoc($getyear));
$rows = mysql_num_rows($getyear);
if($rows > 0) {
mysql_data_seek($getyear, 0);
$row_getyear = mysql_fetch_assoc($getyear);
}
?>
</select>
</form>
<p> </p>
<p><img src="report_month.php?typeID=<? echo $type; ?>&time=<? echo microtime(); ?>" alt="Loading the graph..." width="650" height="400"/></p>
<p> </p>
<?
mysql_select_db($database_t77_connect, $t77_connect);
$query_Companies = "SELECT * FROM t77_bill_companies";
$Companies = mysql_query($query_Companies, $t77_connect) or die(mysql_error());
$row_Companies = mysql_fetch_assoc($Companies);
$totalRows_Companies = mysql_num_rows($Companies);
$comi=0;
do { ?>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="tableBorder">
<tr>
<td class="tableTop"><h1><?php echo $row_Companies['company_name']; ?></h1></td>
<td align="right" class="tableTop"><h1>Turnover per month (in <?php echo $row_settings['valuta_sign']; ?>)</h1></td>
</tr>
<?
$i = 0;
$totaal = 0;
do {
$datevar = $i;
$comVar = $row_Companies['company_id'];
$colname3_maanden = "3";
if (isset($type)) {
$colname3_maanden = (get_magic_quotes_gpc()) ? $type : addslashes($type);
}
$colname2_maanden = "1";
if (isset($comVar)) {
$colname2_maanden = (get_magic_quotes_gpc()) ? $comVar : addslashes($comVar);
}
$colname_maanden = "1";
if (isset($datevar)) {
$colname_maanden = (get_magic_quotes_gpc()) ? $datevar : addslashes($datevar);
}
mysql_select_db($database_t77_connect, $t77_connect);
$query_maanden = sprintf("SELECT * FROM t77_bill_bills, t77_bill_items, t77_bill_companies, t77_bill_contacts WHERE t77_bill_contacts.contact_id = t77_bill_bills.bill_contact AND t77_bill_contacts.contact_company_name = t77_bill_companies.company_id AND t77_bill_bills.bill_id = t77_bill_items.bill_id AND MONTH( t77_bill_bills.bill_date) = %s AND t77_bill_contacts.contact_company_name = %s AND t77_bill_bills.bill_type = %s", $colname_maanden,$colname2_maanden,$colname3_maanden);
$maanden = mysql_query($query_maanden, $t77_connect) or die(mysql_error());
$row_maanden = mysql_fetch_assoc($maanden);
$totalRows_maanden = mysql_num_rows($maanden);
$monthprice[$i] = 0;
do {
$monthprice[$i] = $monthprice[$i] + $row_maanden['item_price'];
} while ($row_maanden = mysql_fetch_assoc($maanden));
if ($i > 0) {
$totaal = $totaal + $monthprice[$i];
if(is_int($i/2)) {
$bgcolor = "#eeeeee";
} else {
$bgcolor = "#ffffff";
}
if($monthprice[$i] < 0) {
$fcolor = "#ff0000";
} else {
$fcolor = "#000033";
}
?>
<tr bgcolor="<? echo $bgcolor; ?>">
<td><h1><? echo $datax[$i]; ?></h1></td>
<td align="right"><h1><font color="<? echo $fcolor; ?>"><? echo number_format($monthprice[$i],2,',','.'); ?></font></h1></td>
</tr>
<?
}
$i++;
} while ($i <= 12);
if($totaal < 0) {
$fcolor = "#ff0000";
} else {
$fcolor = "#000033";
}
if(is_int($i/2)) {
$bgcolor = "#eeeeee";
} else {
$bgcolor = "#ffffff";
}
?>
<tr bgcolor="<? echo $bgcolor; ?>">
<td><h1>Total:</h1></td>
<td align="right"><h1><font color="<? echo $fcolor; ?>"><? echo number_format($totaal,2,',','.');
$ubertotal = $ubertotal + $totaal; ?></font></h1></td>
</tr>
<?
unset($monthprice);
$comi++; ?>
</table>
<p> </p>
<? } while ($row_Companies = mysql_fetch_assoc($Companies)); ?>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="tableBorder">
<tr>
<td><h1>Total:</h1></td>
<td align="right"><h1><font color="<?
if($ubertotal < 0) {
$fcolor = "#ff0000";
} else {
$fcolor = "#000033";
}
echo $fcolor; ?>"><? echo number_format($ubertotal,2,',','.'); ?></font></h1></td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($maanden);
mysql_free_result($Companies);
mysql_free_result($getyear);
mysql_free_result($settings);
mysql_free_result($Typen);
?>