<div class="blocktitle" style="margin-bottom: 10px;">Search Result</div> 
<div style="clear: both;"></div>
<div class="w99p pdl10">
	<div class="row-fluid single-section">
	<?php  
			foreach ($finaldata as $courserole):   
                            ?> 

			<?php if (!empty($courserole['profiles']['id'])){?>
			<a href="<?php echo $this->webroot?>profiles/about/<?php echo base64_encode($courserole['profiles']['id'])?> ">
				<div style="float: left; margin:10px">
				<?php if (!empty($courserole['profiles']['link'])){?>
					<img  src="<?php echo $courserole['profiles']['link'];?>" width="50">
				<?php }else {
					echo $this->Html->image('noimagefound.jpg',array('width'=>'50'));
				}?>	
				</div>
				<div style="margin:8px"><h4><?php echo $courserole[0]['nameprifle'];?></h4></div>
			</a>
                        <?php }?>
            <div style="clear: both"></div>
                        <?php if($_REQUEST['keyword']==$courserole['courses']['teacherKey']){?>
                         <?php echo $this->Html->link('Add Teacher',array('controller'=>'courses','action'=>'addteachers',$courserole['courses']['id']),array('type'=>'button','class'=>'btn btn-mini','style'=>'float:right;margin: 18px 18px'));?>
                         <?php }?>
            
			<?php if (!empty($courserole['courses']['id'])){?> 
			
				<!-- <a href="<?php //echo $this->webroot?>courseroles/overview1/<?php //echo base64_encode($courserole['courses']['id'])?> "> -->
				<a href="javascript:void(0)">
					<div style="float: left; margin:10px">
					<?php if (!empty($courserole['courses']['link'])){?>
						<img  src="<?php echo $courserole['courses']['link'];?>" width="50">
					<?php }else {
						echo $this->Html->image('noimagefound.jpg',array('width'=>'50'));
					}?>	
					</div>
					<div style="margin:8px"><h4><?php echo $courserole['courses']['courseName'];?></h4></div>
					<?php if($courserole['courses']['courseKey'] == $_REQUEST['keyword']):?>
					<div style="float: right;padding: 0px 23px">  
					<?php 
					if ($courserole['courseroles']['role']==1 AND $courserole['courseroles']['status']==1 AND $courserole['courseroles']['profile_id']==$loggedUser['profile_id']) {
						echo $this->Html->link('Start Learling Now',array('controller'=>'courseroles','action'=>'coursedetails',$courserole['courses']['id']),array('class'=>'btn btn-mini'));
					} else{
						echo $this->Html->link('Enroll','#myModalEnroll', array('title' => 'Enroll', 'class' => 'btn btn-mini'));
					} ?>
					</div>
				<?php endif ?>
				</a>  
			<?php }if (!empty($courserole['networks']['id'])){?>
					<a href="<?php echo $this->webroot?>networks/overviews1/<?php echo base64_encode($courserole['networks']['id'])?> ">
					<div style="float: left; margin:10px">
					<?php if (!empty($courserole['networks']['link'])){?>
						<img  src="<?php echo $courserole['networks']['link'];?>" width="50">
					<?php }else {
						echo $this->Html->image('noimagefound.jpg',array('width'=>'50'));
					}?>	
					</div>
					<div style="margin:8px"><h4><?php echo $courserole['networks']['titlename'];?></h4></div>
				</a>
			<?php }if (!empty($courserole['users']['id'])){
                  $photo=$link1[$courserole['users']['profile_id']];
			?>
					<a href="<?php echo $this->webroot?>profiles/about/<?php echo base64_encode($courserole['users']['profile_id'])?> ">
					<div style="float: left; margin:10px">
					<?php if (!empty($photo)){?>
						<img  src="<?php echo $photo;?>" width="50">
					<?php }else {
						echo $this->Html->image('noimagefound.jpg',array('width'=>'50'));
					}?>	
					</div>
					<div style="margin:8px"><h4><?php echo $profilefullNames[$courserole['users']['profile_id']];?></h4></div>
					<div><p><?php echo $courserole['users']['username'];?></p></div>
				</a>
			<?php }?>
			<div style="clear: both; margin-bottom: 10px;"></div>
	<?php endforeach; ?>
</div>
</div>
<div class="remodal" data-remodal-id="myModalEnroll" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
    <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
    <div class="modal-header">
        <b>If you want to Enroll course, please insert Enrollment Key.</b>
        

    </div>
    <div class="modal-body"> 
<?php echo $this->Form->create("Course", array('action' => 'verifyenrollmentkey/' . $_REQUEST['keyword'])); ?>
    <?php echo $this->Form->input('enrollmentKey',array('value'=>$this->Session->read('oldEnrollKey')??'')) ?> 
<?= $this->Session->flash()?>
    </div>
    <div class="modal-footer">
        <button data-remodal-action="cancel" class="btn btn-mini">Close</button>
        <button class="btn btn-mini">Verify</button>
    </div>
<?php echo $this->Form->end(); ?>

<?php unset($_SESSION['oldEnrollKey']);?>
 </div>
<style type="text/css">
	.single-section {
	    margin-bottom: 14px;
	    border: 1px solid #dddddd;
	    padding: 0px;
	    border-radius: 5px;
	    margin-top: 10px;
	}
</style>