<?php
//print_r($this->input->get('aid'));
$display = $cid = $datepicker = $ofid = $pagination_link = $thclause = $select_val = "";
$display=$cid="";
?>
<link rel="stylesheet" href="../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="../public/bower_components/select2/dist/css/select2.min.css">
  <link rel="stylesheet" href="../public/bower_components/bootstrap-daterangepicker/daterangepicker.css">

  <!-- bootstrap datepicker -->
  <link rel="stylesheet" href="../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>

	<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">Conversion 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 placeholder="All Affiliate">-->
                                                                        <select multiple class="form-control select2" name="aid[]" id="aid" required placeholder="All Affiliate">
																			
                                                                        <option value="all" <?php $cidv = []; 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 $oidv = []; 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">
								<label>Data Fields</label>
								</div>
								<div class="form-group">
								<div class="container">
								<label class="col-md-2 checkbox-inline" for="checkboxes-0">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-0" value="aff_sub2" <?php //if($variable['aff_sub2']=='aff_sub2'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-0" value="aff_sub2" <?php if(isset($variable) && is_array($variable) && in_array('aff_sub2', $variable)) { echo 'checked'; } ?>>

								  Aff_Sub2
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-5">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-5" value="source"<?php //if($variable['source']=='source'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-5" value="source"<?php if(isset($variable) && is_array($variable) && in_array('source', $variable)){ echo ' checked';}?>>

								  Source
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-14">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-14" value="adv_sub2"<?php //if($variable['adv_sub2']=='adv_sub2'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-14" value="adv_sub2"<?php if(isset($variable) && is_array($variable) && in_array('adv_sub2', $variable)) { echo ' checked'; } ?>>

								  Adv_sub2
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-10">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-10" value="offer_file_id"<?php //if($variable['offer_file_id']=='offer_file_id'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-10" value="offer_file_id"<?php if(isset($variable) && is_array($variable) && in_array('offer_file_id', $variable)) { echo ' checked'; } ?>>

								  Offer_file_id
								</label>

								<label class="col-md-2 checkbox-inline" for="checkboxes-4">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-4" value="offer_ref"<?php //if($variable['offer_ref']=='offer_ref'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-4" value="offer_ref"<?php if(isset($variable) && is_array($variable) && in_array('offer_ref', $variable)) { echo ' checked'; } ?>>

								  Offer_ref
								</label>
								</div>
								</div>
								
								<div class="form-group">
								<div class="container">

								<label class="col-md-2 checkbox-inline" for="checkboxes-1">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-1" value="aff_sub3"<?php //if($variable['aff_sub3']=='aff_sub3'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-1" value="aff_sub3"<?php if(isset($variable) && is_array($variable) && in_array('aff_sub3', $variable)) { echo ' checked'; } ?>>

								  Aff_Sub3
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-6">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-6" value="goal_id"<?php //if($variable['goal_id']=='goal_id'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-6" value="goal_id"<?php if(isset($variable) && is_array($variable) && in_array('goal_id', $variable)) { echo ' checked'; } ?>>

								  Goal_id
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-15">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-15" value="adv_sub3"<?php //if($variable['adv_sub3']=='adv_sub3'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-15" value="adv_sub3"<?php if(isset($variable) && is_array($variable) && in_array('adv_sub3', $variable)) { echo ' checked'; } ?>>

								  Adv_sub3
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-8">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-8" value="aff_click_id"<?php //if($variable['aff_click_id']=='aff_click_id'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-8" value="aff_click_id"<?php if(isset($variable) && is_array($variable) && in_array('aff_click_id', $variable)) { echo ' checked'; } ?>>

								  Aff_click_id
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-9">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-9" value="offer_url_id"<?php //if($variable['offer_url_id']=='offer_url_id'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-9" value="offer_url_id"<?php if(isset($variable) && is_array($variable) && in_array('offer_url_id', $variable)) { echo ' checked'; } ?>>

								  Offer_url_id
								</label>
								</div>
								</div>
								

								<div class="form-group">
								<div class="container">


								<label class="col-md-2 checkbox-inline" for="checkboxes-2">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-2" value="aff_sub4"<?php //if($variable['aff_sub4']=='aff_sub4'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-2" value="aff_sub4" <?php if(isset($variable) && is_array($variable) && in_array('aff_sub4', $variable)) { echo 'checked'; } ?>>

								  Aff_Sub4
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-11">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-11" value="file_name"<?php //if($variable['file_name']=='file_name'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-11" value="file_name" <?php if(isset($variable) && is_array($variable) && in_array('file_name', $variable)) { echo 'checked'; } ?>>

								  File_name
								</label>

								<label class="col-md-2 checkbox-inline" for="checkboxes-16">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-16" value="adv_sub4"<?php //if($variable['adv_sub4']=='adv_sub4'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-16" value="adv_sub4" <?php if(isset($variable) && is_array($variable) && in_array('adv_sub4', $variable)) { echo 'checked'; } ?>>

								  Adv_sub4
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-13">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-13" value="adv_sub"<?php //if($variable['adv_sub']=='adv_sub'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-13" value="adv_sub" <?php if(isset($variable) && is_array($variable) && in_array('adv_sub', $variable)) { echo 'checked'; } ?>>

								  Adv_sub
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-7">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-7" value="affiliate_ref"<?php //if($variable['affiliate_ref']=='affiliate_ref'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-7" value="affiliate_ref" <?php if(isset($variable) && is_array($variable) && in_array('affiliate_ref', $variable)) { echo 'checked'; } ?>>

								  Affiliate_ref
								</label>
								</div>
								</div>
								
								<div class="form-group">
								<div class="container">


								<label class="col-md-2 checkbox-inline" for="checkboxes-3">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-3" value="aff_sub5"<?php //if($variable['aff_sub5']=='aff_sub5'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-3" value="aff_sub5" <?php if(isset($variable) && is_array($variable) && in_array('aff_sub5', $variable)) { echo 'checked'; } ?>>

								  Aff_Sub5
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-12">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-12" value="advertiser_id"<?php //if($variable['advertiser_id']=='advertiser_id'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-12" value="advertiser_id" <?php if(isset($variable) && is_array($variable) && in_array('advertiser_id', $variable)) { echo 'checked'; } ?>>

								  Advertiser_id
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-17">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-17" value="adv_sub5"<?php //if($variable['adv_sub5']=='adv_sub5'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-17" value="adv_sub5" <?php if(isset($variable) && is_array($variable) && in_array('adv_sub5', $variable)) { echo 'checked'; } ?>>
								  Adv_sub5
								</label>
								<label class="col-md-2 checkbox-inline" for="checkboxes-18">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-18" value="session_ip"<?php //if($variable['session_ip']=='session_ip'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-18" value="session_ip" <?php if(isset($variable) && is_array($variable) && in_array('session_ip', $variable)) { echo 'checked'; } ?>>
								  Session_ip
								</label>
								<label class="col-md-1 checkbox-inline" for="checkboxes-20">
								  <!-- <input type="checkbox" name="variable[]" id="checkboxes-20" value="datetime"<?php //if($variable['datetime']=='datetime'){ echo 'checked';}?>> -->
								  <input type="checkbox" name="variable[]" id="checkboxes-20" value="datetime" <?php if(isset($variable) && is_array($variable) && in_array('datetime', $variable)) { echo 'checked'; } ?>>

								  Datetime
								</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="reservation"  name="gdate" value="<?php echo (!empty($date) ? $date : date('DD-MM-YYYY')); ?>" required>
								</div>
							  </div>
						</div>
						                                 <div class="box-footer">
                                                                <button type="submit" class="btn btn-primary">Submit</button>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../offer/reports">Reset Filter</a>
                                                                <?php if(!empty($_SERVER['QUERY_STRING'])){?><a href="<?php print $_SERVER['REQUEST_URI']."&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-2">Conversion Time</th>
                  <th class="col-xs-1">Advertiser</th>
				  <th class="col-xs-2">Affiliate Name</th>
                  <th class="col-xs-1">Offer</th>
                  <th class="col-xs-1">Click Id</th>
                  <th class="col-xs-2">Click IP</th>
                 <!-- <th class="col-xs-2">Click URL</th>
                 --> <th class="col-xs-1">Browser</th>
                  <th class="col-xs-1">City</th>
                  <th class="col-xs-1">Country</th>
                  <th class="col-xs-1">Status</th>
                  <th class="col-xs-1">Pixel Type</th>
                  <th class="col-xs-1">Aff_Sub</th> 
				<?=$thclause?>
                </tr>
                </thead> 
				<?php
				//$this->load->view('temp-conv');
				?>
                <tbody>
				<?php if(!empty($report)){print $report;}?>
				</tbody>
				
				</table>
			</div>
			<span align="center" ><?php echo $paginate;?></span>
			</div>
			</div>
			</div>
			</section>