<?php
include("../includes/site_config.php");
include('../session_handler.inc');
include_once __INCLUDE_CLASS_PATH."/class.Banner.php";
error_reporting(0);

//if ($Sess_UserType != "A") exit;
function myformat($date)
{
	$timestamp=strtotime($date);
	$new_format=date("jS F, Y",$timestamp);
	
	return $new_format;
}

if (isset($_REQUEST['lstYear'])) 
    $lstYear = $_REQUEST['lstYear'];
else $lstYear = date('Y');

if (isset($_REQUEST['WMonth'])) 
    $WMonth = $_REQUEST['WMonth'];
else $WMonth = date('m');

$data = Banner::report($lstYear, $WMonth);

$area = 'member';

?><?php include("include/header.php"); ?>
<div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;Banner Reports</div></div>
<div class="clear"></div>
<div class="admin-page">
  <table width="700" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>">
    <tr>
      <td><table width="680" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>">
        <form method='post' action='<?php echo $CONST_LINK_ROOT ?>/admin/report_banners.php?<?php print("?PHPSESSID=".session_id());//print("$sess_id"); ?>' name='FrmReports'>
		<tr><td colspan="6">
          <table cellpadding="2" cellspacing="2" border="0">
		  <tr>
            <td align='left' valign='top' class="admin-head2"> <b><?=REPORT_BANNERS_MONTH?> </b> </td>
            <td align='left' valign='top'>
              
              <select size="1" name="WMonth">
                <option value="-Choose-"  <?php if ($WMonth == "") { print("selected");} ?>>
                <?=REPORT_BANNERS_CHOOSE?>
                </option>
                <option value="01" <?php if ($WMonth == "01") { print("selected");} ?>>
                <?=MONTH_JAN?>
                </option>
                <option value="02" <?php if ($WMonth == "02") { print("selected");} ?>>
                <?=MONTH_FEB?>
                </option>
                <option value="03" <?php if ($WMonth == "03") { print("selected");} ?>>
                <?=MONTH_MAR?>
                </option>
                <option value="04" <?php if ($WMonth == "04") { print("selected");} ?>>
                <?=MONTH_APR?>
                </option>
                <option value="05" <?php if ($WMonth == "05") { print("selected");} ?>>
                <?=MONTH_MAY?>
                </option>
                <option value="06" <?php if ($WMonth == "06") { print("selected");} ?>>
                <?=MONTH_JUN?>
                </option>
                <option value="07" <?php if ($WMonth == "07") { print("selected");} ?>>
                <?=MONTH_JUL?>
                </option>
                <option value="08" <?php if ($WMonth == "08") { print("selected");} ?>>
                <?=MONTH_AUG?>
                </option>
                <option value="09" <?php if ($WMonth == "09") { print("selected");} ?>>
                <?=MONTH_SEP?>
                </option>
                <option value="10" <?php if ($WMonth == "10") { print("selected");} ?>>
                <?=MONTH_OCT?>
                </option>
                <option value="11" <?php if ($WMonth == "11") { print("selected");} ?>>
                <?=MONTH_NOV?>
                </option>
                <option value="12" <?php if ($WMonth == "12") { print("selected");} ?>>
                <?=MONTH_DEC?>
                </option>
              </select>
              </td>
			  <td>&nbsp;</td>
            <td valign='top' class="admin-head2"> <b>
              <?=REPORT_BANNERS_YEAR?>
              </b> </td>
            <td align='left' valign='top' class="normal"> <b>
              <select size="1" name="lstYear">
                <option value="-Choose-"><?=REPORT_BANNERS_CHOOSE?></option>
                <?php 
                    for ($i=date("Y"); $i >= 2004; $i--) {
                        if ($i==$lstYear) $selected="selected"; else $selected="";
                        print("<option value='$i' $selected>$i</option>");
                    }
                ?>
              </select>
              </b> </td>
			  <td>&nbsp;</td>
            <td align='left' valign='top' class="normal"> <input name="btnSubmit" type="submit" class="normal" value="<?=REPORT_BANNERS_GET?>">
            </td>
          </tr>
		  </table></td></tr>
          <tr >
            <td colspan="6" align='left' valign='top' class="normal">&nbsp;</td>
          </tr>
          <?php
 if (isset($WMonth) and $WMonth != '-Choose-' and $lstYear != '-Choose-') {
    print("<tr class='tdhead'>
                              <td class='admin-head2'><b>".REPORT_BANNERS_TDATE.":</b></td>
                             <td class='admin-head2'><b>Name:</b></td>
							
                             <td class='admin-head2'><b>".REPORT_BANNERS_SIZE.":</b></td>
							 
                             <td class='admin-head2'><b>Impressions:</b></td>
							
                             <td class='admin-head2'><b>Clicks:</b></td>
                             <td class='admin-head2'><b>CTR:</b></td>
                        </tr>
                      ");

    foreach ($data as $sql_array) {
$ctr=round($sql_array->hits*100/$sql_array->impressions, 0);
$date = myformat($sql_array->statdatePrint);
        print("<tr class='normal'>
                     <td>$date</td>
                  <td >$sql_array->bannerName</td>
                  <td >$sql_array->bannerSize</td>
				 
                  <td >$sql_array->impressions</td>
				
                  <td >$sql_array->hits</td>
                     <td>$ctr%</td>
                </tr> ");
        $sum_hits += $sql_array->hits;
    }
  }
?>
            <tr class='tdfoot'>
             <td   colspan='6'>&nbsp; </td>
            </tr>
           <!-- <tr>
              <td  class='tdhead' colspan='6'><b><?=REPORT_BANNERS_SUMMARY?></b></td>
            </tr>-->

            <tr class='normal'>
              <td colspan='6'>&nbsp;</td>
              
            </tr>
        </form>
      </table></td>
    </tr>
</table></div><div class="admin-page-bottom"></div></div>
<?php include("include/footer.php"); ?>