<style>
.card-header{padding:8px; background:#e0ffe0;}
.card-header a{font-size:18px;}
.applied{font-size:14px; color:#FFF;}
</style>
<div class="container" style="margin-top:50px;">
	<h4 class="text-success">Hi, <?php echo $this->session->userdata("name");?></h4>
    <p>Send Your Proposal with suitable Quote..</p>
    <div class="row">
    <div class="col-md-3">
        <div class="card">
         <!-- card-group-item.// -->
            <article class="card-group-item">
            	<header class="card-header">
                    <h4 class="title">Filter By Technologies </h4>
                </header>
                <div class="filter-content">
                    <div class="card-body">
                    <?php $techs=$this->db->get('techs')->result();foreach($techs as $t){?>
                        <div class="custom-control custom-checkbox">
                            <span class="float-right badge badge-light round">0</span>
                            <input type="checkbox" class="custom-control-input" value="<?php echo $t->tid;?>" name="techs[]" id="check<?php echo $t->tid;?>">
                            <label class="custom-control-label" for="check<?php echo $t->tid;?>"><?php echo $t->tech_name;?></label>
                        </div> <!-- form-check.// -->
					<?php }?>        
                       
                    </div> <!-- card-body.// -->
                </div>
            </article> <!-- card-group-item.// -->
        </div>
    </div>
    <div class="col-md-9">
    	<div id="accordion">
	  <?php $i=1;foreach($projects as $p){?>
      <div class="card">
        <div class="card-header">
          <a class="card-link" data-toggle="collapse" href="#collapseOne<?php echo $i;?>">
            <?php echo $p->pro_title;?>
            <label class="badge badge-light float-right"><?php echo 'Posted on '.date("d M",strtotime($p->post_date));?></label>
          </a>
        </div>
        <div id="collapseOne<?php echo $i;?>" class="collapse show" data-parent="#accordion">
          <div class="card-body">
            <?php   $techs=explode(",",$p->ptechs);
                    foreach($techs as $t){
						$tt=$this->db->get_where("techs",array("tid"=>$t))->row();
						echo '<label class="badge badge-success">'.$tt->tech_name.'</label>&nbsp;&nbsp;';
					}?>
                    <?php if(!$this->session->userdata("user")){?>
                    <a href="#" class="btn btn-warning float-right btn-sm"  data-toggle="modal" data-target="#myModal">Login to Apply</a>
                    <?php }else if($this->db->get_where("applied",array("uid"=>$this->session->userdata("user"),"pro_id"=>$p->pro_id))->num_rows()>0){?>
                    <label class="badge badge-warning float-right applied"><i class="fa fa-check"></i> Applied</label>
                    <?php }else{?>
                    <button type="button" data-toggle="modal" title="<?php echo $p->pro_title;?>" data-target="#detailmodal" id="<?php echo $p->pro_id;?>" class="btn btn-warning view_details btn-sm float-right">Apply</button>
                    <?php }?>
          </div>
        </div>
      </div><br/>
	  <?php $i++;}?>
    </div>
    </div>
    </div>
</div>
<div id="detailmodal" class="modal fade" role="dialog">
          <div class="modal-dialog modal-lg">
            <!-- Modal content-->
            <div class="modal-content">
              <div class="modal-header">
                <h4 class="modal-title"></h4>
                <button type="button" class="close" data-dismiss="modal">&times;</button>
              </div>
              <div class="modal-body project_details row">
                
              </div>
            </div>
          </div>
        </div>
<script>
$(document).ready(function(){
	$(".view_details").click(function(){
		var id=$(this).attr('id');
		var title=$(this).attr('title');
		$(".modal-title").text(title);
		$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>home/view_details',
			 data: {id:id},
			 success: function(res){
				 //alert(res);
				 $(".project_details").html(res);
			 }
		});
	});
});
</script>