<?php 
/**
 * Screen recorddetail\index
 * @version 1.0.1
 * @package Backend\DataRecords
 * 
*/
require_once 'app/class-lov-manager.php';
$detail = $this->data['item'];
$list = $this->data['list'];
$lovmanager = new LovManager();
$recordstatuslist = $lovmanager->getLov_RecordStatus();
$bakurl =  $this->data['bakkey'];
$navurl = $this->data['navkey'];
$listStates = $this->data['states'];

?>
<div class="row" >
<div class="col-lg-12" >
            <h3><?= R('page_title_nfp_recorddetail') ?></h3>
             <form class="form-inline" role="form" name="form1" method="post" action="<?= __SITEBASE ?>/recorddetail/save/?uid=<?= $detail->id ?>">
             <div class="panel panel-default">
		         <div class="panel-body">
			        
			         	<div class="form-group">
			          	<?= R('label_organisation') ?>:
			          	<b><?= $detail->organisationintname ?></b>	
					   </div>
					   <div class="form-group">
					   <?= R('label_date') ?>:
					   <b><?= $detail->datefrom ?></b>
					  </div>
					  <div class="form-group">
					  <?= R('label_recordset') ?>:
					   <?php if (isset($detail->recordsetid)) {?>
					   	<b><a href="<?= __SITEBASE ?>/recordconsolidation?uid=<?= $detail->recordsetid ?>&<?=$navurl ?>"><?= $detail->recordsetid ?></a></b>
					   	<?php } else { ?>
					  	<b> - </b>
					  	<?php } ?>
					  </div>
					  <div class="form-group">
					  <?= R('label_type') ?>:
					 	<b><?= $detail->statisticaltypeid == __STATISTICAL_TYPE_VICTIMS ? D(__STATISTICAL_TYPE_VICTIMS_DESCRITION) : ($detail->statisticaltypeid == __STATISTICAL_TYPE_TRAFFICKERS ? D(__STATISTICAL_TYPE_TRAFFICKERS_DESCRITION) : '')  ?></b>
					  </div>
					  <div class="form-group">
					   <?= R('cluster') ?>:
					   <?php if (isset($detail->clusterid)) {?>
					   	<b><a href="<?= __SITEBASE ?>/clusterdetail?cid=<?= $detail->clusterid ?>&<?=$navurl ?>"><?= $detail->clusterid ?></a></b>
					   	<?php } else { ?>
					  	<b> - </b>
					  	<?php } ?>
					  </div>
					  <div class="form-group">
					   <?= R('label_annotation') ?>:
					   <textarea class="form-control" cols="60" rows="2" name="annotation"><?= $detail->annotation ?></textarea> 
					  </div>
					  <div class="form-group">
					  <?= R('label_status') ?>:
					  <select name="recordstatus" class="form-control">
					  	  <?php  foreach($listStates as $status) { ?>
					   		<option value="<?= $status->to_statecode_id ?>" <?= $detail->statuscodeid == $status->to_statecode_id ? 'selected':''?>><?= D($status->to_statecode__description) ?></option>
					   <?php  } ?>
					   </select>
					  </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>
				                    <th class="header"><?= R('label_name') ?> <i class="fa fa-sort"></i></th>
				                    <th class="header"><?= R('label_value') ?> <i class="fa fa-sort"></i></th>
				                  </tr>
				                </thead>
				                <tbody>
				                <?php foreach($list as $line) { ?>
				                 <tr>
				                    <td><?= D($line[0]->group_descriptioncode) ?></td>
				                    <td><?= D($line[0]->question_descriptioncode) ?></td>
				                    <td><?= $line[0]->umlcode ?></td>
				                    <td>
				                    <?php foreach($line as $response) { ?>
				                    	<?php if ($response->datatypecodeid == _DATA_TYPE_RESPONSE_MAPPOINT) { ?>
		                    		<!--<a href="javascript:alert('<?= $response->originalvalue ?>')"><span class="glyphicon glyphicon-map-marker"></span></a>--><!-- <?= R('label_maplocation') ?> -->
										<a href="javascript:openGeoModal('<?= __SITEBASE ?>/websig/modal?geo=<?= $response->originalvalue ?>')"><span class="glyphicon glyphicon-map-marker"></span></a>
						                    	<?php }else {?>
                                                        <?= isset($response->codelist_descriptioncode) ? D($response->codelist_descriptioncode) : (($response->originalvalue !== null) ? $response->originalvalue : R('label_unknown')) ?>
				                    	<?php } ?>
				                    	<br>
				                    <?php } ?>
				                    </td>
				                 </tr>
				                <?php } ?>
				                </tbody>
				              </table>
			              </div>
		              </div>
	              </div>
            </div>
           <div class="form-group">
				<button style="padding-left:20px;" type="submit" class="btn btn-default"><?=R('label_save') ?></button>
				<?php if (isset($bakurl)) { ?>
					<a href="<?= __SITEBASE ?>/<?= $bakurl ?>" class="btn btn-default"><?=R('label_cancel') ?></a>
					<?php } ?>
				
			</div>
			</form>
		</div>
</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>