<?php 
/**
 * Screen comparerecords\index
 * @version 1.0.1
 * @package Backend\DataRecords
 *
 */
$list1 = $this->data['list1'];
$list2 = $this->data['list2'];
$values = $this->data['values'];
$bakurl =  $this->data['bakkey'];
$navurl = $this->data['navkey'];

?>
<div class="row" >
<div class="col-lg-12" >
            <h3><?= R('page_title_comparerecords') ?></h3>
            <p>&nbsp;</p>
			<?php $this->load('common/message',$this) ?>            
              <div class="panel" style="margin-top:20px;">
	             <div class="panel panel-default">
			         <div class="panel-body">
			           	 <div class="table-responsive" >
			           	 	  <p><?= R('label_records') ?></p>
				              <table class="table table-hover table-striped tablesorter">
				                <thead>
				                  <tr>
				                  
				                    <th class="header"><?= R('label_record') ?> <i class="fa fa-sort"></i></th>
				                    <th class="header"><?= R('label_date') ?> <i class="fa fa-sort"></i></th>
				                    <th class="header"><?= R('label_type') ?> <i class="fa fa-sort"></i></th>
				                    <th class="header"><?= R('label_organisation') ?> <i class="fa fa-sort"></i></th>
                                                    <th class="header"><?= R('label_status') ?> <i class="fa fa-sort"></i></th>
				                  </tr>
				                </thead> 
				                <tbody>
				                <?php foreach($list1 as $line) { ?>
				                 <tr>
				                    <td><?= $line->id ?></td>
				                    <td><?= $line->datefrom ?></td>
				                    <td><?= $line->statisticaltypeid == __STATISTICAL_TYPE_VICTIMS ? R('type_victims') : ($line->statisticaltypeid == __STATISTICAL_TYPE_TRAFFICKERS ? R('type_traffickers') : '')  ?></td>
				                    <td><?= $line->organisationintname ?></td>
				                    <td>
				                    <?php 
				                    $status = new Entity('codelistitems',$line->statuscodeid);
				                    ?>
				                	<?= D($status->descriptioncode) ?>
				                	</td>
				                 </tr>
				               <?php }?>
				                </tbody>
				              </table>
			              </div>
		              </div>
	              </div>
			</div>
			<div class="panel" style="margin-top:20px;">
	             <div class="panel panel-default">	
			         <div class="panel-body">
			           	 <div class="table-responsive" >
			           	 	
				            <table class="table table-hover table-striped tablesorter">
				                <thead>
				                  <tr>
				                  
				                    <th class="header"><?= R('label_group') ?> <i class="fa fa-sort"></i></th>
				                    <th class="header"><?= R('label_question') ?> <i class="fa fa-sort"></i></th>
				                   <?php foreach($list1 as $col) {?>
				                    	<th class="header"><?= R('label_question_value') ?>&nbsp;<?= $col->id ?>&nbsp;<i class="fa fa-sort"></i></th>
				                    <?php } ?>
				                  </tr>
				                </thead>
				                <tbody>
				                <?php 
    
				                foreach($list2 as $line) { ?>
				                 <tr>
				                    <td><?= D($line->group_descriptioncode) ?></td>
				                    <td><?= D($line->question_descriptioncode) ?></td>
				                    <?php foreach($list1 as $col) { ?>
				                    	<td>
				                    	<?php 
				                    	if ($values[$col->id.'_'.$line->questionid]) {
					                    	foreach($values[$col->id.'_'.$line->questionid] as $value) { ?> 
					                    		<?php if ($line->datatypecodeid == _DATA_TYPE_RESPONSE_MAPPOINT) { ?>
					                    		<!-- <a href="javascript:alert('<?= $value ?>')"><span class="glyphicon glyphicon-map-marker"></span></a>--><!-- <?= R('label_maplocation') ?> -->
						                   		<a href="javascript:openGeoModal('<?= __SITEBASE ?>/websig/modal?geo=<?= $value ?>')"><span class="glyphicon glyphicon-map-marker"></span></a><!-- <?= R('label_maplocation') ?> -->
					                    		<?php } else { ?>
					                    		<?= ($value !== null) ?$value : R('label_unknown')  ?><br>
					                    	<?php }
					                    	}
					                    	?>
				                    	</td>
				                    <?php } 
				                    	}?>
				                 </tr>
				               <?php }?>
				                </tbody>
				             </table>
			              </div>
		              </div>
	              </div>
			</div>
</div>
 <form class="form-inline">
		<div class="form-group">
				<?php if (isset($bakurl)) { ?>
					<a href="<?= __SITEBASE ?>/<?= $bakurl ?>" class="btn btn-default"><?=R('label_cancel') ?></a>
					<?php } ?>		</div>
 </form>
</div>          
<br><br>
<div class="modal" id="geoModal" data-backdrop="static">
	<div class="modal-dialog" style="width:80%">
      <div class="modal-content" >
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"  aria-hidden="true">X</button>
          <h4 class="modal-title"><?= __NAME ?></h4>
        </div>
        <div class="modal-body">
        	<iframe id="geomod" style="border:0;width:100%;height:630px"></iframe>
        </div>
      </div>
    </div>
</div>
 <script>
 function openGeoModal(url) {
	$('#geomod').attr('src',url);
	$('#geoModal').modal({show:true});
}
	 
 </script>
 