From ea99421800e025aa88fe5527431e4cc766cc0b60 Mon Sep 17 00:00:00 2001 From: Tim Repke <repketim@informatik.hu-berlin.de> Date: Tue, 30 Sep 2014 23:56:52 +0100 Subject: [PATCH] few changes, mainly unstable/wip toggle in admin list; frontend: maps included (also unstable, wip) --- registration-system/admin/pages_list.php | 44 +++++++++++---- registration-system/index.php | 69 ++++++++++++++++++++++++ registration-system/view/style.css | 6 +++ 3 files changed, 108 insertions(+), 11 deletions(-) diff --git a/registration-system/admin/pages_list.php b/registration-system/admin/pages_list.php index c466d3a..3c3107c 100644 --- a/registration-system/admin/pages_list.php +++ b/registration-system/admin/pages_list.php @@ -20,7 +20,9 @@ $ecols = [ "abday" => function($d){ return date('Y-m-d', DateTime::createFromFormat('d.m.Y',$d)->getTimestamp()); }, "comment" => function($d){ return $d; }, "studityp"=> function($d){ return $d; }, - "virgin" => function($d){ return (($d=="Nein") ? 1 : 0); } // nein zu 18+ heißt ja zu virgin => 1 + "virgin" => function($d){ return (($d=="Nein") ? 1 : 0); }, // nein zu 18+ heißt ja zu virgin => 1 + "public" => function($d){ return $d; }, + "essen" => function($d){ return $d; } ]; if(isset($_REQUEST['change'])){ @@ -86,7 +88,7 @@ if(isset($_REQUEST['ajax'])){ $ajax .= ' <label>Anmerkung</label> <textarea id="comment" name="comment" rows="3" cols="40">'.$bachelor["comment"].'</textarea> - <input type="checkbox" name="public" value="public" style="width:40px" '.(($bachelor['public']==1 ? " checked" : "")).'><span style="float:left">Anmeldung verstecken</span><br/> + <input type="checkbox" name="public" value="public" style="width:40px" '.(($bachelor['public']==0 ? " checked" : "")).'><span style="float:left">Anmeldung verstecken</span><br/> <div style="clear:both"></div> Note: No check for validity of data here! <button type="submit" name="submit" id="submit" value="submit">Ändern!</button> @@ -190,7 +192,7 @@ div.btn{ </style>"; -$text .= "Meldeliste"; +$text .= "<h1>Meldeliste</h1>"; $columns = array( "bachelor_id", @@ -209,7 +211,8 @@ $columns = array( "paid", "repaid", "backstepped", - "virgin" + "virgin", + "essen" ); $columnFunctions = array( @@ -223,10 +226,19 @@ $columnFunctions = array( "Abreisetag" => function($person) { return comm_from_mysqlDate( $person["abday"]); }, "Kommentar" => function($person) { return $person["comment"]; }, "StudiTyp" => function($person) { return $person["studityp"]; }, + "Essen" => function($person) { return $person["essen"]; }, "18+" => function($person) { return (($person["virgin"]==0) ? "Ja" : "Nein"); }, "PaidReBack" => function($person) { return ($person["paid"] ? $person["paid"] : "0") .",". ($person["repaid"] ? $person["repaid"] : "0") .",". ($person["backstepped"] ? $person["backstepped"] : "0"); } ); +$text .= "Toggle Column "; + $tcnt = 0; +foreach($columnFunctions as $key => $value){ + $text .= '<a class="toggle-vis" data-column="'.$tcnt.'">'.$key.'</a> - '; + $tcnt++; +} +$text .= "<br />"; + $text .=<<<END <table id="mlist"> <thead> @@ -252,6 +264,7 @@ foreach($people as $person) { $text .= "</tr>"; } + $buttoncol = 11; $text .=<<<END </tbody> </table> @@ -283,22 +296,21 @@ $text .=<<<END $(document).ready(function(){ var ltab = $('#mlist').dataTable({ - "iDisplayLength": 70, "columnDefs": [ { type: 'link', targets: 2 }, { type: 'link', targets: 0 }, - { type: 'prb', targets: 10 } + { type: 'prb', targets: $buttoncol } ], "aoColumnDefs": [ { - "aTargets": [ 10 ], + "aTargets": [ $buttoncol ], "mDataProp": function ( data, type, row ) { if (type === 'set') { - data[10] = row; + data[$buttoncol] = row; var btns = ""; var classes = ["paid", "repaid", "backstepped"]; - var txt = data[10].split(","); + var txt = data[$buttoncol].split(","); for(var i = 0; i < txt.length; i++){ var tmp = (txt[i]==0) ? 0 : 1; btns += "<div onclick=\"btnclick(this, '"+classes[i]+"','"+data[0].match(/<a [^>]+>([^<]+)<\/a>/)[1]+"',"+tmp+");\" class='btn btn-"+classes[i]+"-"+tmp+"'> </div>"; @@ -312,13 +324,23 @@ $text .=<<<END return data.date_rendered; } // 'sort' and 'type' both just use the raw data - return data[10]; + return data[$buttoncol]; } } ], - "order": [[ 2, "asc" ]] + "order": [[ 2, "asc" ]], + "paging": false }); + $('a.toggle-vis').click( function (e) { + e.preventDefault(); + + // Get the column API object + var column = ltab.column( $(this).attr('data-column') ); + + // Toggle the visibility + column.visible( ! column.visible() ); + } ); $(".edit_bachelor").click( function(){ var bid = $(this).text(); $.get( "?page=list&ajax=ajax&form=form&hash="+bid, function( data ) { diff --git a/registration-system/index.php b/registration-system/index.php index 5df3881..bc14836 100644 --- a/registration-system/index.php +++ b/registration-system/index.php @@ -77,6 +77,8 @@ function index_show_content(){ // --- Liste der Anmeldungen index_show_signupTable($fid); + + index_show_fahrtHeader_js($fid); } // Zeige Übersicht aller Fahrten else { @@ -462,6 +464,73 @@ function index_show_alleFahrten(){ * @param $fahrt wenn array, dann Datenbankrow; wenn zahl, dann wird das selektiert */ function index_show_fahrtHeader($fahrt){ + global $index_db, $config_googleAPI; + + if(!is_array($fahrt)){ + // select fahrt by ID + $fahrt = $index_db->select('fahrten', array('fahrt_id','titel','ziel', 'von', 'bis', 'leiter', 'kontakt', 'beschreibung', 'max_bachelor', 'map_pin'), array('fahrt_id'=> $fahrt)); + if(!$fahrt){ index_show_alleFahrten(); return;} + else $fahrt = $fahrt[0]; + } + $cnt = $index_db->count("bachelor", ["AND"=> + ["backstepped" => NULL, + "fahrt_id" => $fahrt['fahrt_id']]]); + + echo '<div class="fahrt"> + <a class="fahrthead" href="index.php?fid='.$fahrt['fahrt_id'].'">'.$fahrt['titel'].'</a>'; + echo 'Ziel: <i>'.$fahrt['ziel'].'</i><br />'; + echo 'Datum: <i>'.comm_from_mysqlDate($fahrt['von'])." - ".comm_from_mysqlDate($fahrt['bis']).'</i><br />'; + echo "Ansprechpartner: <i>".$fahrt['leiter']." (".comm_convert_mail($fahrt['kontakt']).")</i><br />"; + echo "Anmeldungen: <i>".$cnt."; maximal: ".$fahrt['max_bachelor']."</i>"; + echo '<p>'.$fahrt['beschreibung'].'</p> + <div id="map-canvas"></div> + </div>'; +} +function index_show_fahrtHeader_js($fahrt){ + global $index_db; + $pin = $index_db->get("fahrten", "map_pin", ["fahrt_id" => $fahrt]); + + echo '<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> + <script> + + var ziel = new google.maps.LatLng('.str_replace(" ", ", ", $pin ).'); + var marker; + var map; + + function initialize() { + var mapOptions = { + zoom: 8, + center: ziel, + panControl: false, + zoomControl: false, + scaleControl: true, + mapTypeControl: false, + streetViewControl: false, + overviewMapControl: false + }; + + map = new google.maps.Map(document.getElementById(\'map-canvas\'), mapOptions); + + marker = new google.maps.Marker({ + map:map, + draggable:true, + animation: google.maps.Animation.DROP, + position: ziel + }); + + marker.setAnimation(google.maps.Animation.BOUNCE); + } + + + google.maps.event.addDomListener(window, \'load\', initialize); + + </script>'; + +} +/** + * @param $fahrt wenn array, dann Datenbankrow; wenn zahl, dann wird das selektiert + */ +function index_show_fahrtHeader_old($fahrt){ global $index_db; if(!is_array($fahrt)){ // select fahrt by ID diff --git a/registration-system/view/style.css b/registration-system/view/style.css index e44ae27..2ce120e 100644 --- a/registration-system/view/style.css +++ b/registration-system/view/style.css @@ -382,3 +382,9 @@ a.editenum { display: block; height: 20px; line-height: 20px; width: 20px; font- font-weight:bold; } +#map-canvas { + height: 300px; + width: 300px; + margin: 0px; + padding: 0px +} \ No newline at end of file -- GitLab