<?php
	$postUrl = $this->url ( array ("module" => "oa", "controller" => "relationships", "action" => "currentbatches"));
	$this->placeholder;
?>
<h2>Release Approval</h2>
<br />
<form name="chkinUserReleases" action="<?php echo $postUrl?>" method="post">
	<div class="panelHeader">
		<h3>Currently checked out</h3>
	</div>
	<div class="panelContent">
		<table class="data">
			<tr>
				<th>User Name</th>
				<th class="center">Checked out Time</th>
				<th class="center"># Checked Out</th>
				<th class="rowSelect">
					<?php if(count($this->batches)>0){?>
						<input type="checkbox" name="selectAll" id="selectAll"/>
					<?php }?>
				</th>
			</tr>
<?php
			foreach($this->batches as $batch){
?>
				<tr>
					<td><a href="<?php echo $this->url ( array ("module" => "oa", "controller" => "relationships", "action" => "checkoutrelease" ,"userId"=>$batch['checked_out_by'],"pageType"=>"myBatch"));?>"><?php echo $batch['userName']?></a></td>
					<td><?php echo $batch['updated']?></td>
					<td class="center"><?php echo $batch['count']?></td>
					<td class="center"><input type="checkbox" name="selectUsers[]" class="case" value="<?php echo $batch['checked_out_by']?>"/></td>
				</tr>
<?php
			}
?>
		</table>&nbsp;
<?php
		if(count($this->batches)>0){
?>
			<div align="right"><input class="btn btn-primary btn-sm" type="submit" value="Check In Releases"/></div>
<?php
		}
?>
	</div>
</form>
<script>
$(function(){
    // add multiple select / deselect functionality
    $("#selectAll").click(function () {
    	$('.case').attr('checked', this.checked);
    });

    // if all checkbox are selected, check the selectall checkbox
    // and viceversa
	$(".case").click(function(){
		if($(".case").length == $(".case:checked").length) {
            $("#selectAll").attr("checked", "checked");
        } else {
            $("#selectAll").removeAttr("checked");
        }
    });
});
</script>