 <?php
           $d = 0;
           $StDate = $this->StrDate;
           $start_day = date("d",  strtotime($StDate));
           $start_month = date("m",  strtotime($StDate));
           $start_year = date("Y",  strtotime($StDate));
           $start_nextyear = $start_year+1;
              
           $Fixtures = $this->Fixtures;
           while($d<7){
               
                $today = date("Y-m-d",  strtotime($start_year."-".$start_month."-".$start_day));
                $todayTimeStamp = date("Ymd",  strtotime($today));
                
                    $event = " ";
                
                
                 if(isset($Fixtures[$todayTimeStamp]["StartTime"])){
                     
                        $count = json_decode($Fixtures[$todayTimeStamp]["Players1"],true);
                     if($this->SID ==$Fixtures[$todayTimeStamp]["AwayTeam"]){
                        $count = json_decode($Fixtures[$todayTimeStamp]["Players2"],true);
                     }
                     
                     if(count($count)>=$this->SQUAD["RugbyCode"]){
                          $event = "<a href='/union/fixtures/profile/id/".$Fixtures[$todayTimeStamp]["FID"]."/sid/".$this->SID."'> <i class='fa fa-check-circle' style='color:green'></i> ".$Fixtures[$todayTimeStamp]["SquadName1"]." VS ".$Fixtures[$todayTimeStamp]["SquadName2"]." : ".date("H:i",strtotime($Fixtures[$todayTimeStamp]["StartTime"]))."</a>";
                 
                     }else{
                          $event = "<a   data-original-title='Team Not Assigned' data-toggle='tooltip' data-placement='top' href='/union/fixtures/profile/id/".$Fixtures[$todayTimeStamp]["FID"]."/sid/".$this->SID."'> <i class='fa fa-warning' style='color:red'></i> ".$Fixtures[$todayTimeStamp]["SquadName1"]." VS ".$Fixtures[$todayTimeStamp]["SquadName2"]." : ".date("H:i",strtotime($Fixtures[$todayTimeStamp]["StartTime"]))."</a>";
                 
                     }
                
                    $event2=$event;
                 
                     }
               if($today == date("Y-m-d")){
             
                $event = "(0) events today";
                if(isset($Fixtures[$todayTimeStamp]["StartTime"])){
                 $event = $event2;
                }
           ?>
         <div class="list-group-item">
            <span class="title-color current-day"><?= strtoupper(date('l', strtotime($today))) ;?></span>
            <span class="sub-title"><?=date('d', strtotime($today)) ;?> <?= strtoupper(date('M', strtotime($today))) ;?></span>
            <p class="event-day"><?=$event?> </p>
            <div class="list-group-controls">
               <span class="current-date"><?= date("H:i") ?></span>
            </div>
         </div>
           <?php 
               }else{
                   
                   
                   ?>
           <div class="list-group-item site-border-top" href="#">
            <span class="title-color day-font"><?= strtoupper(date('l', strtotime($today))) ;?></span>
            <span class="sub-title"><?=date('d', strtotime($today)) ;?>  <?= strtoupper(date('M', strtotime($today))) ;?></span>
            <p class="event-day"><?=$event?> </p>
            <div class="list-group-controls">
            </div>
         </div>
             <?php }
             if((date('d', strtotime($today)))>date("t")){
                 $start_day = "01";
                 $start_month = date('m', strtotime($today))+1;
             
             if(date('-m-d', strtotime($today))=="-12-31"){
                 $start_year = $start_nextyear;
                 $start_nextyear = $start_nextyear+1;
                 $start_month = "01";
                 $today = date("Y-m-d",  strtotime($start_year."-".$start_month."-".$start_day));
                 
             }
             
             }else{
             $start_day = date('d', strtotime($today))+1;
             $start_month = date('m', strtotime($today));
             
             }
             
             
             
             
           $d++; 
           
           
           
               } 
               
              $lastWeek =  date('Y-m-d', strtotime($StDate.'  -7 days')); 
              $nextWeek =  date('Y-m-d', strtotime($StDate.'  +7 days'));
               
               
               ?>
         
<script>
$(function(){
    console.log("Code: <?=$count?>" );
});
function getNextWeek(){
    
    $("#CalenderBodyWrapa").html("<div style='line-height:505px; text-align:center'>Loading please wait...</div>");
   $.get("/union/squads/calender/sid/<?=$this->SID?>/startingdate/<?=$nextWeek?>",function(html){
       $("#CalenderBodyWrapa").html(html);
   });
   
}

function getLastWeek(){
   $("#CalenderBodyWrapa").html("<div style='line-height:505px; text-align:center'>Loading please wait...</div>");
   $.get("/union/squads/calender/sid/<?=$this->SID?>/startingdate/<?=$lastWeek?>",function(html){
       $("#CalenderBodyWrapa").html(html);
   });
}
</script>