<? if($_SESSION['page'] == '8' and $_SESSION['section'] == '1') { ?>
<link href="../admin.css" rel="stylesheet" type="text/css" />

<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<table width="95%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
      <tr>
        <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td class="Main_Text"><a class="Main_Text">Staff Productivity Report</a></td>
            <td width="10%" class="Main_Text"><div align="right"><img src="image/more_info.gif" width="32" height="32" border="0" /></a></div></td>
          </tr>
          <tr>
            <td colspan="2">
            <? if ($_GET['stat'] == '' ) { ?>
    	<script type="text/javascript">
			window.addEvent('domready', function() { 
				new vlaDatePicker('from_date', { style: 'apple_widget',separator: '-', format: 'y/m/d'});
				new vlaDatePicker('to_date', { style: 'apple_widget',separator: '-', format: 'y/m/d'});
			});	
		</script>
              <form action="index.php?stat=create" method="post" name="form1" id="form1">
                
                <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="image/subheader_icon.gif" width="12" height="12" /><strong class="text2">&nbsp;&nbsp;&nbsp;Enter the Date</strong></p>
                <table width="70%" border="0" align="center">
                  <tr>
                    <td width="30%" class="Main_Text1_case">From</td>
                    <td class="Main_SText_case1"><div align="center"><span id="sprytextfield1">
                      <input type="text" name="from_date" id="from_date" />
                    <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span></span></div></td>
                  </tr>
                  <tr>
                    <td class="Main_Text1_case">To</td>
                    <td class="Main_SText_case1"><div align="center"><span id="sprytextfield2">
                      <input type="text" name="to_date" id="to_date" />
                      <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">*</span></span></div></td>
                  </tr>
                  <tr>
                    <td class="Main_Text1_case"><span class="Main_Text1">Staff id</span></td>
                    <td class="Main_SText_case1"><div align="center">
                      <select name="staff_id" id="staff_id">
                        <option value="0">All Staff</option>
                        <?
						  $result1 = mysql_query("SELECT * FROM ".$dcm_table_start."userlist where active=1"); 
							while($row = mysql_fetch_array($result1)){ 
							?>
                        			<option value="<? echo $row['user_id'];?>"><? echo $row['fname'];?> <? echo $row['lname'];?></option>
                            <? } ?>

						
                      </select>
                    </div></td>
                  </tr>
                  <tr>
                    <td><input name="Submit" type="submit" class="Button1" id="Submit" value="   Create   " /></td>
                    <td>&nbsp;</td>
                  </tr>
                </table>
                <br />
              </form>
            <? }if ($_GET['stat'] == 'create' ) { ?>
            <br />

                <table width="90%" border="0" align="center">
                  <tr>
                    <td class="Main_Text1"><div align="center">Staff id</div></td>
                    <td class="Main_Text1"><div align="center">Number of call</div></td>
                    <td class="Main_Text1"><div align="center">visite</div></td>
                    <td class="Main_Text1"><div align="center">promes to pay</div></td>
                    <td class="Main_Text1"><div align="center">Meeting</div></td>
                  </tr>
                  <?
				  		if ($_POST['staff_id'] == "0") 
							{
								$result1 = mysql_query("SELECT * FROM ".$dcm_table_start."userlist where active = 1"); 
							}else{
								$result1 = mysql_query("SELECT * FROM ".$dcm_table_start."userlist where active = 1 and user_id = ".$_POST['staff_id']); 
							}
						
						
						
						 while($row = mysql_fetch_array($result1)){ 
						 
						 
						 

				  ?>
                  <tr>
                    <td class="Main_SText_case1"><div align="center"><? echo $row['user_id']?></div></td>
                    <td class="Main_SText_case1"><div align="center"><? 
					$query = mysql_query("select count(*) count from dcm_call where uid = ".$row['user_id']." and call_date between '".$_POST['from_date']."' and '".$_POST['to_date']."'");
						echo mysql_result($query,0,"count");
					
					?></div></td>
                    <td class="Main_SText_case1"><div align="center"><? 
					$query = mysql_query("select count(*) count from dcm_call where uid = ".$row['user_id']." and reminder_type = 3 and reminder_date between '".$_POST['from_date']."' and '".$_POST['to_date']."'");
						echo mysql_result($query,0,"count");
					
					?></div></td>
                    <td class="Main_SText_case1"><div align="center"><? 
					$query = mysql_query("select count(*) count from dcm_call where uid = ".$row['user_id']." and reminder_type = 4 and reminder_date between '".$_POST['from_date']."' and '".$_POST['to_date']."'");
						echo mysql_result($query,0,"count");
					
					?></div></td>
                    <td class="Main_SText_case1"><div align="center"><? 
					$query = mysql_query("select count(*) count from dcm_call where uid = ".$row['user_id']." and reminder_type =2  and reminder_date between '".$_POST['from_date']."' and '".$_POST['to_date']."'");
						echo mysql_result($query,0,"count");
					
					?></div></td>
                  </tr>
                  <?
				  		}
				  ?>
                </table>
                <br />

            <? } ?>            </td>
          </tr>
        </table></td>
      </tr>
</table>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"yyyy-mm-dd"});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "date", {format:"yyyy-mm-dd"});
//-->
</script>

<? } ?>
