<?php 
	echo $this->Html->script('site_js/common');
	echo $this->Html->script('site_js/assignment');
?>
<style type="text/css">.blocktitle{
	width: 20%
}</style>
<div class="blocktitle"> Assignment</div>

<?php if($loggedUser['profile_id'] == $ses_datainfo[0]['Courserole']['profile_id'] &&  $ses_datainfo[0]['Courserole']['role'] == array_search('Teacher',$course_user_role)):?>
<div class="tar borb">
	<?php echo $this->Html->link('New Assignment',array('action'=>'index'),array('class'=>'btn btn-mini'));?>
	<?php echo $this->Html->link('Show All',array('controller'=>'assignments'.'/all'),array('class'=>'btn btn-mini'));?>
	<?php echo $this->Html->link('Old Assignment','javascript:void(0);',array('onclick'=>"getCtp('../assignments','/all');",'class'=>'btn btn-mini'));?>
	<?php echo $this->Html->link('Create Assignment',array('action'=>'add'),array('class'=>'btn btn-mini'));?>
	<?php //echo $this->Html->link('Back',array('controller'=>'sections'.'/add'),array('class'=>'btn btn-mini'));?>
</div>
<?php else:?>
<div class="tar borb">
	<?php echo $this->Html->link('New Assignment',array('action'=>'index'),array('class'=>'btn btn-mini'));?>
	<?php echo $this->Html->link('Show All',array('action'=>'all'),array('class'=>'btn btn-mini'));?>
	<?php echo $this->Html->link('Old Assignment','javascript:void(0);',array('onclick'=>"getCtp('../assignments','/index');",'class'=>'btn btn-mini'));?>
	<?php //echo $this->Html->link('Back',array('controller'=>'sections'.'/add'),array('class'=>'btn btn-mini'));?>
</div>
<?php  endif; ?>

<br/>


<div class="w99p pdl10 fnt80">
	<table width="100%" cellpadding="0" cellspacing="0" class="listable">
		<thead>
			<tr> 
				<th align="left">Due Date</th>
				<th align="left">Title</th>
				<th align="left">Description</th>
			</tr>
		</thead>
		<?php 
		//pr($assignments);die();
		foreach ($assignments as $assignment):
			$ass_title = $assignment['Assignment']['title'];
			if(strlen($ass_title)>20){
				$ass_title = substr($assignment['Assignment']['title'],0,20).'...';
			}
			?>
			<tr>
				<td><?php echo date('m-d-Y',strtotime($assignment['Assignment']['dueDate']))?></td>
                                <td><?php echo $this->Html->link(strip_tags($ass_title),array('controller'=>'assignmentfeedbacks','action'=>'add', base64_encode($assignment['Assignment']['id'])));?></td>
				<td><?php echo substr(strip_tags($assignment['Assignment']['description']),0,70)?></td>
			</tr>
			<?php 
		endforeach;
		?>
	</table>
</div>