<?php 
                   if( count($this->FixtureTime )>0){
                    
                    ?>
                        <div class="span12" style="margin:0px; margin-bottom:20px  ">
                        <div class="head clearfix">
                            <div class="isw-cloud"></div>
                            <h1>Career List</h1>
                            <ul class="buttons">        
                               <li class="toggle active"><a href="#"></a></li>
                            </ul> 
                        </div>
                        <div class="block  " style="padding: 0px; margin-bottom:0px " id="CareerList">
                           <table class="table table-dark">
                           	<tr>
                           	<th width="10%">Date</th>
                           	
                           	<th width="72%" colspan="6">Tournament</th>
                           
                           	<th width="2%">S</th>
                           	<th width="2%">B</th>
                           	<th width="2%">T</th>
                           	<th width="2%">C</th>
                           	<th width="2%">P</th>
                           	<th width="2%">D</th>
                           	<th width="2%">YC</th>
                           	<th width="2%">RC</th>
                           	<th width="2%">GT</th>
                           	</tr>
                           	<?php
                           	$totalStart  = 0;
							$totalBench  = 0;
							$totaltries  = 0;$totalConversions  = 0;$totalPenalties  = 0;$totalDropGoals  = 0;$totalYellowCard  = 0;$totalRedCard  = 0;
							$totalGameTime  = 0;
							
                           	 if(count($this->FixtureTime)>0 ){
                           	 	foreach($this->FixtureTime as $Fixtures){
                           	 		
									$T_totalStart  = 0;
							$T_totalBench  = 0;
							$T_totaltries  = 0;$T_totalConversions  = 0;$T_totalPenalties  = 0;$T_totalDropGoals  = 0;
							$T_totalYellowCard  = 0;$T_totalRedCard  = 0;
							$T_totalGameTime  = 0;
									foreach ($Fixtures as $Fixture) {
										$T_totalStart = $T_totalStart+$Fixture["Started"];
										$T_totalBench = $T_totalBench+$Fixture["Banched"];
										$T_totalGameTime = $T_totalGameTime+$Fixture["Total_GameTime"];
									}
									
                           	 		?>
									<tr  style="cursor: pointer" id="<?=md5($Fixtures[0]["TID"])?>" onclick="DisplayFixtures(this)">
                           	<th><?=date("Y",strtotime($Fixtures[0]["FixtureDate"]))?></th>
                           
                           	<th colspan="6"><i class="fa fa-arrow-alt-circle-down"></i> <span><?=$Fixtures[0]["TournName"]?></span></th>
                           	<th><?=$T_totalStart?></th>
                           	<th><?=$T_totalBench?></th>
                           	<th></th>
                           	<th></th>
                           	<th></th>
                           	<th></th>
                           	<th></th>
                           	<th></th>
                           	<th><?=SecToMin($T_totalGameTime)?></th>
                           	</tr>
								
									<tr  style="display: none" class="<?=md5($Fixtures[0]["TID"])?> hide_Fixtures">
                           	<th width="10%">Date</th>
                           	<th width="5%">Age</th>
                           	<th width="5%">Position</th>
                           	<th width="10%">Team</th>
                           	<th width="10%">Opponent</th>
                           	<th width="10%">Result</th>
                           	<th width="15%">Venue</th>
                           
                           	<th colspan="9"></th>
                           	</tr>	
									
								<?php 	
                           		foreach($Fixtures as $Career){
                           			$totalStart  = $totalStart+$Career["Started"];
									$totalBench  = $totalBench+$Career["Banched"];
									$totalGameTime  = $totalGameTime+$Career["Total_GameTime"];
                           		?>
                           		<tr style="display: none"  class="<?=md5($Fixtures[0]["TID"])?> hide_Fixtures">
                           	<td><?=$Career["FixtureDate"]?></td>
                           	<td><?=$Career["Age"]?></td>
                           	<td><?=$Career["Pos"]?></td>
                           	<td><?=($Career["SID"]==$Career["HomeTeam"])?$Career["Home"]:$Career["Away"]?></td>
                           	<td><?=($Career["SID"]==$Career["AwayTeam"])?$Career["Home"]:$Career["Away"]?></td>
                           	<td></td>
                           	<td><?=$Career["Location"]?></td>
                           	<td><?=$Career["Started"]?></td>
                           	<td><?=$Career["Banched"]?></td>
                           	<td></td>
                           	<td></td>
                           	<td></td>
                           	<td></td>
                           	<td></td>
                           	<td></td>
                           	<td><?=SecToMin($Career["Total_GameTime"])?></td>
                           	</tr>
                           	<?php } 
//End Loop fixtures


                           	}} ?>
                           	<tr>
                           		<td style="text-align: right; font-weight: bold; background: #ccc" colspan="7">Total</td>
                           		<td><?=$totalStart?></td>
                           		<td><?=$totalBench?></td>
                           		<td><?=$totaltries?></td>
                           		<td><?=$totalConversions?></td>
                           		<td><?=$totalPenalties?></td>
                           		<td><?=$totalDropGoals?></td>
                           		<td><?=$totalYellowCard?></td>
                           		<td><?=$totalRedCard?></td>
                           		<td><?=SecToMin($totalGameTime)?></td>
                           	</tr>
                           </table>
                        </div>
                        </div>
                        	
                       <?php } 
                       
                       
                       function SecToMin($seconds) {
  $t = round($seconds);
 $SecToMin = sprintf('%2d:%2d:%02d', ($t/3600),($t/60%60), $t%60);
  $expl = explode(":", $SecToMin);
  $TotalMin = ($expl[0]*60 + $expl[1]);
  $SecToMin = $TotalMin.",".$expl[2];
  return $SecToMin;
//return sprintf('%2d:%2d:%02d', ($t/3600),($t/60%60), $t%60);
}
                       
                       
                       ?>
                       <script>
                       	function DisplayFixtures(e){
                       		var id = $(e).attr("id");
                       		$(".hide_Fixtures").hide();
                       		$("."+id).show();
                       		
                       	}
                       </script>