<?

$host ="it2008";
$user = "sa";
$pass = "mercury";
$objConnect = mssql_connect($host,$user,$pass);
$objDB = mssql_select_db("SMVDB_WEB");



$arr_month = array("Jan"=>"01","Feb"=>"02","Mar"=>"03","Apr"=>"04","May"=>"05","Jun"=>"06","Jul"=>"07","Aug"=>"08","Sep"=>"09","Oct"=>"10","Nov"=>"11","Dec"=>"12");
$arr_st = array("ST_1"=>"680","ST_2"=>"650","ST_3"=>"600","ST_4"=>"580","ST_5"=>"550");






				$sql="select * from V_Follow_plan_Pending_summary";
				$objQuery = mssql_query($sql) or die ("Error Query [".$sql."]");
				
				
				
			

?>
<!DOCTYPE HTML>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Summary Pending PD</title>
<link rel="stylesheet" href="pikaday/pikaday.css">






        <style type="text/css">
<!--
.style2 {font-size: 12px}
-->
        </style>
</head> 
    <body> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#999999">
      <tr>
        <td><table width="100%" border="0" cellspacing="1" cellpadding="1" bgcolor="#CCCCCC">
          <tr bgcolor="#FFFFFF" align="center" style="font-size:12px">
            <td  width="80">Program No</td>
            <td >Pending_qty</td>
            <td>FG_bal</td>
            <td>Pac</td>
            <td>Plan</td>
            <td>Target</td>
            <td>Wax</td>
            <td>Cas</td>
            <td>Fil</td>
            <td>MP</td>
            <td>Sol</td>
            <td>QC_Sol</td>
            <td>Res</td>
            <td>Mec</td>
			<td>ReSett</td>
            <td>Sett</td>
            <td>Hp</td>
            <td>QCHP</td>
			<td>QCHP R</td>
            <td>Pla</td>
            <td>QC_Pla</td>
            <td>Fp</td>
            <td>Glue</td>
			<td>TTone</td>
            <td>Ena</td>
            <td>QCE</td>
			<td>QCE R</td>
			<td>Total</td>
            <td>w_master</td>
            <td>wt_stone</td>
            <td>wt_component</td>
            <td>wt_st_cp</td>
           
          </tr>
		  <? 
		  
		         $Pending_qty=0; 
				 $Plan=0;  
				 $PD=0;  
				 $Wax=0;  
				 $Cas=0;  
				 $Fil=0;  
				 $MP=0;  
				 $Sol=0;  
				 $QC_Sol=0;  
				 $Res=0;  
				 $Mec=0;  
				 $Sett=0;  
				 $ReSett=0;  
				 $Hp=0; 
                 $QCHP=0; 
				 $Pla=0;  
				 $QC_Pla=0; 
				 $Fp=0;  
				 $Glue=0; 
				 $Ena=0;  
				 $TTone=0; 
				 $QCE=0;  
				 $Pac=0; 
				 $FG_bal=0;  
				 $wt_stone=0;  
				 $wt_component=0; 
				 $wt_st_cp=0; 
				 $w_master=0;    
				 $repair_qcf=0;  
				 $repair_qce=0;  
				 $Total=0;
		  
		  while($objResult = mssql_fetch_array($objQuery))
				{
				
				 $datex = $objResult['date_current']+1;
				 $datex1 = $objResult['date_current']+3;
				
				if( $objResult['program_no_order1'] < $objResult['date_current'])
				{ 
				
				    $color="style='color:#0066FF'";/*RGB(64, 151, 239)*/
					
					
				}elseif( $objResult['program_no_order1'] == $objResult['date_current'] or  $objResult['program_no_order1'] == $datex )
				{
				
				    $color="style='color:#FF0000'";/*RGB(244, 76, 87)*/
					
					
				}elseif( $objResult['program_no_order1'] > $datex and  $objResult['program_no_order1'] <=$datex1)
				{
				
				   $color="style='color:#FF9933'";/* RGB(255, 106, 0)*/
					
			    }elseif( $objResult['program_no_order1'] > $datex1)
				{
				
				     $color="style='color:#00CC66'";/*RGB(0, 153, 76)*/
					 
			     }
				 else
				 {
				     $color="style='color:#000000'";/*RGB(0,0,0)*/
					 
					 
				 }
				 
				 $Pending_qty=$Pending_qty+$objResult['Pending_qty']; 
				 $Plan=$Pending_qty+$objResult['Plan'];  
				 $PD=$PD+$objResult['PD'];  
				 $Wax=$Wax+$objResult['Wax'];  
				 $Cas=$Cas+$objResult['Cas'];  
				 $Fil=$Fil+$objResult['Fil'];  
				 $MP=$MP+$objResult['MP'];  
				 $Sol=$Sol+$objResult['Sol'];  
				 $QC_Sol=$QC_Sol+$objResult['QC_Sol'];  
				 $Res=$Res+$objResult['Res'];  
				 $Mec=$Mec+$objResult['Mec'];  
				 $Sett=$Sett+$objResult['Sett'];  
				 $ReSett=$ReSett+$objResult['ReSett'];  
				 $Hp=$Hp+$objResult['Hp'];  
                 $QCHP=$QCHP+$objResult['QCHP'];  
				 $Pla=$Pla+$objResult['Pla'];  
				 $QC_Pla=$QC_Pla+$objResult['QC_Pla'];  
				 $Fp=$Fp+$objResult['Fp'];  
				 $Glue=$Glue+$objResult['Glue'];  
				 $Ena=$Ena+$objResult['Ena'];  
				 $TTone=$TTone+$objResult['TTone'];  
				 $QCE=$QCE+$objResult['QCE'];  
				 $Pac=$Pac+$objResult['Pac'];  
				 $FG_bal=$FG_bal+$objResult['FG_bal'];  
				 $wt_stone=$wt_stone+$objResult['wt_stone'];  
				 $wt_component=$wt_component+$objResult['wt_component'];  
				 $wt_st_cp=$wt_st_cp+$objResult['wt_st_cp'];  
				 $w_master=$w_master+$objResult['w_master'];    
				 $repair_qcf=$repair_qcf+$objResult['repair_qcf'];   
				 $repair_qce=$repair_qce+$objResult['repair_qce'];  
				 $Total=$Total+$objResult['Total'];  
				 
				
				
				/*
				
				program_no, program_no_order, date_current, program_no_order1, Pending_qty, [Plan], PD, Wax, Cas, Fil, MP, Sol, QC_Sol, Res, Mec, Sett, ReSett, Hp, 
                      QCHP, Pla, QC_Pla, Fp, Glue, Ena, TTone, QCE, Pac, FG_bal, wt_stone, wt_component, wt_st_cp, w_master, non_cast, repair_qcf, repair_qce, Total*/
					

		  ?>
          <tr bgcolor="#FFFFFF" align="center" style="font-size:10px" height="30">
            <td <?=$color;?>><?=$objResult['program_no'];?></td>
            <td <?=$color;?>><?=number_format($objResult['Pending_qty'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['FG_bal'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Pac'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Plan'], 0, '.', ',');?></td>
			<td <?=$color;?>><?=number_format($objResult['PD'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Wax'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Cas'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Fil'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['MP'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Sol'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['QC_Sol'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Res'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Mec'], 0, '.', ',');?></td>
			<td <?=$color;?>><?=number_format($objResult['ReSett'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Sett'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Hp'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['QCHP'], 0, '.', ',');?></td>
			<td <?=$color;?>><?=number_format($objResult['repair_qcf'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Pla'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['QC_Pla'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Fp'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Glue'], 0, '.', ',');?></td>
			<td <?=$color;?>><?=number_format($objResult['TTone'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Ena'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['QCE'], 0, '.', ',');?></td>
			<td <?=$color;?>><?=number_format($objResult['repair_qce'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['Total'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['w_master'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['wt_stone'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['wt_component'], 0, '.', ',');?></td>
            <td <?=$color;?>><?=number_format($objResult['wt_st_cp'], 0, '.', ',');?></td>
            
          </tr>
		  
		  <?
		  }
		  ?>
          <tr bgcolor="#FFFFFF" height="30" style="font-size:12px" align="center">
            <td>Total</td>
            <td><?=number_format($Pending_qty, 0, '.', ',');?></td>
            <td><?=number_format($FG_bal, 0, '.', ',');?></td>
            <td><?=number_format($Pac, 0, '.', ',');?></td>
            <td><?=number_format($Plan, 0, '.', ',');?></td>
            <td><?=number_format($PD, 0, '.', ',');?></td>
            <td><?=number_format($Wax, 0, '.', ',');?></td>
            <td><?=number_format($Cas, 0, '.', ',');?></td>
            <td><?=number_format($Fil, 0, '.', ',');?></td>
            <td><?=number_format($MP, 0, '.', ',');?></td>
            <td><?=number_format($Sol, 0, '.', ',');?></td>
            <td><?=number_format($QC_Sol, 0, '.', ',');?></td>
            <td><?=number_format($Res, 0, '.', ',');?></td>
            <td><?=number_format($Mec, 0, '.', ',');?></td>
            <td><?=number_format($ReSett, 0, '.', ',');?></td>
            <td><?=number_format($Sett, 0, '.', ',');?></td>
            <td><?=number_format($Hp, 0, '.', ',');?></td>
            <td><?=number_format($QCHP, 0, '.', ',');?></td>
            <td><?=number_format($repair_qcf, 0, '.', ',');?></td>
            <td><?=number_format($Pla, 0, '.', ',');?></td>
            <td><?=number_format($QC_Pla, 0, '.', ',');?></td>
            <td><?=number_format($Fp, 0, '.', ',');?></td>
            <td><?=number_format($Glue, 0, '.', ',');?></td>
            <td><?=number_format($TTone, 0, '.', ',');?></td>
            <td><?=number_format($Ena, 0, '.', ',');?></td>
            <td><?=number_format($QCE, 0, '.', ',');?></td>
            <td><?=number_format($repair_qce, 0, '.', ',');?></td>
            <td><?=number_format($Total, 0, '.', ',');?></td>
            <td><?=number_format($w_master, 0, '.', ',');?></td>
            <td><?=number_format($wt_stone, 0, '.', ',');?></td>
			<td><?=number_format($wt_component, 0, '.', ',');?></td>
            <td><?=number_format($wt_st_cp, 0, '.', ',');?></td>
         
          </tr>
        </table></td>
      </tr>
    </table>
	
    </body>
</html>

