<?php include("../header_test.php") ?>
<?php include("../menu_test.php") ?>
		<div id="content_main">
			<div id="sectionhead">
                OCEAN PICTURE OF THE DAY (OPOD)
			</div>
<?php include("../action/menu.php") ?>
		    <div id="right_col">
              <div id="content">
			  <table bgcolor="white" border="0" cellpadding="10" cellspacing="0" width="780">
              <tr>
              <td>
              <table width="780" bgcolor="white">
                <tr>
                <td align="center" valign="middle">
                    <center><h1>OPOD Monitoring<br />
                    <?php print(Date("l, F d, Y")); ?></h1></center>
                </td>
            </tr>
          </table>
	  	  <?php
			//Connect To Database
			$hostname='mysql27.secureserver.net';
			$username='oceanweb';
			$password='password';
			$dbname='oceanweb';

            $con = mysql_connect($hostname,$username,$password); 
    
            //Connect
            if (!$con) 
            { 
                die('Could not connect: ' . mysql_error()); 
            } 
            mysql_select_db($dbname, $con);
            
            $status=$_REQUEST['status']; 
            $submitdate=$_REQUEST['dsubmitDate'];
            
            $id="";
            
            $result = mysql_query("SELECT submits.id FROM user, pic, submits WHERE user.id = submits.user_id AND pic.id = submits.picture_id AND submits.status = 0 ORDER BY date LIMIT 1");
        
            if($result) {
                if($row = mysql_fetch_array($result)) {
                    $id = $row['id'];
                    $sql2 = mysql_query("UPDATE submits SET status='".$status."', picture_id='".$id."', user_id='".$id."', use_date='".$submitdate."' WHERE id=".$id);
					echo '     <span class="instruction" style="font-size: 14px; font-weight:bold; color: #000000">Update Processed: Submission ID: '.$id.'   DATE: '.$submitdate.'   STATUS: '.$status.'</span>';
                }
            } else {
                //echo 'No results from query';
            }	 
            
            echo '<table width="80%" border="0" bordercolor="#ffffff" bgcolor="#ffffff" id="Report" align="center">';
            echo '<tr>';
            echo '<td></td>';
            echo '</tr></table><p> </p>';
            mysql_close($con); 
        ?>  
        
        <table width="80%" border="0" bordercolor="#ffffff" bgcolor="#ffffff" id="Report" align="center">
            <tr>
               <td bgcolor="#FFFFFF"><span class="instruction" style="font-size: 14px; font-weight:bold; color: #000000">Monitor Progress Report:</span></td>
            </tr>
            <tr>
               <td bgcolor="#CCCCCC"><div align="left"><span style="color: #000000">
                    <?php
                        // LINKUP ////
                        //Connect To Database
                        $hostname='mysql27.secureserver.net';
                        $username='oceanweb';
                        $password='password';
                        $dbname='oceanweb';
                        $incoming=$_REQUEST['incoming'];
                        
                        //connect to database
                        mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database!.');
                        //select - use this database 
                        mysql_select_db($dbname);
                        
                        //$query13 = "SELECT COUNT(*) as Num_unreview FROM 'submits' WHERE status = '0'";
                        
                        $result = mysql_query("SELECT * FROM submits");
                        $num_rows = mysql_num_rows($result);
                        
                        echo'<span class="instruction" style="font-size: 12px";>Total Opod Records:</span>';
                        echo "$num_rows";
                        echo  '<br />';						
                        echo  '</span>';	
                        echo  '</div>';	
                        echo  '</td>';	
                        echo  '</tr>';	
                        echo  '<tr>';	
                        echo  '<td>';		
                                                    
                        $result = mysql_query("SELECT * FROM submits WHERE status = 1 OR status = 2");
                        $num_rows = mysql_num_rows($result);
                        
                        echo'<span class="instruction" style="font-size: 12px";>Records Processed:</span>';
                        echo'<span class="Awaiting">'."$num_rows".'</span>';
                        echo  '<br />';                        
                        echo  '</td>';	
                        echo  '</tr>';	
                        echo  '<tr>';	
                        echo  '<td>';	
                                                         
                        $result = mysql_query("SELECT * FROM submits WHERE status = 0");
                        $num_rows = mysql_num_rows($result);
                        
                        echo'<span class="instruction" style="font-size: 12px";>Records Not Processed:</span>';
                        echo'<span class="Awaiting">'."$num_rows".'</span>';
                        echo  '<br />';         
                        echo  '</td>';	
                        echo  '</tr>';	
                        echo  '<tr>';	
                        echo  '<td>';				
    
                        $result = mysql_query("SELECT * FROM submits WHERE status = 1");
                        $num_rows = mysql_num_rows($result);
                        
                        echo'<span class="instruction" style="font-size: 12px";>Records Approved:</span>';
                        echo '<span class="Success">'."$num_rows".'</span>';
                        echo  '<br />';
                        echo  '</td>';	
                        echo  '</tr>';	
                        echo  '<tr>';	
                        echo  '<td>';	
    
                        $result = mysql_query("SELECT * FROM submits WHERE status = 2");
                        $num_rows = mysql_num_rows($result);
                        
                        echo'<span class="instruction" style="font-size: 12px";>Records Declined:</span>';
                        echo '<span class="Exists">'."$num_rows".'</span>';
                        echo  '<br />';
                        echo  '</td>';	
                        echo  '</tr>';	
                        echo  '</table>';	
                    ?>
                    <p> </p>
                    <p>               <a href="http://theoceanproject.org/opod/MonitorLogin.php">Process Next Submission</a></p>
          </td></tr></table>
          </div></div>
        <div id="footer" style="left:464px;top:712px">
        <table>
            <tr>
                <td style="background:transparent">
<?php include("../footer_div.php") ?>
</div>
</body>
</html>