Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.94 KB | None | 0 0
  1. @if($table->record->isNotEmpty())
  2.     <table class="table table-bordered">
  3.         <thead>
  4.         <tr>
  5.             <th>Pavadinimas</th>
  6.             @foreach($tableCalendar['day'] as $day)
  7.                 <th>{{ $day }}</th>
  8.             @endforeach
  9.         </tr>
  10.         </thead>
  11.         @php
  12.             $modifiedRecords= array();
  13.  
  14.  
  15.             foreach($table->record as $record)
  16.             {
  17.                 if(!in_array($record->table_id,$modifiedRecords)){
  18.  
  19.                     $sameRecordsCount=0;
  20.                     $SameRecordsInfo=array();
  21.                     array_push($sameRecordsInfo,array($record->date,$record->liters));
  22.                     foreach($table->record as $TemporaryRecord)
  23.                     {
  24.                         if( $record->table_id == $TemporaryRecord->table_id
  25.                             &&
  26.                             $record->id != $TemporaryRecord->id){
  27.  
  28.                             $sameRecordsCount++;
  29.                             array_push($sameRecordsInfo,array($TemporaryRecord->date,$Temporaryrecord->liters));
  30.                         }
  31.                     }
  32.                     if($sameRecordsCount==0){
  33.                         echo "<tbody>
  34.                           <tr>
  35.                            <td>". $record->title ."</td>";
  36.                             foreach($tableCalendar['full_date'] as $fullDate)
  37.                             {
  38.                                  echo "<td>";
  39.                                     if($fullDate == $record->date){
  40.                                         array_push($modifiedRecords,$record->table_id);
  41.                                         echo $record->liters ;
  42.                                         }
  43.                                     else
  44.                                         echo "-";
  45.  
  46.                                  echo "</td>";
  47.                             }
  48.                         echo "</tr>
  49.                            </tbody>";
  50.                     }
  51.                     else{
  52.                         echo "<tbody>
  53.                                <tr>
  54.                                <td>". $record->title ."</td>";
  55.                         array_push($modifiedRecords,$record->table_id);
  56.                         $x=0;
  57.                         foreach($tableCalendar['full_date'] as $fullDate)
  58.                         {
  59.                             echo "<td>";
  60.                                 if($fullDate == $sameRecordsInfo[$x][0]){
  61.                                     echo $sameRecordsInfo[$x][1];
  62.                                     $x++;
  63.                                     }
  64.                                 else
  65.                                     echo "-";
  66.  
  67.                             echo "</td>";
  68.                         }
  69.                         echo "</tr>
  70.                            </tbody>";
  71.                     }
  72.             }
  73.         }
  74.         @endphp
  75.     </table>
  76. @else
  77.     <p>Nėra įrašų.</p>
  78. @endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement