<link rel="stylesheet" href="<?php print base_url();?>public/bower_components/font-awesome/css/font-awesome.min.css">
<!--	<script src="../public/bower_components/select2/dist/js/select2.full.min.js"></script>
-->  <link rel="stylesheet" href="<?php print base_url();?>public/bower_components/select2/dist/css/select2.min.css">
  <link rel="stylesheet" href="<?php print base_url();?>public/bower_components/bootstrap-daterangepicker/daterangepicker.css">

  <!-- bootstrap datepicker -->
  <link rel="stylesheet" href="<?php print base_url();?>public/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
<style>
.select2-container--default .select2-selection--multiple .select2-selection__choice{
background-color:#336877;
}
</style>

<style>
.table-hover tbody tr:hover td{
background-color:#cac3c3;
}
</style>
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
			<section class="content" >
			<div class="row">
			<!--<div class="col-md-10" style="margin-left:10%;">--> 
					<div class="box box-primary" style="box-shadow: 0 2px 1px #666;" >
							<div class="box-header with-border bg-navy disabled">
							  <h3 class="box-title">Affiliate Report</h3>
							</div>
							<!-- /.box-header -->
							<!-- form start -->
							<form role="form" method="get" action="">
							  <div class="box-body">
								<div class="form-group"><div class="container">
								 <div class="col-sm-4"><label>Affiliate</label>
									<!--<select multiple class="form-control select2" name="aid[]" id="aid" onchange="getAff(this.value)"  required>-->
									<select multiple class="form-control select2" name="aid[]" id="aid"  required>
									<option value="all" <?php if(in_array('all',$cidv)){ echo "selected";}?>>All Affiliate</option>
										 <?php
										foreach($advertiser as $avalue)
										{
											$adv_comp=$avalue['comp'];
											$adv_id=$avalue['id'];
											if(in_array($adv_id,$cidv))
											{
												$selected="selected";
												echo "<option value='$adv_id' $selected>$adv_comp - ($adv_id)</option>";
											}
											else{
												echo "<option value='$adv_id'>$adv_comp - ($adv_id)</option>";
											}
										}
										?>
									</select>
									</div>
                                                                 <div class="col-sm-5">
									<label>Offers</label>
		                                                        <select multiple class="form-control select2" name="ofid[]" id="ofid"  data-placeholder="Select Offer">
                		                                             <option value="all" <?php if(in_array('all',$oidv)){ echo "selected";}?>>All Offers</option>
                                		                              <?php
                                                		             foreach($offers as $ovalue)
                                                               		{
                                                                                        $ofrnm=$ovalue['ofr_name'];
                                                                                        $ofrid=$ovalue['ofr_id'];
                                                                                        if(in_array($ofrid,$oidv))
                                                                                        {
                                                                                                $selected="selected";
                                                                                                echo "<option value='$ofrid' $selected>$ofrnm - ( $ofrid )</option>";
                                                                                        }
                                                                                        else{
                                                                                                echo "<option value='$ofrid'>$ofrnm - ( $ofrid )</option>";
                                                                                        }
                                                                                }
                                                                                ?>
                                                        		</select>

                                                                        </div>

									</div></div>
							 <div class="form-group">
							<div class="container">
                                                        <div class="col-sm-3">
							<label>Aff_Sub1</label>	
							<!--<select class="select2 form-control itemNam" onclick="setValss('sub')" name="sub" id="sub" data-placeholder="Aff_Sub" ></select>
-->
							<select class="form-control select2" name="sub" id="sub11" data-placeholder="Aff_Sub" >
							<option value=" ">--Select--</option>
							<option value="all" <?php if($asub1=='all'){ print "selected";}?>>All AFF_SUB1</option>
							<option value="<?php print $asub1;?>" <?php if($asub1){ print "selected";}?>><?php print $asub1;?></option>
							<?php
							/*foreach($sub1 as $affval)
							{
								$affsub1=$affval['aff_sub'];
								if($asub1==$affsub1)
								{
								$selected="selected";
								echo "<option value='$affsub1' $selected>$affsub1</option>";
								}
								else{
								echo "<option value='$affsub1'>$affsub1</option>";
								}
							}*/
							?>
							</select>
							</div>                                                        <div class="col-sm-3">
                                                        <label>Aff_Sub2</label>
                                                        <!--<select class="select2 form-control itemNam" onclick="setValss('sub2')" name="sub2" id="sub2" data-placeholder="Aff_Sub2"></select>-->
                                                        <select class="form-control select2" name="sub2" id="sub22" data-placeholder="Aff_Sub2" >
                                                        <option value=" ">--Select--</option>
                                                        <option value="all" <?php if($asub2=='all'){ print "selected";}?>>All AFF_SUB2</option>
                                                        <?php
                                                        foreach($sub2 as $affval)
                                                        {
                                                                $affsub2=$affval['aff_sub2'];
                                                                if($asub2==$affsub2)
                                                                {
                                                                $selected="selected";
                                                                echo "<option value='$affsub2' $selected>$affsub2</option>";
                                                                }
                                                                else{
                                                                echo "<option value='$affsub2'>$affsub2</option>";
                                                                }
                                                        }
                                                        ?>
                                                        </select>
                                                        </div>                                                        <div class="col-sm-3">
                                                        <label>Aff_Sub3</label>
                                                        <!--<select class="select2 form-control itemNam" onclick="setValss('sub3')" name="sub3" id="sub3" data-placeholder="Aff_Sub3"></select>-->
                                                        <select class="form-control select2" name="sub3" id="sub33" data-placeholder="Aff_Sub3" >
                                                        <option value=" ">--Select--</option>
                                                        <option value="all" <?php if($asub3=='all'){ print "selected";}?>>All AFF_SUB3</option>
                                                        <?php
                                                        foreach($sub3 as $affval)
                                                        {
                                                                $affsub3=$affval['aff_sub3'];
                                                                if($asub3==$affsub3)
                                                                {
                                                                $selected="selected";
                                                                echo "<option value='$affsub3' $selected>$affsub3</option>";
                                                                }
                                                                else{
                                                                echo "<option value='$affsub3'>$affsub3</option>";
                                                                }
                                                        }
                                                        ?>
                                                        </select>
                                                        </div></div></div>                                                          <div class="form-group">
                                                        <div class="container">
                                                       <div class="col-sm-3">
                                                        <label>Aff_Sub4</label>
                                                        <!--<select class="select2 form-control itemNam" onclick="setValss('sub4')" name="sub4" id="sub4" data-placeholder="Aff_Sub4"></select>-->
                                                        <select class="form-control select2" name="sub4" id="sub44" data-placeholder="Aff_Sub4" >
                                                        <option value=" ">--Select--</option>
                                                        <option value="all" <?php if($asub4=='all'){ print "selected";}?>>All AFF_SUB4</option>
                                                        <?php
                                                        foreach($sub4 as $affval)
                                                        {
                                                                $affsub4=$affval['aff_sub4'];
                                                                if($asub4==$affsub4)
                                                                {
                                                                $selected="selected";
                                                                echo "<option value='$affsub4' $selected>$affsub4</option>";
                                                                }
                                                                else{
                                                                echo "<option value='$affsub4'>$affsub4</option>";
                                                                }
                                                        }
                                                        ?>
                                                        </select>
                                                        </div>                                                       <div class="col-sm-3">
                                                        <label>Aff_Sub5</label>
                                                        <select class="select2 form-control itemNam"  onclick="setValss('sub5')" name="sub5" id="sub5" data-placeholder="Aff_Sub5"></select>
                                  </div>
							<input type="hidden" id="getid" value="">
