 <?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;
           $AlreadySet = array();
           while($d<7){
               
                $today = date("Y-m-d",  strtotime($start_year."-".$start_month."-".$start_day));
                $todayTimeStamp = strtotime($today);
                $event2 ="";
                     
                    $event = " ";
                if(count($Fixtures[$todayTimeStamp])>0){
                foreach($Fixtures[$todayTimeStamp] as $Fixture){
                    
                    
                        $count = json_decode($Fixture["TeamH"],true);
                     if($this->SID ==$Fixture["AwayTeam"]){
                         $count = json_decode($Fixture["TeamA"],true);
                     }
                    
                     if(count($count)>=$this->SQUAD["RugbyCode"]){
                         if(!in_array($Fixture["FID"], $AlreadySet)){
                             $AlreadySet[] =$Fixture["FID"];
                           $event .= "<a href='/union/fixtures/profile/id/".$Fixture["FID"]."/sid/".$this->SID."'> <i class='fa fa-check-circle' style='color:green'></i> ".$Fixture["SquadName1"]." VS ".$Fixture["SquadName2"]." : ".date("H:i",strtotime($Fixture["StartTime"]))."</a><br />";
                         }
                     }else{
                         if(!in_array($Fixture["FID"], $AlreadySet)){
                             $AlreadySet[] =$Fixture["FID"];
                          $event .= "<a   data-original-title='Team Not Assigned' data-toggle='tooltip' data-placement='top' href='/union/fixtures/profile/id/".$Fixture["FID"]."/sid/".$this->SID."'> <i class='fa fa-warning' style='color:red'></i> ".$Fixture["SquadName1"]." VS ".$Fixture["SquadName2"]." : ".date("H:i",strtotime($Fixture["StartTime"]))."</a><br />";
                         }
                     }
                
                    
                 
                     
                }
                }
                  $event2.=$event;   
                    
               if($today == date("Y-m-d")){
             
                $event = "(0) events today";
                
                if(isset($Fixtures[$todayTimeStamp])){
                 $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>