Viewing Source Code - This creates an inventory cost comparison report. - Back to Resume

Output:


Source Code:
<head>
<style type="text/css">
<!--
body {    margin-left: 0px;    margin-top: 0px;    margin-right: 0px;    margin-bottom: 0px; }
.td1 {    font-family:Verdana, Arial, Helvetica, sans-serif;    font-size:10px; }
.td2 {    font-family:Verdana, Arial, Helvetica, sans-serif;    font-size:10px; background-color:#dfdfdf; }
.table1 { border: 1px solid #CCCCCC; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px}
.seperator {
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:1px;
    border-bottom-width: 1px;
    border-top-style: none;
    border-right-style: none;
    border-bottom-style: solid;
    border-left-style: none;
    border-bottom-color: #CCCCCC;
    height:2px;
}
-->
</style>
<title>Electrical Pricing</title>
</head>
<body>
<?php 
function clear_counters() {
    global     
$icnt$ihold$iretail$iqty$itot$iuom;
    
$icnt=0;
    
$ihold='';
    
$iretail=0;
    
$iqty=0;
    
$itot=0;
    
$iuom='';
}
function 
counters($amt,$retail,$um,$total,$tv,$l1,$l2) {
    global     
$icnt$ihold$iretail$iqty$itot$iuom$isum$tvsum$tvl1$tvl2;
    
$iqty=$iqty+$amt;
    
$iretail=$iretail+$retail;
    
$iuom=$um;
    
$itot=$itot+$total;
    
$isum=$isum+$total;
    
$tvsum=$tvsum+($amt*$tv);
    
$tvl1=$tvl1+($amt*$l1);
    
$tvl2=$tvl2+($amt*$l2);
}
function 
titles() {
    echo 
'<tr><td colspan=13 class=seperator>&nbsp;</td></tr>';
    echo 
'<tr><td align=center>Item</td>
        <td>Description</td>
        <td align=center>Qty</td>
        <td align=center>UM</td>
        <td align=center>Cost</td>
        <td align=right>Retail</td>
        <td align=right>Total</td>
        <td align=right>TV </td>
        <td align=right>TV Retail</td>
        <td align=right>L1</td>
        <td align=right>TV L1</td>
        <td align=right>L2</td>
        <td align=right>TV L2</td></tr>'
;
}
$hn='server2';
$db='database1';
$un='sa';
$pw='pwd';
$con=mssql_connect($hn,$un,$pw);
mssql_select_db($db,$con);
$sql='SELECT * FROM Detail1 
    INNER JOIN tvElectrical 
    ON Detail1.code=tvElectrical.code 
    ORDER BY Detail1.code,Detail1.invoice'
;
$sql_qry=mssql_query($sql);
$cnt=mssql_num_rows($sql_qry);
include(
'../i/h.htm');
echo 
'<br><table width="95%" border="0" cellspacing="0" cellpadding="1" align=center class=table1>';
titles();
clear_counters();
$firstrun=true;
$x=2;
$isum=0;
$tvsum=0;
$tvl1=0;
$tvl2=0;
$showt=0;
while (
$row=mssql_fetch_assoc($sql_qry)) {
    if (
$firstrun) {
        
$ihold=$row['code'];
        
$firstrun=false;
    }
    if (
$row['code']==$ihold) {
        
counters($row['amt'],$row['retail'],$row['um'],$row['total'],$row['Retail'],$row['L1'],$row['L2']);
    } else {
        echo 
$output;
        
$showt++;
        if (
$showt>=44) {
            
titles();
            
$showt=0;
        }
        
clear_counters();
        
counters($row['amt'],$row['retail'],$row['um'],$row['total'],$row['Retail'],$row['L1'],$row['L2']);
        if (
$x==1) { $x=2; } else { $x=1; }
    }
    
$ihold=$row['code'];
    
$output='<tr><td class=td'.$x.' align=center>'.$row['code'].'</td>
        <td class=td'
.$x.'>'.$row['description'].'</td>
        <td class=td'
.$x.' align=center>'.$iqty.'</td>
        <td class=td'
.$x.' align=center>'.$row['um'].'</td>
        <td class=td'
.$x.' align=right>$'.number_format($row['Member'],2).'</td>
        <td class=td'
.$x.' align=right>$'.number_format($row['retail'],2).'</td>
        <td class=td'
.$x.' align=right>$'.number_format($itot,2).'</td>
        <td class=td'
.$x.' align=right>$'.number_format($row['Retail'],2).'</td>
        <td class=td'
.$x.' align=right>$'.number_format(($iqty*$row['Retail']),2).'</td>
        <td class=td'
.$x.' align=right>$'.number_format($row['L1'],2).'</td>
        <td class=td'
.$x.' align=right>$'.number_format(($iqty*$row['L1']),2).'</td>
        <td class=td'
.$x.' align=right>$'.number_format($row['L2'],2).'</td>
        <td class=td'
.$x.' align=right>$'.number_format(($iqty*$row['L2']),2).'</td></tr>';

}
echo 
'<tr><td></td><td></td><td></td><td></td><td></td>';
echo 
'<td align=right colspan=2>$'.number_format($isum,2).'</td>';
echo 
'<td align=right colspan=2>$'.number_format($tvsum,2).'</td>';
echo 
'<td align=right colspan=2>$'.number_format($tvl1,2).'</td>';
echo 
'<td align=right colspan=2>$'.number_format($tvl2,2).'</td></tr>';
echo 
'</table>';
?>
<br /><br />
</body>
</html>