<script type="text/javascript">
function deleteBanner(Type,ID) {
  if(confirm("<?php echo L_G_CONFIRMDELETEBANNER?>"))
   	document.location.href = "index.php?md=Affiliate_Merchants_Views_Banner"+Type+"&bid="+ID+"&action=delete"+"&<?php echo SID?>";
}
function addBanner(Type) {
	document.location.href = "index.php?md=Affiliate_Merchants_Views_Banner"+Type+"&campaign=<?php echo $campaignid?>&<?php echo SID?>";
}
function editBanner(Type, ID) {
	document.location.href = "index.php?md=Affiliate_Merchants_Views_Banner"+Type+"&action=edit&bid="+ID+"&<?php echo SID?>";
}
</script>


    <form enctype="multipart/form-data" name="myform" action=index.php method=post>
    <table class="mt10' border=0 cellspacing=0 cellpadding=3 width="780">
    <tr><td><?php echo L_G_ROTATORBANNERHELP; ?></td></tr>
    </table>
    <table border=0 class="listing mt10" cellspacing=0 cellpadding=3 width="780">
    <?php QUnit_Templates::printFilter(2, $_POST['header']); ?>
    <tr>
      <td width="5%" class=formText nowrap>&nbsp;<?php echo L_G_BANNERNAME?>&nbsp;&nbsp;<?php showQuickHelp(L_G_HLP_BANNERNAME); ?></td>
      <td>
        <input type=text name=name size=60 maxlength="100" value="<?php echo $_POST['name']?>">
      </td>
    </tr>
    <tr>
      <td class=formText nowrap>&nbsp;<?php echo L_G_ADDBANNER?>&nbsp;&nbsp;<?php showQuickHelp(L_G_HLP_ROTATOR_ADDSUBBANNER); ?></td>
      <td>
        <select name=addbanner_id>
        <?php $bannerInfo = array();
           while($data=$this->a_list_data_banners->getNextRecord()) { ?>
          <option value='<?php echo $data['bannerid']?>' <?php echo ($_POST['exist_banner'] == $data['bannerid'] ? 'selected' : '')?>><?php echo $data['type_text'].'┃'.$data['bannerid'].'┃'.$data['name'].'┃'.$data['destinationurl']?></option>
        <?php  $bannerInfo[$data['bannerid']] = $data['type_text'].'┃'.$data['bannerid'].'┃'.$data['name'].'┃'.$data['destinationurl'];
           } ?>
        </select>&nbsp;&nbsp;&nbsp;
            <?php $rank = (count($this->a_selected_banners) > 0) ? round(100/(count($this->a_selected_banners)+1)) : 100; ?>
            <?php echo L_G_RANK?>:&nbsp;&nbsp;<input type="text" name="addbanner_rank" size="3" value="<?php echo $rank?>">
        &nbsp;&nbsp;&nbsp;<input class="formbutton" name="submit_add" type="submit" value="<?php echo L_G_ADD?>">
      </td>
    </tr>
    <tr>
      <td class=formText nowrap>&nbsp;<?php echo L_G_BANNERLIST?>&nbsp;&nbsp;<?php showQuickHelp(L_G_HLP_ROTATOR_BANNERLIST); ?></td>
      <td><input type="hidden" name="desc" value="<?php echo $_POST['desc']?>">
          <table width="100%" class="tblist" border=0 cellspacing=0 cellpadding=1>
          <tr class="header">
              <td class="header" nowrap align="center" rowspan="2"><?php echo L_G_BANNER?></td>
              <td class="header" width=1% nowrap align="center" colspan="2"><?php echo L_G_IMPRESSIONS?></td>
              <td class="header" width=1% nowrap align="center" rowspan="2"><?php echo L_G_CLICKS?></td>
              <td class="header" width=1% nowrap align="center" rowspan="2"><?php echo L_G_CTR?></td>
              <td class="header" width=1% nowrap align="center" rowspan="2"><?php echo L_G_RANK?></td>
              <td class="header" width=50 nowrap align="center" rowspan="2"><?php echo L_G_ACTIONS?></td>
          </tr>
          <tr class="header">
              <td class="header" align="center" width=1% nowrap><?php echo L_G_ALL?></td>
              <td class="header" align="center" width=1% nowrap><?php echo L_G_UNIQUE?></td>
          </tr>
          <?php
          if (count($this->a_selected_banners) != 0) {
              foreach ($this->a_selected_banners as $bannerID => $bannerData) { ?>
                 <tr class=listresult class=row onMouseover="this.className='listresultMouseOver'" onMouseOut="this.className='listresult';">
                      <td class="listresultnocenter" align="left" nowrap>&nbsp;<?php echo $bannerInfo[$bannerID]?></td>
                      <td class="listresult" align="right"><?php echo $bannerData['all_imps']?></td>
                      <td class="listresult" align="right"><?php echo $bannerData['uniq_imps']?></td>
                      <td class="listresult" align="right"><?php echo $bannerData['clicks']?></td>
                      <td class="listresult" align="right"><?php echo ($bannerData['all_imps'] == 0) ? 0 : round($bannerData['clicks']/$bannerData['all_imps']*100, 2)?> %</td>
                      <td class="listresult" align="right">
                        <?php  if ($_POST['edit_rank_id'] == $bannerID) { ?>
                                <input type="hidden" name="edit_rank_id" value="<?php echo $_POST['edit_rank_id']?>">
                                <input type="text" size="5" name="edit_rank_value" value="<?php echo ($_POST['edit_rank_value'] == '') ? $bannerData['rank'] : $_POST['edit_rank_value']?>">
                        <?php  } else {
                                echo $bannerData['rank'];
                            }
                        ?>
                      </td>
                      <td class="listresult">
                          <?php  if ($_POST['edit_rank_id'] == $bannerID) {
                              ?><input class="formbutton_icotick" name="save_rank" type="submit" title="<?php echo L_G_SAVE.' '.L_G_RANK?>" value="">
                              <?php } else {
                              ?>
                                <input type="image" name="editrank_<?php echo $bannerID?>" title="<?php echo L_G_EDIT.' '.L_G_RANK; ?>" src="<?php echo QUnit_UI_TemplatePage::getImage('edit.gif'); ?>" />
                              <?php } ?>
                              &nbsp;
                              <input onclick="javascript:return window.confirm('<?php echo L_G_DELETEFADROMROTATOR; ?>');" type="image" name="delete_<?php echo $bannerID; ?>" title="<?php echo L_G_DELETE; ?>" src="<?php echo QUnit_UI_TemplatePage::getImage('delete.png'); ?>" />
                      </td>
                 </tr>
          <?php    }
          } else { ?>
                <tr class=listresult class=row onMouseover="this.className='listresultMouseOver'" onMouseOut="this.className='listresult';">
                    <td class="listresult" colspan="7"><b><?php echo L_G_NOBANNERSINROTATOR?></b></td>
                </tr>
          <?php
          } ?>
          <tr class="listheader">
              <td class=listresultnocenter nowrap colspan="7" align="left">
                &nbsp;<input class="formbutton" name="reset_stats" type="submit" value="<?php echo L_G_RESETSTATS?>">
                &nbsp;&nbsp;&nbsp;<input class="formbutton" name="reset_rank" type="submit" value="<?php echo L_G_RESETRANK?>">
              </td>
          </tr>
          </table>
      </td>
    </tr>
    <tr>
      <td class=formText>&nbsp;</td>
      <td class="errorMessage"><?php echo L_G_ROTATORBANNERWARNING?></td>
    </tr>
    <tr>
      <td class=formText nowrap>&nbsp;<?php echo L_G_SELFOPTIMIZATION?>&nbsp;&nbsp;<?php showQuickHelp(L_G_HLP_ROTATOR_SELFOPTIMIZATION); ?></td>
      <td><select name="sourceurl">
          <option value="<?php echo SELFOPTIMIZATION_NONE?>" <?php echo ($_POST['sourceurl'] == SELFOPTIMIZATION_NONE) ? 'selected' : ''?>><?php echo L_G_NOSELFOPTIMIZATION?></option>
          <option value="<?php echo SELFOPTIMIZATION_CLICKS?>" <?php echo ($_POST['sourceurl'] == SELFOPTIMIZATION_CLICKS) ? 'selected' : ''?>><?php echo L_G_CLICKS?></option>
          <option value="<?php echo SELFOPTIMIZATION_CTR?>" <?php echo ($_POST['sourceurl'] == SELFOPTIMIZATION_CTR) ? 'selected' : ''?>><?php echo L_G_CTR?></option>
          </select>
      </td>
    </tr>
    <tr>
      <td class="formText" colspan="2" align="left">
      <input type="hidden" name="desturl" value="<?php echo $_POST['desturl']?>" />
      <input type="hidden" name="commited" value="yes" />
      <input type="hidden" name="hidden" value="0" />
      <input type="hidden" name="campaign" value="cliksale" />
      <input type="hidden" name="bannercategory" value="_" />
      <input type="hidden" name="md" value="<?php echo $this->a_md?>" />
      <input type="hidden" name=action value="<?php echo $_REQUEST['action']?>" />
      <input type="hidden" name="cid" value="<?php echo $_REQUEST['cid']?>" />
      <input type="hidden" name="bid" value="<?php echo $_REQUEST['bid']?>" />
      <input class="formbutton" name="submit" type="submit" value="<?php echo L_G_SUBMIT; ?>" />
      </td>
    </tr>
    </table>
    </form>


<?php if($_REQUEST['action']!='edit') { ?>
<form name="FilterForm" action="index.php">
<input type="hidden" name="md" value="<?php echo $_REQUEST['md']; ?>" />
<input type="hidden" name="list_page" value="<?php echo $_REQUEST['list_page']; ?>" />
<table class="tblist mt10" border=0 cellspacing=0 cellpadding=2 width="780">
<tr class="header">
    <?php $this->a_this->printListHeader();?>
</tr>

<?php if(!$this->a_allcount) {?>
<tr>
    <td colspan="<?php echo $this->a_list_cols; ?>"><?php echo L_G_NORESULTS; ?></td>
</tr>
<?php } else {
    $this->a_this->printListData();
?>
<tr>
    <td colspan="<?php echo $this->a_list_cols; ?>" align="center" ><?php QUnit_Templates::printPaging($this->a_list_page, $this->a_list_pages, $this->a_allcount);?></td>
</tr>
<?php } ?>

</table>
</form>
<?php } ?>