<?php
/**
 * Screen efppublish\index
 * @version 1.0.1
 * @package Backend\DataSets
 * 
*/
require_once 'app/class-lov-manager.php';

$list = $this->data['list'];
$navurl = $this->data['navkey'];

$lovmanager = new LovManager();
$recordstatuslist = $lovmanager->getLov_RecordStatus();
$pubstatuslist = $lovmanager->getLov_PublishStatus();

$simpleStatusList = array();
foreach ($recordstatuslist as $lc){
	$simpleStatusList[$lc->id] = $lc->descriptioncode;
}
$simplePStatusList = array();
foreach ($pubstatuslist as $lc){
	$simplePStatusList[$lc->id] = $lc->descriptioncode;
}

//print_r($list);


?>
<div class="row" >
<div class="col-lg-12" >
            <h3><?= R('page_title_efp_publishdata') ?></h3>
            <p>&nbsp;</p>
			<?php $this->load('common/message',$this) ?>
            
             <form class="form-inline" role="form" name="formpubefp" id="formpubefp" onsubmit="return validate_checks();" method="post" action="<?= __SITEBASE ?>/efppublish/markpublishable">
             <input type="hidden" id="tainted" name="tainted" value="0"></input>
             <input type="hidden" id="retnav" name="retnav" value="efppublish"></input>
      
             
            <div class="panel" style="margin-top:20px;">
	             <div class="panel panel-default">
			         <div class="panel-body">
			           	 <div class="table-responsive" >
				              <table id="table1" class="table table-hover table-striped tablesorter">
				                <thead>
				                  <tr>
				                  	<th class=""></th>
										<th class=""><?= R('label_set') ?> <i class="fa fa-sort"></i></th>
										<th class="header"><?= R('label_organization') ?> <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_period') ?> <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_status') ?> <i class="fa fa-sort"></i></th>
										<th class="header"><?= R('label_publication') ?> <i class="fa fa-sort"></i></th>
								</tr>
				                </thead>
				                <tbody>
				                <?php foreach($list as $line) { ?>
			                 <tr class="annotation" title="<?=$line->annotation ?>">
				                    <td><input name="ck_<?= $line->id ?>" type="checkbox" <?= ($_POST['ck_'.$line->id] != null)? " checked " :"" ?> <?= ( $line->statuscodeid == __RECORD_STATUS_VALID && $line->publishcodeid == __PUBLISHED_STATUS_UNPUBLISHED)? "" : " disabled " ?> ></td>
									<td><a href="<?= __SITEBASE ?>/setdetail?uid=<?= $line->id ?>&<?=$navurl ?>"><?= $line->id ?></a></td>
									<td><?= $line->organisationname ?></td>
									<td><?= ($line->type == __STATISTICAL_TYPE_TRAFFICKERS) ? D(__STATISTICAL_TYPE_TRAFFICKERS_DESCRITION) : D(__STATISTICAL_TYPE_VICTIMS_DESCRITION) ?></td>
									<td><?= $line->fromperiod.'-'.$line->toperiod ?></td>
									<td><?= $line->setdate ?></td>
									<td><?= D($simpleStatusList[$line->statuscodeid]) ?></td>
				                    <td><?= D($simplePStatusList[$line->publishcodeid]) ?></td>			                    
				                 </tr>
				               <?php }?>
				                </tbody>
				              </table>
		            
			              </div>
			              
		              </div>
		              </div> 

						<button style="padding-left:20px;" type="submit" class="btn btn-default"><?=R('mark_publishable') ?></button>
						<br><br>				
						<a permissions="true" href="<?= __SITEBASE ?>/efppublish/prereleasestats?<?=$navurl ?>" class="btn btn-default"><?=R('label_prerelease_statistics') ?></a>
						<a permissions="true" href="<?= __SITEBASE ?>/efppublish/releasestats?<?=$navurl ?>" class="btn btn-default"><?=R('label_final_statistics') ?></a>

				</form>
				</form>
            </div>
</div>
</div>
 
 <script>
function validate_checks() {
	var numberOfChecked = $('input:checkbox:checked').length;

	if (numberOfChecked >0) {
		return true;
	} else {
	return false;
	}
}
</script>