</script>
<div class="col-sm-3">
                                                        <label>Aff_Manager</label>
                                                       <select class="form-control select2" name="affmng" id="affmng" data-placeholder="Aff_Manager" >
                                                        <option value=" ">Affiliate Manager</option>
                                                        <?php
                                                        foreach($affmng as $affval)
                                                        {
                                                                $mng=$affval['manager_name'];
                                                                if($affmngsubmit==$mng)
                                                                {
                                                                $selected="selected";
                                                                echo "<option value='$mng' $selected>$mng</option>";
                                                                }
                                                                else{
                                                                echo "<option value='$mng'>$mng</option>";
                                                                }
                                                        }
                                                        ?>
                                                        </select>
                                                        </div>
	</div></div>
															
								<div class="form-group">
								<label>Calculation</label>
								</div>
								<div class="form-group">
								<div class="container">
								<label class="col-md-2 checkbox-inline" for="checkboxes-20">
								  <input type="checkbox" name="calculation[]" id="checkboxes-20" value="cpc" <?php if($calculation['cpc']=='cpc'){ echo 'checked';}?>>
								  CPC
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-21">
								  <input type="checkbox" name="calculation[]" id="checkboxes-21" value="cr"<?php if($calculation['cr']=='cr'){ echo 'checked';}?>>
								  CR
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-23">
								  <input type="checkbox" name="calculation[]" id="checkboxes-23" value="cpa"<?php if($calculation['cpa']=='cpa'){ echo 'checked';}?>>
								  CPA
								</label>


								</div>
								</div>
								
								<div class="form-group">
								<div class="container">
								<label class="col-md-2 checkbox-inline" for="checkboxes-24">
								  <input type="checkbox" name="calculation[]" id="checkboxes-24" value="rpc" <?php if($calculation['rpc']=='rpc'){ echo 'checked';}?>>
								  RPC
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-25">
								  <input type="checkbox" name="calculation[]" id="checkboxes-25" value="rpa"<?php if($calculation['rpa']=='rpa'){ echo 'checked';}?>>
								  RPA
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-26">
								  <input type="checkbox" name="calculation[]" id="checkboxes-26" value="ctr"<?php if($calculation['ctr']=='ctr'){ echo 'checked';}?>>
								  CTR
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-27">
								  <input type="checkbox" name="calculation[]" id="checkboxes-27" value="addurl"<?php if($calculation['addurl']=='addurl'){ echo 'checked';}?>>
								  ADD URL
								</label>
								</div>
								</div>
								
								

							  <div class="form-group">
								<label>Select Date:</label>

								<div class="input-group" style="width:50%">
								  <div class="input-group-addon">
									<i class="fa fa-calendar"></i>
								  </div>
								  <input type="text" class="form-control pull-right" id="daterange-btn"  name="gdate" value="<?php echo (!empty($date) ? $date : date('DD/MM/YYYY')); ?>" required>
								</div>
								<!-- /.input group -->
							  </div>
						</div>
							  <!-- /.box-body -->

							  <div class="box-footer">
								<button type="submit" class="btn btn-primary">Submit</button>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../offer/areport">Reset Filter</a>
								<?php if(!empty($_SERVER['QUERY_STRING'])){?><a href="<?php print base_url()."/offerssub/areportcsv?".$_SERVER['QUERY_STRING']."&csv=1";?>" class="ml-2" style="float:right">Export Report</a>
								<?php }?>
							  </div>
							</form>
						  </div>
			<!--</div>-->
			</div>
			</section>
            <!-- /.box-header -->
			<hr style="border: 1px dotted #0099CC;margin-left:10px; margin-right:10px;">
        
        
            <div class="box-body table-responsive">
              <table id="example2" class="table table-bordered table-hover">
                <thead>
                <tr>
            <!--      <th class="col-xs-1">SN.</th>
                -->  <th class="col-xs-1">Date</th>
                  <th class="col-xs-1">Offer-ID</th>
                  <th class="col-xs-2">Offer-Name</th>
		  <th class="col-xs-2">Affiliate-Name</th>
                  <th class="col-xs-1">Total-Clicks</th>
                  <th class="col-xs-1">Unique-Clicks</th>
                  <th class="col-xs-1">Conversion</th>
                  <th class="col-xs-2">Cost</th>
          <!--        <th class="col-xs-1">Payout</th>
                  <th class="col-xs-1">Revenue-Type</th>
              -->    <th class="col-xs-1">Revenue</th>
				  <?=$thclausecal?>
		 <th class="col-xs-1">Profit</th>
		<?php if($asub1){?>
		 <th class="col-xs-1">Aff_Sub1</th>
		<?php } if($asub2){?>
		 <th class="col-xs-1">Aff_Sub2</th>
		<?php } if($asub3){?>
		 <th class="col-xs-1">Aff_Sub3</th>
		<?php } if($asub4){?>
		 <th class="col-xs-1">Aff_Sub4</th>
		<?php } if($asub5){?>
		 <th class="col-xs-1">Aff_Sub5</th>
		<?php } ?>
                </tr>
                </thead>
                <tbody>
				<?php if(!empty($report)){print $report;}?>
				<!--<tr style="background-color: #efecec;">
				<td></td>
				<td></td>
				<td></td>
				<td>Total</td>
				<td><?php //print $totalid;?></td>
				<td><?php //print $totaluni;?></td>
				<td><?php //print $totalconv;?></td>
				<td><?php //print $totalcost;?></td>
				<td><?php //print $totalrev;?></td>
				<td><?php //print $totalpro;?></td>
				<td></td>
				<td></td>
				</tr>-->
				</tbody>
				
				</table>
			</div>
			<span align="center" ><?php echo $paginate;?></span>
			</div>
			</div>
			</div>
			</section>

<script>
$(document).ready(function(){

 $("#sub111").select2({
  ajax: { 
   url: "../dropd",
   type: "post",
   dataType: 'json',
   delay: 250,
   data: function (params) {
    return {
      q: params.term // search term
    };
   },
   processResults: function (response) {
     return {
        results: response
     };
   },
   cache: true
  }
 });
});
</script>			
