Coodle Farbcodierung

This commit is contained in:
Manfred Kindl
2018-04-27 15:37:15 +02:00
parent d72dfb1d52
commit 097218884c
2 changed files with 135 additions and 27 deletions
+38 -4
View File
@@ -68,6 +68,8 @@ switch($work)
$email='';
$gruppe_kurzbz='';
$name='';
$backgroundcolor = '';
$textcolor = '';
switch($typ)
{
case 'Ort': $ort = $id; break;
@@ -85,7 +87,7 @@ switch($work)
$gruppe = new gruppe();
if(!$gruppe->loadUser($gruppe_kurzbz))
die('Fehler: '.$gruppe->errormsg);
foreach($gruppe->result as $row)
{
$coodle->coodle_id = $coodle_id;
@@ -108,7 +110,15 @@ switch($work)
}
}
}
echo 'true';
$data['result'] = 'true';
$data['backgroundColor'] = $backgroundcolor;
$data['textColor'] = $textcolor;
if(isset($_POST['format']) && $_POST['format'] == 'json')
echo json_encode($data);
else
echo 'true';
}
else
{
@@ -133,9 +143,33 @@ switch($work)
$coodle->insertvon = $user;
$coodle->updateamum = date('Y-m-d H:i:s');
$coodle->updatevon = $user;
if ($uid != '')
{
$backgroundcolor = 'hsl('.abs((crc32($id)) % 360).', 80%, 90%)';
$textcolor = 'hsl('.abs((crc32($id)) % 360).', 60%, 70%)';
}
elseif ($ort != '')
{
$backgroundcolor = 'hsl('.abs((crc32($id)) % 360).', 0%, 80%)';
$textcolor = 'hsl('.abs((crc32($id)) % 360).', 0%, 50%)';
}
elseif ($email != '')
{
$backgroundcolor = 'hsl('.abs((crc32($id)) % 360).', 80%, 90%)';
$textcolor = 'hsl('.abs((crc32($id)) % 360).', 60%, 70%)';
}
$data['result'] = 'true';
$data['backgroundColor'] = $backgroundcolor;
$data['textColor'] = $textcolor;
if($coodle->saveRessource(true))
echo 'true';
{
if(isset($_POST['format']) && $_POST['format'] == 'json')
echo json_encode($data);
else
echo 'true';
}
else
echo 'Fehler beim Speichern:'.$coodle->errormsg;
}
+97 -23
View File
@@ -286,7 +286,22 @@ echo '<html>
.ressourceItem
{
display: table-cell;
font-size: 0.8em;
padding: 3px;
margin-bottom: 3px;
border-radius: 10px 0 0 10px;
-moz-border-radius: 10px 0 0 10px;
}
.ressourceImage
{
display: table-cell;
vertical-align: top;
padding: 3px;
margin-bottom: 3px;
border-radius: 10px 0 0 10px;
-moz-border-radius: 10px 0 0 10px;
}
#fertig
@@ -315,6 +330,28 @@ echo '<html>
color: #666;
}
.fc-event-draggable
{
z-index: 1000 !important;
}
.ui-state-active
{
border: none !important;
background-color: lightgrey !important;
background-image: none !important;
}
.ressourceElement
{
background-color: lightblue;
margin: 3px;
padding: 2px 4px;
border-radius: 2px;
margin-bottom: 3px;
}
</style>
<script type="text/javascript">
@@ -588,7 +625,7 @@ echo '
</div>
<div id="ressourcen">
<h4>'.$p->t('coodle/ressourcen').'</h4>
<div id="ressourcecontainer">
<div id="ressourcecontainer" style="display: table">
</div>
<div id="ressourcenInput">
<p>
@@ -632,6 +669,7 @@ echo '
type:"POST",
url:"coodle_worker.php",
data:{
"format" : "json",
"work": "addressource",
"id": id,
"typ": typ,
@@ -640,15 +678,16 @@ echo '
},
success: function(data)
{
if(data!="true")
var data_obj = jQuery.parseJSON(data);
if(data_obj.result != "true")
alert("ERROR:"+data)
else
{
// Speichern der Ressource OK
if(typ=="Gruppe")
if(typ == "Gruppe")
location.reload(true);
else
addRessourceToContent(id, typ, bezeichnung);
addRessourceToContent(id, typ, bezeichnung, data_obj.backgroundColor, data_obj.textColor);
}
},
@@ -656,21 +695,28 @@ echo '
});
}
// Zeigt eine Ressource mit deren Events an
function addRessourceToContent(id, typ, bezeichnung)
function addRessourceToContent(id, typ, bezeichnung, backgroundColor, textColor, cr32)
{
// HTML Tags aus der Bezeichnung Entfernen, sofern vorhanden
var div = document.createElement("div");
var div = document.createElement("ul");
var text = document.createTextNode(bezeichnung);
div.appendChild(text);
bezeichnung = div.innerHTML;
if (backgroundColor == "")
backgroundColor = "lightgrey";
if (textColor == "")
textColor = "white";
// Anzeige der Ressource mit Loeschen Button
var code = \'<span class="ressourceItem"> \
var code = \'<div class="ressourceElement" style="background-color: \
\'+backgroundColor+\' \
"><div class="ressourceImage"> \
<a href="#delete" onclick="removeRessource(this, \\\'\'+id+\'\\\',\\\'\'+typ+\'\\\'); return false;"> \
<img src="../../../skin/images/delete_round.png" height="13px" title="'.$p->t('coodle/ressourceEntfernen').'"/> \
</a> \
\'+bezeichnung+\' \
<br /></span>\';
<img src="../../../skin/images/delete_x.png" height="13px" title="'.$p->t('coodle/ressourceEntfernen').'"/> \
</a></div><div class="ressourceItem"> \
\'+bezeichnung+cr32+\' \
<br /></div></div>\';
$("#ressourcecontainer").append(code);
// Events der Ressource hinzufuegen
@@ -685,8 +731,8 @@ echo '
error: function() {
alert("Error fetching data for "+typ+" "+id);
},
color:"lightgrey"
//textColor:"black"
color: backgroundColor,
textColor: textColor
});
}
@@ -736,7 +782,7 @@ echo '
alert("Error fetching data for "+typ+" "+id);
}
});
$(item).parent().remove();
$(item).closest(".ressourceElement").remove();
}';
echo '
@@ -748,36 +794,64 @@ echo '
if(!$coodle->getRessourcen($coodle_id))
die('Fehler:'.$coodle->errormsg);
$backgroundcolor = 0;
$zahl = 0;
$textcolor = '';
foreach($coodle->result as $row)
{
echo "\n\t";
$typ='';
$id='';
$bezeichnung='';
$typ = '';
$id = '';
$bezeichnung = '';
if($row->uid!='')
{
$typ='Person';
$id=$row->uid;
$typ = 'Person';
$id = $row->uid;
$benutzer = new benutzer();
$benutzer->load($row->uid);
$bezeichnung = $benutzer->nachname.' '.$benutzer->vorname;
// $backgroundcolor = 'hsl('.abs((crc32($id)) % 360).', 80%, 90%)';
$textcolor = 'hsl('.abs((crc32($id)) % 360).', 60%, 70%)';
}
elseif($row->ort_kurzbz!='')
{
$typ='Ort';
$id=$row->ort_kurzbz;
$typ = 'Ort';
$id = $row->ort_kurzbz;
$ort = new ort();
$ort->load($row->ort_kurzbz);
$bezeichnung = $ort->bezeichnung;
$bezeichnung = $ort->bezeichnung.' '.$row->ort_kurzbz;
// $backgroundcolor = 'hsl('.abs((crc32($id)) % 360).', 0%, 80%)';
$textcolor = 'hsl('.abs((crc32($id)) % 360).', 0%, 50%)';
}
elseif($row->email!='')
{
$typ = 'Extern';
$id = $row->email;
$bezeichnung = $row->name;
// $backgroundcolor = 'hsl('.abs((crc32($id)) % 360).', 80%, 90%)';
$textcolor = 'hsl('.abs((crc32($id)) % 360).', 60%, 70%)';
}
echo 'addRessourceToContent("'.$db->convert_html_chars($id).'", "'.$db->convert_html_chars($typ).'", "'.$db->convert_html_chars($bezeichnung).'");';
$zahl = abs(crc32($id));
$zahl = strval($zahl);
// $zahl = strrev($zahl);
$zahl = substr($zahl, -3, 3);
$zahl = intval($zahl);
$zahl = abs($zahl % 360);
// $backgroundcolor = crc32($id);
// $backgroundcolor = strval($backgroundcolor);
// $backgroundcolor = strrev($backgroundcolor);
// $backgroundcolor = substr($backgroundcolor, 0, 3);
// $backgroundcolor = intval($backgroundcolor);
// $backgroundcolor = abs($backgroundcolor % 360);
// $backgroundcolor = 'hsl('.$backgroundcolor.', 80%, 90%)';
$backgroundcolor = 'hsl('.$zahl.', 80%, 90%)';
echo 'addRessourceToContent("'.$db->convert_html_chars($id).'", "'.$db->convert_html_chars($typ).'", "'.$db->convert_html_chars($bezeichnung).'", "'.$backgroundcolor.'", "'.$textcolor.'", "'.$zahl.'");';
$zahl = $zahl+20;
}
// Bereits eingetragene Terminvorschlaege laden