Last active
January 23, 2018 18:18
-
-
Save Meistercoach83/a2b6251d62a0a9e1a22fd44a9199b57b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace APPLICATION\sites\pres\documentcontroller\sfw\verein; | |
use APPLICATION\sites\pres\documentcontroller\sfw\myBaseController; | |
use APF\tools\request\RequestHandler; | |
use APF\core\service\APFService; | |
class kunstrasen_controller extends myBaseController | |
{ | |
private $length = 104; | |
private $width = 67; | |
private $platzMitte = 0; | |
public $sportplatz = array(); | |
function transformContent() | |
{ | |
$this->sportplatz = array(); | |
$form = &$this->getForm('form'); | |
$this->setPlatzMitte(); | |
$this->generateSportplatz(); | |
$this->getTorLinie(); | |
$this->getFuenfer(); | |
$this->getSechzehner(); | |
$this->getElfmeterPunkt(); | |
$this->getEckpunkte(); | |
#$betragprofeld = 10; | |
#$verkauftArray = downloadVerkauftListe(); | |
#$this->sportplatz = setzeVerkaufteFelder($this->sportplatz, $this->length, $this->width, $verkauftArray); | |
/* $this->sportplatz = setzeVerkaufteFelder($this->sportplatz, $this->length, $this->width, $verkauftArray); */ | |
if ($form->isSent()) { | |
var_dump($form); | |
} else { | |
$content = ''; | |
foreach ($this->sportplatz AS $row) { | |
$content .= "<tr>"; | |
foreach ($row AS $cell) { | |
$content .= $this->generateCell($cell); | |
} | |
$content .= "</tr>\n"; | |
} | |
$form->setPlaceHolder('content', $content); | |
$this->setPlaceHolder('form', $form->transformForm()); | |
} | |
} | |
private function setPlatzMitte() | |
{ | |
$this->platzMitte = round($this->width / 2); | |
} | |
function getElfmeterPunkt() | |
{ | |
$this->sportplatz[$this->platzMitte - 1][10]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - 1][$this->length - 11]['bezeichnung'] | |
= '11er'; | |
$this->sportplatz[$this->platzMitte - 1][10]['status'] | |
= $this->sportplatz[$this->platzMitte - 1][$this->length - 11]['status'] | |
= array( | |
'color' => 'orange', | |
'description' => 'Sonderfläche 11er' | |
); | |
} | |
function getTorLinie() | |
{ | |
for ($i = 1; $i < 5; $i++) { | |
$this->sportplatz[$this->platzMitte - $i][0]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][0]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1]['bezeichnung'] | |
= 'Tor'; | |
$this->sportplatz[$this->platzMitte - $i][0]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][0]['status'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1]['status'] | |
= array( | |
'color' => 'red', | |
'description' => 'Sonderfläche Torlinie' | |
); | |
// Verlängerung 5er | |
for ($j = 1; $j < 5; $j++) { | |
$this->sportplatz[$this->platzMitte - $i][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1 - $j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1 - $j]['bezeichnung'] | |
= '5er'; | |
$this->sportplatz[$this->platzMitte - $i][$j]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['status'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1 - $j]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1 - $j]['status'] | |
= array( | |
'color' => 'blue', | |
'description' => 'Sonderfläche 5er' | |
); | |
} | |
// Verlängerung 16er | |
for ($j = 5; $j < 16; $j++) { | |
$this->sportplatz[$this->platzMitte - $i][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1 - $j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1 - $j]['bezeichnung'] | |
= '16er'; | |
$this->sportplatz[$this->platzMitte - $i][$j]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['status'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1 - $j]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1 - $j]['status'] | |
= array( | |
'color' => 'green', | |
'description' => 'Sonderfläche 16er' | |
); | |
} | |
} | |
} | |
function getFuenfer() | |
{ | |
for ($i = 5; $i < 10; $i++) { | |
$this->sportplatz[$this->platzMitte - $i][0]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][0]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1]['bezeichnung'] | |
= '5er'; | |
$this->sportplatz[$this->platzMitte - $i][0]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][0]['status'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1]['status'] | |
= array( | |
'color' => 'blue', | |
'description' => 'Sonderfläche 5er' | |
); | |
// Verlängerung 5er | |
for ($j = 1; $j < 5; $j++) { | |
$this->sportplatz[$this->platzMitte - $i][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - $j - 1]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - $j - 1]['bezeichnung'] | |
= '5er'; | |
$this->sportplatz[$this->platzMitte - $i][$j]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['status'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - $j - 1]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - $j - 1]['status'] | |
= array( | |
'color' => 'blue', | |
'description' => 'Sonderfläche 5er' | |
); | |
} | |
// Verlängerung 16er | |
for ($j = 5; $j < 16; $j++) { | |
$this->sportplatz[$this->platzMitte - $i][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - $j - 1]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - $j - 1]['bezeichnung'] | |
= '16er'; | |
$this->sportplatz[$this->platzMitte - $i][$j]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['status'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - $j - 1]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - $j - 1]['status'] | |
= array( | |
'color' => 'green', | |
'description' => 'Sonderfläche 16er' | |
); | |
} | |
} | |
} | |
function getSechzehner() | |
{ | |
$this->platzMitte = round($this->width / 2); | |
for ($i = 10; $i < 21; $i++) { | |
$this->sportplatz[$this->platzMitte - $i][0]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][0]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1]['bezeichnung'] | |
= '16er'; | |
$this->sportplatz[$this->platzMitte - $i][0]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][0]['status'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - 1]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - 1]['status'] | |
= array( | |
'color' => 'green', | |
'description' => 'Sonderfläche 16er' | |
); | |
for ($j = 1; $j < 16; $j++) { | |
$this->sportplatz[$this->platzMitte - $i][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - $j - 1]['bezeichnung'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - $j - 1]['bezeichnung'] | |
= '16er'; | |
$this->sportplatz[$this->platzMitte - $i][$j]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$j]['status'] | |
= $this->sportplatz[$this->platzMitte - $i][$this->length - $j - 1]['status'] | |
= $this->sportplatz[$this->platzMitte + $i - 2][$this->length - $j - 1]['status'] | |
= array( | |
'color' => 'green', | |
'description' => 'Sonderfläche 16er' | |
); | |
} | |
} | |
} | |
function getEckpunkte() | |
{ | |
$this->sportplatz[0][0]['bezeichnung'] | |
= $this->sportplatz[0][$this->length - 1]['bezeichnung'] | |
= $this->sportplatz[$this->width - 1][0]['bezeichnung'] | |
= $this->sportplatz[$this->width - 1][$this->length - 1]['bezeichnung'] | |
= 'Ecke'; | |
$this->sportplatz[0][0]['status'] | |
= $this->sportplatz[0][$this->length - 1]['status'] | |
= $this->sportplatz[$this->width - 1][0]['status'] | |
= $this->sportplatz[$this->width - 1][$this->length - 1]['status'] | |
= array( | |
'color' => 'orange', | |
'description' => 'Sonderfläche Eckball' | |
); | |
} | |
function generateSportplatz() | |
{ | |
for ($i = 0; $i < $this->width; $i++) { | |
for ($j = 0; $j < $this->length; $j++) { | |
$this->sportplatz[$i][] = array( | |
'feld' => $j + $i * $this->length, | |
'bezeichnung' => '', | |
'status' => '' | |
); | |
} | |
} | |
} | |
function generateCell($cell) | |
{ | |
$text = '<td>'; | |
if(is_array($cell['status'])) { | |
$text .= '<div class="quadrat '.$cell['status']['color'].'" title="'.$cell['status']['description'].'"></div>'; | |
} | |
else { | |
$text .= '<input type="checkbox" name="check[]" title="Feld '.$cell['feld'].'" value="'.$cell['feld'].'">'; | |
} | |
// $cell['bezeichnung'] !== '' ? $cell['bezeichnung'] . '-' . $cell['feld'] : $cell['feld'] | |
// $text .= '<a title="'.$cell['bezeichnung'].'">'.$cell['feld'].'</a>'; | |
/*if (@$_POST["testval1"] AND in_array($k, $check)) { | |
$chk = "checked"; | |
} else { | |
$chk = ""; | |
} */ | |
// {$chk} | |
$text .= "</td>\n"; | |
return $text; | |
} | |
function setzeVerkaufteFelder($verkauftArray) | |
{ | |
foreach ($verkauftArray AS $verkauft) { | |
// var_dump($verkauft); | |
/*echo $verkauftesFeld . "- "; | |
$row = ceil(($verkauftesFeld) / $this->length); | |
$this->sportplatz[$row][0]['status'] = array( | |
'color' => 'grey', | |
'description' => 'verkauft' | |
); | |
*/ | |
echo "<br />"; | |
} | |
} | |
function downloadVerkauftListe() | |
{ | |
$spreadsheet_url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vQyCDJv4MmBuJ9iKlzL3MXzpm09chuIhRjPYZ73N-vONXbmr3jV0hmv_c9NK2xj0TMVRlLdJzHtL1Kd/pub?gid=0&single=true&output=csv"; | |
$spreadsheet_data = null; | |
if (!ini_set('default_socket_timeout', 15)) echo "<!-- unable to change socket timeout -->"; | |
if (($handle = fopen($spreadsheet_url, "r")) !== FALSE) { | |
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | |
$spreadsheet_data[] = $data; | |
} | |
fclose($handle); | |
} else | |
die("Problem reading csv"); | |
return $spreadsheet_data; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment