Forum Moderators: coopster
<?phperror_reporting(E_ALL ^ E_NOTICE);
include_once("checklogin.php");
include_once("db.php");
include_once("commonFunctions.php");
if (isset($_POST['query_creditcontroller'])) {
//update the CreditControllers table
/*
$resultMonths = mssql_query("UPDATE CreditControllers
SET CreditConName = '".substr($_POST['query_creditcontroller'],5,25)."'
WHERE CostCentre = '".substr($_POST['query_creditcontroller'],0,4)."'
AND MonthData = 0
") or die(mssql_get_last_message());
*/
echo substr($_POST['query_creditcontroller'],5,25)."<br />";
echo substr($_POST['query_creditcontroller'],0,4);
print_r($_POST);
}
$result = mssql_query("EXEC web_GetCreditControllers") or die(mssql_get_last_message());
$selected = mssql_select_db("KPI_DEV", $dbhandle)
or die("Couldn't open database $myDB");
$resultMonths = mssql_query("EXEC kpi_GetMonthData") or die(mssql_get_last_message());
?>
<link rel="stylesheet" type="text/css" href="styles1.css" />
<style>
input.dropdown {width: 300px;}
input.go {width: 50px;}
</style>
<table style='font-weight:bold; width:100%;border-width: 2px 2px 2px 2px;border-color: black black black black;' cellpadding='0' cellspacing='0' border='1'>
<tr>
<td style='vertical-align:middle;text-align:center;border-width: 0px 0px 0px 0px;width:1%;'><a class ='2' href='index.php'><img src='images/HomeIcon.png' alt='Return to main menu'></a></td>
<td style='padding: 0em 0em 0em 0em; background-color:white;border-width: 0px 0px 0px 0px;' colspan='10'>
<img src='images/logo.gif'>
<img src='images/picture.jpg'></td>
</tr>
</table>
<br />
<center>
Note: The KPI data must be imported for the new month before you can allocate the appropriate cost centre for a controller.
<form action='allocation.php' method='post'>
<select id='month' name='month' style='width:15%;' onChange='this.form.submit();'>
<?
echo "<option>--- Month ---</option>";
while ($rowMonths=mssql_fetch_assoc($resultMonths))
{
echo "<option value='".$rowMonths['MonthDataInt'].",".$rowMonths['MonthName']." ".$rowMonths['Year']."'>".$rowMonths['MonthName']." ".$rowMonths['Year']."</option>";
}
?>
</select>
</form>
<hr style='width:100%;'>
<br />
Note: the allocation in CMS for companies or cost centre splits will always override this data. For example, ZDTI, ASDA, Cumbria County Council, etc.
<br />
<?
if (isset($_POST['month'])) {
$month = 0;
if (substr($_POST['month'],0,1) == '-') {$month = substr($_POST['month'],0,2);} else {$month = substr($_POST['month'],0,1);}
$res_CC = mssql_query("EXEC bonus_ListControllerAllocation $month") or die(mssql_get_last_message());
echo "<br /><table cellpadding='2' width='400'>";
echo "<tr class='orange'><td colspan='3' align='center'>Allocation</td></tr>";
echo "<tr class='maintable'><th>Cost Centre</th><th>Controller</th><th>Change to:</th>";
$toggle = 0;
while($row = mssql_fetch_array($res_CC))
{
$costcentre = $row['CostCentre'];
if ($toggle == 0) {echo "<tr class='lightblue'>";} else {echo "<tr class='grey'>";}
echo "<td>".$costcentre."</td><td>".$row['CreditConName']."</td><td>";
?>
<form action='allocation.php' method='post'>
<select id='query_creditcontroller' name = 'query_creditcontroller' width='100%' onChange='this.form.submit();'>
<option id='cc' name = 'cc' value=''>Choose controller</option>
<?
mssql_data_seek($result, 0);
while($row2 = mssql_fetch_array($result))
{
echo "<option id='cc' name = 'cc' value='".$costcentre.",".$row2['CreditConName']."'>".$row2['CreditConName']."</option>";
}
?>
</form>
</select>
<?
echo "</tr>";
if ($toggle == 0) {$toggle++;} else {$toggle--;}
}
echo "</table>";
}
?>
</center>